]>
Commit | Line | Data |
---|---|---|
c7a5e4e0 MG |
1 | (function(){ |
2 | 'use strict'; | |
3 | function set_style(name){ | |
d53c616a MG |
4 | $('link[rel~="stylesheet"]').prop('disabled', true); |
5 | $('link[title="' + name + '"]').prop('disabled', false); | |
c7a5e4e0 MG |
6 | localStorage.setItem("theme", name); |
7 | } | |
7dc32473 | 8 | |
bdaa8919 MG |
9 | var selector; |
10 | ||
11 | function add_themelink(theme, text) { | |
12 | var link = $('<a role="button">' + text + '</a>'); | |
13 | link.appendTo(selector.find('ul')).wrap('<li>').on('click', function () { set_style(theme) }); | |
14 | } | |
15 | ||
c7a5e4e0 | 16 | $( document ).ready(function() { |
bdaa8919 MG |
17 | selector = $('<div>Themes: <ul class="list-inline"></ul></div>'); |
18 | add_themelink('cyborg', 'Black'); | |
19 | add_themelink('slate', 'Grey'); | |
20 | add_themelink('readable', 'White'); | |
21 | $('#sidebar').prepend(selector); | |
7dc32473 MG |
22 | }); |
23 | ||
c7a5e4e0 MG |
24 | var theme = localStorage.getItem("theme"); |
25 | if(theme) { | |
a96f684c MG |
26 | if(theme == "cerulean" || theme == "cosmo") |
27 | theme = "readable"; | |
c7a5e4e0 MG |
28 | set_style(theme); |
29 | } | |
30 | })(); |