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 --- client.go | 8 ++++++++ static/js/themes.js | 12 +++++++++++- static/main.html | 13 ++++++++----- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/client.go b/client.go index bef5c77..31e11f2 100644 --- a/client.go +++ b/client.go @@ -123,6 +123,8 @@ func IndexGet(w http.ResponseWriter, r *http.Request, db *sql.DB) { data.InstanceIndex = GetCollectionFromReq("https://fchan.xyz/followers").Items data.NewsItems = getNewsFromDB(db, 3) + data.Themes = &Themes + t.ExecuteTemplate(w, "layout", data) } @@ -156,6 +158,8 @@ func NewsGet(w http.ResponseWriter, r *http.Request, db *sql.DB, timestamp int) data.Title = actor.PreferredUsername + ": " + data.NewsItems[0].Title + data.Themes = &Themes + t.ExecuteTemplate(w, "layout", data) } @@ -180,6 +184,8 @@ func AllNewsGet(w http.ResponseWriter, r *http.Request, db *sql.DB) { data.Board.Restricted = actor.Restricted data.NewsItems = getNewsFromDB(db, 0) + data.Themes = &Themes + t.ExecuteTemplate(w, "layout", data) } @@ -329,6 +335,8 @@ func CatalogGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection C returnData.Posts = collection.OrderedItems + returnData.Themes = &Themes + t.ExecuteTemplate(w, "layout", returnData) } 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" . }} - +