From b4397510e75fe9c387bec4161769392906c81bd7 Mon Sep 17 00:00:00 2001 From: silvus Date: Fri, 19 Apr 2013 22:26:39 +0200 Subject: Add a dark theme and is very simple switch --- js/poche.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'js') 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) { $.get('index.php', { view: view, sort: sort, full_head: 'no' }, function(data) { $('#content').html(data); }); -} \ No newline at end of file +} + + +// ---------- Swith light or dark view +function setActiveStyleSheet(title) { + var i, a, main; + for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { + if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) { + a.disabled = true; + if(a.getAttribute("title") == title) a.disabled = false; + } + } +} +$('#themeswitch').click(function() { + // we want the dark + if ($('body').hasClass('light-style')) { + setActiveStyleSheet('dark-style'); + $('body').addClass('dark-style'); + $('body').removeClass('light-style'); + $('#themeswitch').text('light'); + // we want the light + } else if ($('body').hasClass('dark-style')) { + setActiveStyleSheet('light-style'); + $('body').addClass('light-style'); + $('body').removeClass('dark-style'); + $('#themeswitch').text('dark'); + } + return false; +}); -- cgit v1.2.3