]>
Commit | Line | Data |
---|---|---|
7093e9ba | 1 | function set_style(name){ |
8345760a | 2 | $('link[rel~="stylesheet"]').each(e => e.disabled = true); |
7093e9ba MG |
3 | $('link[title="' + name + '"]')[0].disabled = false; |
4 | localStorage.setItem("theme", name); | |
65ef5465 MG |
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')); | |
7dc32473 | 10 | }); |
7093e9ba | 11 | } |
7dc32473 | 12 | |
7093e9ba | 13 | $(function() { |
81c2ef98 MG |
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>'; | |
7093e9ba | 18 | var sidebar = $('#sidebar')[0]; |
81c2ef98 | 19 | sidebar.insertBefore(m(theme_ul), sidebar.firstChild); |
57b322a1 | 20 | $('#themes a').on('click', e => set_style(e.target.dataset.theme)); |
7093e9ba | 21 | }); |
7dc32473 | 22 | |
8345760a | 23 | let theme = localStorage.getItem("theme"); |
7093e9ba MG |
24 | if(theme) { |
25 | if(theme == "cerulean" || theme == "cosmo") | |
26 | theme = "readable"; | |
27 | set_style(theme); | |
28 | } |