/{{ .Board.Name }}/ - {{ .Board.PrefName }}
+/{{ .Board.Name }}/ - {{ .Board.PrefName }}
{{ .Board.Summary }}
{{ $len := len .Posts }} {{ if eq $len 0 }} -- cgit v1.2.3 From c455494cd617d66bc28a30afb1fbd4377e0ecb01 Mon Sep 17 00:00:00 2001 From: KushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com> Date: Mon, 16 Aug 2021 16:35:19 -0300 Subject: extremely basic themes support --- static/js/themes.js | 24 ++++++++++++++++++++++++ static/main.html | 9 ++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 static/js/themes.js (limited to 'static') diff --git a/static/js/themes.js b/static/js/themes.js new file mode 100644 index 0000000..70a1b7f --- /dev/null +++ b/static/js/themes.js @@ -0,0 +1,24 @@ +function setCookie(key, value, age) { + document.cookie = key + "=" + encodeURIComponent(value) + ";sameSite=strict;max-age=" + 60 * 60 * 24 * age + ";path=/"; +} + +function getCookie(key) { + if (document.cookie.length != 0) { + return document.cookie.split('; ').find(row => row.startsWith(key)).split('=')[1]; + } + return ""; +} + +function setTheme(name) { + for (let i = 0, tags = document.getElementsByTagName("link"); i < tags.length; i++) { + if (tags[i].type = "text/css" && tags[i].title) { + tags[i].disabled = !(tags[i].title == name); + } + } + + setCookie("theme", name, 3650); +} + +function applyTheme() { + setTheme(getCookie("theme") || "default"); +} diff --git a/static/main.html b/static/main.html index 3f819dd..3fa1b66 100644 --- a/static/main.html +++ b/static/main.html @@ -8,10 +8,11 @@ - + + {{ template "header" . }} - +All trademarks and copyrights on this page are owned by their respective parties.
-- cgit v1.2.3 From d460fa6316d3db4e68e6b4d4c7ee2d02d6505304 Mon Sep 17 00:00:00 2001 From: KushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com> Date: Wed, 18 Aug 2021 00:50:13 -0300 Subject: it works --- static/js/themes.js | 12 +++++++++++- static/main.html | 13 ++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) (limited to 'static') diff --git a/static/js/themes.js b/static/js/themes.js index 19bdbb4..3f1b906 100644 --- a/static/js/themes.js +++ b/static/js/themes.js @@ -26,5 +26,15 @@ function applyTheme() { tags[i].disabled = true; } } - setTheme(getCookie("theme") || "default"); + let theme = getCookie("theme") || "default"; + setTheme(theme); + + // reflect this in the switcher + let switcher = document.getElementById("themeSwitcher"); + for(var i = 0; i < switcher.options.length; i++) { + if (switcher.options[i].value === theme) { + switcher.selectedIndex = i; + break; + } + } } diff --git a/static/main.html b/static/main.html index 9a88afc..794a602 100644 --- a/static/main.html +++ b/static/main.html @@ -41,11 +41,14 @@ {{ template "bottom" . }} - +-
-
-
- [Catalog] + {{ template "posts" . }}
- [Catalog] + + +
- [ < ] +
- [ < ] {{ end }} {{ range $i, $e := .Pages }} {{ if eq $i $page}} @@ -51,7 +53,7 @@ {{ end }} {{ end }} {{ if lt .CurrentPage .TotalPage }} -
- [ > ] +
- [ > ] {{ end }}
-
-
-
{{ if gt .TotalPage 0 }} {{ $totalPage := .TotalPage }}
-
{{ $page := .CurrentPage }}
{{ if gt $page 0 }}
-