]>
Commit | Line | Data |
---|---|---|
7093e9ba MG |
1 | function set_style(name){ |
2 | $('link[rel~="stylesheet"]').each(function (e){ | |
3 | e.disabled = true; | |
4 | }); | |
5 | $('link[title="' + name + '"]')[0].disabled = false; | |
6 | localStorage.setItem("theme", name); | |
7 | } | |
7dc32473 | 8 | |
7093e9ba | 9 | var theme_ul; |
bdaa8919 | 10 | |
7093e9ba MG |
11 | function add_themelink(theme, text) { |
12 | theme_ul.innerHTML += '<li><a role="button" data-theme="' + theme + '">' + text + '</a>' | |
13 | } | |
bdaa8919 | 14 | |
7093e9ba MG |
15 | $(function() { |
16 | theme_ul = document.createElement('ul'); | |
17 | theme_ul.className = 'list-inline'; | |
18 | theme_ul.id = 'themes'; | |
19 | add_themelink('cyborg', 'Black'); | |
20 | add_themelink('slate', 'Grey'); | |
21 | add_themelink('readable', 'White'); | |
22 | var sidebar = $('#sidebar')[0]; | |
23 | sidebar.insertBefore(theme_ul, sidebar.firstChild); | |
24 | $('#themes a').on('click', function(e){ | |
25 | set_style(this.dataset.theme); | |
7dc32473 | 26 | }); |
7093e9ba | 27 | }); |
7dc32473 | 28 | |
7093e9ba MG |
29 | var theme = localStorage.getItem("theme"); |
30 | if(theme) { | |
31 | if(theme == "cerulean" || theme == "cosmo") | |
32 | theme = "readable"; | |
33 | set_style(theme); | |
34 | } |