From b48f0adccb11619680a47cac5fa9c68f638bd489 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Sun, 17 May 2020 13:15:41 -0400 Subject: [WebCards] Update from my local repos --- webcards/scripts/theme.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 webcards/scripts/theme.js (limited to 'webcards/scripts/theme.js') diff --git a/webcards/scripts/theme.js b/webcards/scripts/theme.js new file mode 100644 index 0000000..8e69377 --- /dev/null +++ b/webcards/scripts/theme.js @@ -0,0 +1,24 @@ +function Theme(){ + this.t = document.getElementById("theme"); +} + +Theme.prototype = { + init: function() { + if(Cookies.getCookie("theme") == ""){ + Cookies.setYearCookie("theme", "styles/themes/colors-base.css"); + } + }, + + restore: function() { + this.init(); + this.t.setAttribute("href", Cookies.getCookie("theme") + "?v=" + Date.now()); + }, + + set: function(sheet) { + Cookies.setYearCookie("theme", sheet); + this.restore(); + } +}; + +var GlobalTheme = new Theme(); +GlobalTheme.restore(); -- cgit v1.2.3