]>
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); | |
5 | } | |
7dc32473 | 6 | |
7093e9ba | 7 | $(function() { |
81c2ef98 MG |
8 | var theme_ul = '<ul class="list-inline" id="themes">' + |
9 | '<li><a role="button" data-theme="cyborg">Black</a>' + | |
10 | '<li><a role="button" data-theme="slate">Grey</a>' + | |
11 | '<li><a role="button" data-theme="readable">White</a></ul>'; | |
7093e9ba | 12 | var sidebar = $('#sidebar')[0]; |
81c2ef98 | 13 | sidebar.insertBefore(m(theme_ul), sidebar.firstChild); |
8345760a | 14 | $('#themes a').on('click', e => set_style(this.dataset.theme)); |
7093e9ba | 15 | }); |
7dc32473 | 16 | |
8345760a | 17 | let theme = localStorage.getItem("theme"); |
7093e9ba MG |
18 | if(theme) { |
19 | if(theme == "cerulean" || theme == "cosmo") | |
20 | theme = "readable"; | |
21 | set_style(theme); | |
22 | } |