diff options
author | silvus <silvus@silvus.fr> | 2013-04-19 22:26:39 +0200 |
---|---|---|
committer | silvus <silvus@silvus.fr> | 2013-04-19 22:26:39 +0200 |
commit | b4397510e75fe9c387bec4161769392906c81bd7 (patch) | |
tree | 1a8bfc93fad823c4b719165b2456780f64daa1fa /js | |
parent | ff4d8c8c1efca0759330906419cb5f36de86d156 (diff) | |
download | wallabag-b4397510e75fe9c387bec4161769392906c81bd7.tar.gz wallabag-b4397510e75fe9c387bec4161769392906c81bd7.tar.zst wallabag-b4397510e75fe9c387bec4161769392906c81bd7.zip |
Add a dark theme and is very simple switch
Diffstat (limited to 'js')
-rw-r--r-- | js/poche.js | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/js/poche.js b/js/poche.js index 6bc3c188..d27ecbba 100644 --- a/js/poche.js +++ b/js/poche.js | |||
@@ -27,4 +27,32 @@ function sort_links(view, sort) { | |||
27 | $.get('index.php', { view: view, sort: sort, full_head: 'no' }, function(data) { | 27 | $.get('index.php', { view: view, sort: sort, full_head: 'no' }, function(data) { |
28 | $('#content').html(data); | 28 | $('#content').html(data); |
29 | }); | 29 | }); |
30 | } \ No newline at end of file | 30 | } |
31 | |||
32 | |||
33 | // ---------- Swith light or dark view | ||
34 | function setActiveStyleSheet(title) { | ||
35 | var i, a, main; | ||
36 | for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { | ||
37 | if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) { | ||
38 | a.disabled = true; | ||
39 | if(a.getAttribute("title") == title) a.disabled = false; | ||
40 | } | ||
41 | } | ||
42 | } | ||
43 | $('#themeswitch').click(function() { | ||
44 | // we want the dark | ||
45 | if ($('body').hasClass('light-style')) { | ||
46 | setActiveStyleSheet('dark-style'); | ||
47 | $('body').addClass('dark-style'); | ||
48 | $('body').removeClass('light-style'); | ||
49 | $('#themeswitch').text('light'); | ||
50 | // we want the light | ||
51 | } else if ($('body').hasClass('dark-style')) { | ||
52 | setActiveStyleSheet('light-style'); | ||
53 | $('body').addClass('light-style'); | ||
54 | $('body').removeClass('dark-style'); | ||
55 | $('#themeswitch').text('dark'); | ||
56 | } | ||
57 | return false; | ||
58 | }); | ||