]>
Commit | Line | Data |
---|---|---|
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 | $('link[title]').each(e => e.disabled = true); | |
7 | $('link[title="' + name + '"]')[0].disabled = false; | |
8 | localStorage.setItem("theme", name); | |
9 | } | |
10 | ||
11 | $(function() { | |
12 | var theme_ul = '<ul class="list-inline" id="themes">' + | |
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>'; | |
16 | var sidebar = $('#sidebar')[0]; | |
17 | sidebar.insertBefore(m(theme_ul), sidebar.firstChild); | |
18 | $('#themes a').on('click', e => set_style(e.target.dataset.theme, true)); | |
19 | }); | |
20 | ||
21 | let theme = localStorage.getItem("theme"); | |
22 | if(theme) { | |
23 | if(theme == "cerulean" || theme == "cosmo") | |
24 | theme = "readable"; | |
25 | set_style(theme, false); | |
26 | } |