diff options
author | KushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com> | 2021-10-05 18:49:08 -0300 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:52:40 -0700 |
commit | 83d8bc02be90950f0661f56f8d4b12d330dbfdcc (patch) | |
tree | 72039e2e93c13ac67bcd92f0249d8843c8e3b7e1 /static | |
parent | e490998c196e5c7a64e8903a500078f5c98e3dad (diff) |
apply theme on load using a cookie
Diffstat (limited to 'static')
-rw-r--r-- | static/js/themes.js | 2 | ||||
-rw-r--r-- | static/main.html | 9 |
2 files changed, 7 insertions, 4 deletions
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 @@ <meta property="og:locale" content="en_US" /> <meta property="og:type" content="website" /> <link rel="icon" type="image/png" href="/static/favicon.png"> - <link rel="stylesheet" type="text/css" href="/static/css/themes/default.css" title="default"> + {{ if gt (len .ThemeCookie) 0 }} + <link rel="stylesheet" type="text/css" href="/static/css/themes/{{.ThemeCookie}}.css" title="selected theme"> + {{ else }} + <link rel="stylesheet" type="text/css" href="/static/css/themes/default.css" title="default"> + {{ end }} {{ range .Themes }} - <link rel="alternate stylesheet" type="text/css" href="/static/css/themes/{{.}}.css" title="{{.}}" disabled> + <link rel="alternate stylesheet" type="text/css" href="/static/css/themes/{{.}}.css" title="{{.}}" disabled> {{ end }} {{ template "header" . }} </head> @@ -49,7 +53,6 @@ <div style="float: right;"> Theme: <select id="themeSwitcher" onchange="setTheme(this.options[this.selectedIndex].value)"> - <option value="default">default</option> {{ range .Themes }} <option value="{{.}}">{{.}}</option> {{ end }} |