]>
Commit | Line | Data |
---|---|---|
1 | function set_style(name){ | |
2 | $('link[rel~="stylesheet"]').each(e => e.disabled = true); | |
3 | $('link[title="' + name + '"]')[0].disabled = false; | |
4 | localStorage.setItem("theme", name); | |
5 | $(function() { | |
6 | if(name == 'slate' || name == 'cyborg') | |
7 | $('.logo').each(e => e.classList.remove('logo-light')); | |
8 | else | |
9 | $('.logo').each(e => e.classList.add('logo-light')); | |
10 | }); | |
11 | } | |
12 | ||
13 | $(function() { | |
14 | var theme_ul = '<ul class="list-inline" id="themes">' + | |
15 | '<li><a role="button" data-theme="cyborg">Black</a>' + | |
16 | '<li><a role="button" data-theme="slate">Grey</a>' + | |
17 | '<li><a role="button" data-theme="readable">White</a></ul>'; | |
18 | var sidebar = $('#sidebar')[0]; | |
19 | sidebar.insertBefore(m(theme_ul), sidebar.firstChild); | |
20 | $('#themes a').on('click', e => set_style(e.target.dataset.theme)); | |
21 | }); | |
22 | ||
23 | let theme = localStorage.getItem("theme"); | |
24 | if(theme) { | |
25 | if(theme == "cerulean" || theme == "cosmo") | |
26 | theme = "readable"; | |
27 | set_style(theme); | |
28 | } |