]> iEval git - gruntmaster-page.git/blame - js/90-themes.js
Make JS a bit simpler
[gruntmaster-page.git] / js / 90-themes.js
CommitLineData
74da6b38
MG
1function set_style(name, trans){
2 if(trans){
3 document.body.classList.add('transition-color');
4 setTimeout(() => document.body.classList.remove('transition-color'), 1000);
5 }
5eae1f77 6 $('link[title]').each(e => e.disabled = true);
dee46c5b 7 q('link[title="' + name + '"]').disabled = false;
7093e9ba
MG
8 localStorage.setItem("theme", name);
9}
7dc32473 10
7093e9ba 11$(function() {
65d5cb3b 12 const theme_ul = '<ul class="list-inline" id="themes">' +
81c2ef98
MG
13 '<li><a role="button" data-theme="cyborg">Black</a>' +
14 '<li><a role="button" data-theme="slate">Grey</a>' +
15 '<li><a role="button" data-theme="readable">White</a></ul>';
dee46c5b 16 const sidebar = q('#sidebar');
81c2ef98 17 sidebar.insertBefore(m(theme_ul), sidebar.firstChild);
74da6b38 18 $('#themes a').on('click', e => set_style(e.target.dataset.theme, true));
7093e9ba 19});
7dc32473 20
65d5cb3b
MG
21const theme = localStorage.getItem("theme");
22if(theme)
23 set_style(theme == "cerulean" || theme == "cosmo" ? "readable" : theme, false);
This page took 0.04761 seconds and 4 git commands to generate.