mirror of
https://github.com/rystaf/mlmym.git
synced 2024-11-08 08:04:26 +00:00
theme dropdown
This commit is contained in:
parent
616ee76275
commit
f95ae87385
|
@ -974,7 +974,7 @@ form.create input[type=file], form.create select {
|
||||||
}
|
}
|
||||||
.preferences label{
|
.preferences label{
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 150px;
|
width: 170px;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
|
||||||
|
|
|
@ -387,7 +387,7 @@ function saveSettings(e) {
|
||||||
var targ = e.currentTarget || e.srcElement || e;
|
var targ = e.currentTarget || e.srcElement || e;
|
||||||
var data = new FormData(targ)
|
var data = new FormData(targ)
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
request(targ.target, data, function(res) {
|
request(targ.dataset.target, data, function(res) {
|
||||||
["endlessScrolling", "autoLoad", "markRead"].map(function(x) {
|
["endlessScrolling", "autoLoad", "markRead"].map(function(x) {
|
||||||
localStorage.setItem(x, data.get(x)=="on")
|
localStorage.setItem(x, data.get(x)=="on")
|
||||||
})
|
})
|
||||||
|
|
19
routes.go
19
routes.go
|
@ -778,15 +778,18 @@ func Settings(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
deleteCookie(w, state.Host, name)
|
deleteCookie(w, state.Host, name)
|
||||||
setCookie(w, "", name, r.FormValue(name))
|
setCookie(w, "", name, r.FormValue(name))
|
||||||
}
|
}
|
||||||
state.Dark = new(bool)
|
dark := true
|
||||||
dark := r.FormValue("darkmode")
|
switch r.FormValue("Dark") {
|
||||||
undark := r.FormValue("undarkmode")
|
case "1":
|
||||||
if dark == "0" && undark != "0" {
|
|
||||||
} else if dark == "0" && undark == "0" {
|
|
||||||
setCookie(w, "", "Dark", "0")
|
|
||||||
} else {
|
|
||||||
setCookie(w, "", "Dark", "1")
|
setCookie(w, "", "Dark", "1")
|
||||||
*state.Dark = true
|
state.Dark = &dark
|
||||||
|
case "0":
|
||||||
|
setCookie(w, "", "Dark", "0")
|
||||||
|
dark = false
|
||||||
|
state.Dark = &dark
|
||||||
|
default:
|
||||||
|
deleteCookie(w, "", "Dark")
|
||||||
|
state.Dark = nil
|
||||||
}
|
}
|
||||||
if r.FormValue("shownsfw") != "" {
|
if r.FormValue("shownsfw") != "" {
|
||||||
setCookie(w, "", "ShowNSFW", "1")
|
setCookie(w, "", "ShowNSFW", "1")
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
<div class="error">{{.Error}}</div>
|
<div class="error">{{.Error}}</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<form id="settings" class="preferences" method="POST" target="/{{.Host}}/settings">
|
<form id="settings" class="preferences" method="POST" data-target="/{{.Host}}/settings">
|
||||||
<div>
|
<div>
|
||||||
<label>
|
<label>
|
||||||
default listing
|
default listing
|
||||||
|
@ -106,21 +106,13 @@
|
||||||
<option value="Controversial"{{ if eq .CommentSort "Controversial"}} selected{{end}}>Controversial</option>
|
<option value="Controversial"{{ if eq .CommentSort "Controversial"}} selected{{end}}>Controversial</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div id="darkmode">
|
<div>
|
||||||
<label>
|
<label>theme</label>
|
||||||
dark mode
|
<select name="Dark">
|
||||||
</label>
|
<option {{ if eq .Dark nil}}selected{{end}}>Default</option>
|
||||||
<input type="checkbox" name="darkmode" {{ if is .Dark }}checked{{end}}>
|
<option value="0" {{ if not (or (is .Dark) (eq .Dark nil)) }}selected{{end}}>Light</option>
|
||||||
<input type="hidden" name="darkmode" value="0">
|
<option value="1" {{ if is .Dark }}selected{{end}}>Dark</option>
|
||||||
</div>
|
</select>
|
||||||
<div id="undarkmode">
|
|
||||||
<label>
|
|
||||||
dark mode
|
|
||||||
</label>
|
|
||||||
{{ if not .Dark }}
|
|
||||||
<input type="checkbox" name="undarkmode" checked>
|
|
||||||
{{ end }}
|
|
||||||
<input type="hidden" name="undarkmode" value="0">
|
|
||||||
</div>
|
</div>
|
||||||
<div class="scripting">
|
<div class="scripting">
|
||||||
<label>
|
<label>
|
||||||
|
|
Loading…
Reference in a new issue