From 7b09a3aff58adae281acab25f13cf2495f1a07b8 Mon Sep 17 00:00:00 2001 From: Azareal Date: Sun, 27 Oct 2019 18:58:35 +1000 Subject: [PATCH] Changing themes should work without JavaScript now. --- public/global.js | 4 ++-- routes/misc.go | 4 +++- templates/footer.html | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/public/global.js b/public/global.js index fd62497d..65d01528 100644 --- a/public/global.js +++ b/public/global.js @@ -851,12 +851,12 @@ function mainInit(){ }); $("#themeSelectorSelect").change(function(){ - console.log("Changing the theme to " + this.options[this.selectedIndex].getAttribute("val")); + console.log("Changing the theme to " + this.options[this.selectedIndex].getAttribute("value")); $.ajax({ url: this.form.getAttribute("action") + "?s=" + me.User.S, type: "POST", dataType: "json", - data: { "newTheme": this.options[this.selectedIndex].getAttribute("val"), js: "1" }, + data: { "theme": this.options[this.selectedIndex].getAttribute("value"), js: 1 }, error: ajaxError, success: function (data, status, xhr) { console.log("Theme successfully switched"); diff --git a/routes/misc.go b/routes/misc.go index 143282b7..04ef0673 100644 --- a/routes/misc.go +++ b/routes/misc.go @@ -8,6 +8,7 @@ import ( "strconv" "strings" "time" + //"fmt" c "github.com/Azareal/Gosora/common" "github.com/Azareal/Gosora/common/phrases" @@ -85,7 +86,8 @@ func ChangeTheme(w http.ResponseWriter, r *http.Request, user c.User) c.RouteErr //headerLite, _ := SimpleUserCheck(w, r, &user) // TODO: Rename js to something else, just in case we rewrite the JS side in WebAssembly? js := r.PostFormValue("js") == "1" - newTheme := c.SanitiseSingleLine(r.PostFormValue("newTheme")) + newTheme := c.SanitiseSingleLine(r.PostFormValue("theme")) + //fmt.Printf("newTheme: %+v\n", newTheme) theme, ok := c.Themes[newTheme] if !ok || theme.HideFromThemes { diff --git a/templates/footer.html b/templates/footer.html index 3868a5f3..89a5f695 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -12,8 +12,8 @@ {{if .CurrentUser.IsAdmin}}
{{.Header.Elapsed1}}
{{elapsed .Header.StartedAt}}
{{end}}
- {{range .Header.Themes}}{{if not .HideFromThemes}} + {{end}}{{end}}
@@ -26,4 +26,4 @@ - + \ No newline at end of file