From 83d8bc02be90950f0661f56f8d4b12d330dbfdcc Mon Sep 17 00:00:00 2001 From: KushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com> Date: Tue, 5 Oct 2021 18:49:08 -0300 Subject: apply theme on load using a cookie --- static/js/themes.js | 2 +- static/main.html | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'static') diff --git a/static/js/themes.js b/static/js/themes.js index 3f1b906..1d89e60 100644 --- a/static/js/themes.js +++ b/static/js/themes.js @@ -1,5 +1,5 @@ function setCookie(key, value, age) { - document.cookie = key + "=" + encodeURIComponent(value) + ";sameSite=strict;max-age=" + 60 * 60 * 24 * age + ";path=/"; + document.cookie = key + "=" + encodeURIComponent(value) + ";sameSite=none;max-age=" + (60 * 60 * 24 * age) + ";path=/"; } function getCookie(key) { diff --git a/static/main.html b/static/main.html index 3e29053..ba871c0 100644 --- a/static/main.html +++ b/static/main.html @@ -8,9 +8,13 @@ - + {{ if gt (len .ThemeCookie) 0 }} + + {{ else }} + + {{ end }} {{ range .Themes }} - + {{ end }} {{ template "header" . }} @@ -49,7 +53,6 @@