summaryrefslogtreecommitdiff
path: root/scripts/theme.js
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2022-07-17 20:17:28 -0400
committerKyle Gunger <kgunger12@gmail.com>2022-07-17 20:17:28 -0400
commitc9edb73751d20bb3c09b406895ca6982b455c9e4 (patch)
treec6cca364d2612db9bda4776ea19d8856fa29c92d /scripts/theme.js
parent0e010b53fbaa243760f5aabd8ad5ed85c87243fd (diff)
Some fixes
Diffstat (limited to 'scripts/theme.js')
-rw-r--r--scripts/theme.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/scripts/theme.js b/scripts/theme.js
index 78f0149..73d31f7 100644
--- a/scripts/theme.js
+++ b/scripts/theme.js
@@ -9,13 +9,15 @@ const BASE_THEMES = [[
"Dark"
]];
+const APP_NAME = "WebCards";
+
class Theme{
static theme = document.getElementById("theme");
static UserThemes = [[],[]];
static init()
{
- let uth = Cookies.getCookie("userThemes").split(',');
+ let uth = Cookies.getCookie("userThemes-" + APP_NAME).split(',');
for (let i = 1; i < uth.length; i += 2)
{
@@ -23,25 +25,21 @@ class Theme{
this.UserThemes[1].push(uth[i]);
}
- if(Cookies.getCookie("theme") == ""){
- Cookies.setYearCookie("theme", "styles/themes/colors-base.css");
+ if(Cookies.getCookie("theme-" + APP_NAME) == ""){
+ Cookies.setYearCookie("theme-" + APP_NAME, BASE_THEMES[0][0]);
}
- }
- static restore()
- {
- Theme.init();
- Theme.theme.setAttribute("href", Cookies.getCookie("theme") + "?v=" + Date.now());
+ Theme.theme.setAttribute("href", Cookies.getCookie("theme-" + APP_NAME) + "?v=" + Date.now());
}
static set(sheet)
{
- Cookies.setYearCookie("theme", sheet);
+ Cookies.setYearCookie("theme-" + APP_NAME, sheet);
Theme.theme.setAttribute("href", sheet + "?v=" + Date.now());
}
static get() {
- return Cookies.getCookie("theme");
+ return Cookies.getCookie("theme-" + APP_NAME);
}
static setUserThemes() {
@@ -54,7 +52,7 @@ class Theme{
out = out + this.UserThemes[0][i] + "," + this.UserThemes[1][i];
}
- Cookies.setYearCookie("userThemes", out);
+ Cookies.setYearCookie("userThemes-" + APP_NAME, out);
}
static removeUserTheme (index) {
@@ -70,4 +68,4 @@ class Theme{
}
}
-Theme.restore(); \ No newline at end of file
+Theme.init(); \ No newline at end of file