]> iEval git - gruntmaster-page.git/blob - js/90-themes.js
fixed "Page 1 of 0" in job log
[gruntmaster-page.git] / js / 90-themes.js
1 function set_style(name, trans){
2 if(trans){
3 document.body.classList.add('transition-color');
4 setTimeout(() => document.body.classList.remove('transition-color'), 1000);
5 }
6 if(q('html').className == name)
7 return;
8 q('html').className = name;
9 localStorage.setItem("theme", name);
10 }
11
12 $(function() {
13 const theme_ul = '<ul class="list-inline" id="themes">' +
14 '<li><a role="button" data-theme="cyborg">Black</a>' +
15 '<li><a role="button" data-theme="slate">Grey</a>' +
16 '<li><a role="button" data-theme="readable">White</a></ul>';
17 const sidebar = q('#sidebar');
18 sidebar.insertBefore(m(theme_ul), sidebar.firstChild);
19 $('#themes a').on('click', e => set_style(e.target.dataset.theme, true));
20 });
21
22 const theme = localStorage.getItem("theme");
23 if(theme)
24 set_style(theme == "cerulean" || theme == "cosmo" ? "readable" : theme, false);
This page took 0.047009 seconds and 4 git commands to generate.