diff options
author | Frankie B <git@diskfloppy.me> | 2024-01-22 01:16:42 +0000 |
---|---|---|
committer | Frankie B <git@diskfloppy.me> | 2024-01-22 01:19:23 +0000 |
commit | 6fa9efcc74a9c36f9e2178ee5427eafb8d470d99 (patch) | |
tree | 9bbcf3d82d3c3b49ec34b89d7a2ec625ea6cb400 /public/js | |
parent | 75fed3cbc11691ca9f50780cad187e5693354c49 (diff) |
Get scheme cookie server-side instead of client-side on page load
Diffstat (limited to 'public/js')
-rw-r--r-- | public/js/schemeSwap.js (renamed from public/js/themeSwap.js) | 23 |
1 files changed, 2 insertions, 21 deletions
diff --git a/public/js/themeSwap.js b/public/js/schemeSwap.js index 18faaee..de5a6b2 100644 --- a/public/js/themeSwap.js +++ b/public/js/schemeSwap.js @@ -1,5 +1,5 @@ /** - * Retrieves a cookie's value + * Retrieves a cookies value * @param {string} cname Cookie name * @returns {string} Cookie value */ @@ -44,29 +44,10 @@ function cookieExists(cname) { /** * Swaps the colorscheme - * @param option + * @param {string} scheme Color scheme ID */ function swapScheme(scheme) { setCookie("colorscheme", scheme, 90); document.getElementById("css-colorscheme").href = `/css/colorschemes/${scheme}.css`; console.log(`Set colorscheme to ${getCookie("colorscheme")}`) } - -function setDefaultScheme() { - if (!cookieExists("colorscheme")) { - setCookie("colorscheme", "catppuccin-macchiato", 90); - console.debug("Set default colorscheme"); - } else { - const scheme = getCookie("colorscheme"); - const schemeselector = document.getElementById("scheme-selector"); - if (scheme && schemeselector) { - for (let option of schemeselector.options) { - if (option.value == scheme) { - option.selected = true; - break; - } - } - } - swapScheme(scheme); - } -} |