diff options
Diffstat (limited to 'public/js/schemeSwap.js')
-rw-r--r-- | public/js/schemeSwap.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/public/js/schemeSwap.js b/public/js/schemeSwap.js index 3baa09b..044df0f 100644 --- a/public/js/schemeSwap.js +++ b/public/js/schemeSwap.js @@ -26,10 +26,11 @@ function getCookie(cname) { * @param {number} exdays Cookie lifespan (days) */ function setCookie(cname, cvalue, exdays) { + const hostname = window.location.hostname; const d = new Date(); d.setTime(d.getTime() + (exdays*24*60*60*1000)); let expires = "expires="+ d.toUTCString(); - document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/;SameSite=Strict;Domain=.diskfloppy.me"; + document.cookie = `${cname}=${cvalue};${expires};path=/;SameSite=Strict;Domain=${hostname}` } /** @@ -46,7 +47,8 @@ function cookieExists(cname) { * Swaps the colorscheme * @param {string} scheme Color scheme ID */ -function swapScheme(scheme) { +function swapScheme() { + let scheme = document.getElementById('scheme-selector').value ; setCookie("colorscheme", scheme, 90); document.getElementById("css-colorscheme").href = `/css/colorschemes/${scheme}.css`; console.log(`Set colorscheme to ${getCookie("colorscheme")}`) |