add an emu peeker to the honkform.
from petersanchez, adapted to new csp rules
This commit is contained in:
parent
2983156e4b
commit
455989f85b
|
@ -37,6 +37,14 @@
|
||||||
<p><label for=timeend>duration:</label><br>
|
<p><label for=timeend>duration:</label><br>
|
||||||
<input type="text" name="timeend" value="{{ .Duration }}">
|
<input type="text" name="timeend" value="{{ .Duration }}">
|
||||||
</div>
|
</div>
|
||||||
|
<svg class="emuload" id="emuload" xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-mood-neutral" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||||
|
<circle cx="12" cy="12" r="9"></circle>
|
||||||
|
<line x1="9" y1="10" x2="9.01" y2="10"></line>
|
||||||
|
<line x1="15" y1="10" x2="15.01" y2="10"></line>
|
||||||
|
</svg>
|
||||||
|
<div id="emupicker">
|
||||||
|
</div>
|
||||||
</details>
|
</details>
|
||||||
<p>
|
<p>
|
||||||
<textarea name="noise" id="honknoise">{{ .Noise }}</textarea>
|
<textarea name="noise" id="honknoise">{{ .Noise }}</textarea>
|
||||||
|
|
|
@ -446,6 +446,24 @@ function playit(elem, word, wordlist, xid) {
|
||||||
module.addguesscontrols(elem, word, wordlist, xid)
|
module.addguesscontrols(elem, word, wordlist, xid)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
function addemu(data){
|
||||||
|
const box = document.getElementById("honknoise");
|
||||||
|
box.value += data;
|
||||||
|
}
|
||||||
|
function loademus() {
|
||||||
|
div = document.getElementById("emupicker")
|
||||||
|
request = new XMLHttpRequest();
|
||||||
|
request.open('GET', '/emus')
|
||||||
|
request.onload = function(){
|
||||||
|
div.innerHTML = request.responseText
|
||||||
|
}
|
||||||
|
if (div.style.display === "none") {
|
||||||
|
div.style.display = "block";
|
||||||
|
} else {
|
||||||
|
div.style.display = "none";
|
||||||
|
}
|
||||||
|
request.send()
|
||||||
|
}
|
||||||
|
|
||||||
// init
|
// init
|
||||||
(function() {
|
(function() {
|
||||||
|
@ -490,6 +508,7 @@ function playit(elem, word, wordlist, xid) {
|
||||||
return showhonkform()
|
return showhonkform()
|
||||||
}
|
}
|
||||||
document.getElementById("checkinbutton").onclick = fillcheckin
|
document.getElementById("checkinbutton").onclick = fillcheckin
|
||||||
|
document.getElementById("emuload").onclick = loademus
|
||||||
document.querySelector("#donker input").onchange = updatedonker
|
document.querySelector("#donker input").onchange = updatedonker
|
||||||
document.querySelector("button[name=cancel]").onclick = cancelhonking
|
document.querySelector("button[name=cancel]").onclick = cancelhonking
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -253,6 +253,11 @@ input[type=file] {
|
||||||
.honk details.actions summary {
|
.honk details.actions summary {
|
||||||
color: var(--fg-subtle);
|
color: var(--fg-subtle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#emupicker{height:300px;overflow-y:scroll;padding:3px;background:var(--bg-dark);border:solid 5px var(--fg-subtle);text-align:center;display:none;}
|
||||||
|
#emupicker img{margin:0;}
|
||||||
|
.emuload{background:var(--bg-page);padding:0.5em;}
|
||||||
|
|
||||||
.subtle .noise {
|
.subtle .noise {
|
||||||
color: var(--fg-subtle);
|
color: var(--fg-subtle);
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
|
|
38
web.go
38
web.go
|
@ -50,6 +50,8 @@ var honkSep = "h"
|
||||||
|
|
||||||
var develMode = false
|
var develMode = false
|
||||||
|
|
||||||
|
var allemus []Emu
|
||||||
|
|
||||||
func getuserstyle(u *login.UserInfo) template.HTMLAttr {
|
func getuserstyle(u *login.UserInfo) template.HTMLAttr {
|
||||||
if u == nil {
|
if u == nil {
|
||||||
return ""
|
return ""
|
||||||
|
@ -149,6 +151,15 @@ func homepage(w http.ResponseWriter, r *http.Request) {
|
||||||
honkpage(w, u, honks, templinfo)
|
honkpage(w, u, honks, templinfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func showemus(w http.ResponseWriter, r *http.Request) {
|
||||||
|
templinfo := getInfo(r)
|
||||||
|
templinfo["Emus"] = allemus
|
||||||
|
err := readviews.Execute(w, "emus.html", templinfo)
|
||||||
|
if err != nil {
|
||||||
|
elog.Print(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func showfunzone(w http.ResponseWriter, r *http.Request) {
|
func showfunzone(w http.ResponseWriter, r *http.Request) {
|
||||||
var emunames, memenames []string
|
var emunames, memenames []string
|
||||||
emuext := make(map[string]string)
|
emuext := make(map[string]string)
|
||||||
|
@ -2422,6 +2433,30 @@ func addcspheaders(next http.Handler) http.Handler {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func emuinit() {
|
||||||
|
var emunames []string
|
||||||
|
dir, err := os.Open(dataDir + "/emus")
|
||||||
|
if err == nil {
|
||||||
|
emunames, _ = dir.Readdirnames(0)
|
||||||
|
dir.Close()
|
||||||
|
}
|
||||||
|
for _, e := range emunames {
|
||||||
|
if len(e) <= 4 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
ext := e[len(e)-4:]
|
||||||
|
emu := Emu{
|
||||||
|
ID: fmt.Sprintf("/emu/%s", e),
|
||||||
|
Name: e[:len(e)-4],
|
||||||
|
Type: "image/" + ext[1:],
|
||||||
|
}
|
||||||
|
allemus = append(allemus, emu)
|
||||||
|
}
|
||||||
|
sort.Slice(allemus, func(i, j int) bool {
|
||||||
|
return allemus[i].Name < allemus[j].Name
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func serve() {
|
func serve() {
|
||||||
db := opendatabase()
|
db := opendatabase()
|
||||||
login.Init(login.InitArgs{Db: db, Logger: ilog, Insecure: develMode, SameSiteStrict: !develMode})
|
login.Init(login.InitArgs{Db: db, Logger: ilog, Insecure: develMode, SameSiteStrict: !develMode})
|
||||||
|
@ -2436,6 +2471,7 @@ func serve() {
|
||||||
go tracker()
|
go tracker()
|
||||||
go bgmonitor()
|
go bgmonitor()
|
||||||
loadLingo()
|
loadLingo()
|
||||||
|
emuinit()
|
||||||
|
|
||||||
readviews = templates.Load(develMode,
|
readviews = templates.Load(develMode,
|
||||||
viewDir+"/views/honkpage.html",
|
viewDir+"/views/honkpage.html",
|
||||||
|
@ -2454,6 +2490,7 @@ func serve() {
|
||||||
viewDir+"/views/msg.html",
|
viewDir+"/views/msg.html",
|
||||||
viewDir+"/views/header.html",
|
viewDir+"/views/header.html",
|
||||||
viewDir+"/views/onts.html",
|
viewDir+"/views/onts.html",
|
||||||
|
viewDir+"/views/emus.html",
|
||||||
viewDir+"/views/honkpage.js",
|
viewDir+"/views/honkpage.js",
|
||||||
)
|
)
|
||||||
if !develMode {
|
if !develMode {
|
||||||
|
@ -2555,6 +2592,7 @@ func serve() {
|
||||||
loggedin.HandleFunc("/t", showconvoy)
|
loggedin.HandleFunc("/t", showconvoy)
|
||||||
loggedin.HandleFunc("/q", showsearch)
|
loggedin.HandleFunc("/q", showsearch)
|
||||||
loggedin.HandleFunc("/hydra", webhydra)
|
loggedin.HandleFunc("/hydra", webhydra)
|
||||||
|
loggedin.HandleFunc("/emus", showemus)
|
||||||
loggedin.Handle("/submithonker", login.CSRFWrap("submithonker", http.HandlerFunc(submithonker)))
|
loggedin.Handle("/submithonker", login.CSRFWrap("submithonker", http.HandlerFunc(submithonker)))
|
||||||
|
|
||||||
err = http.Serve(listener, mux)
|
err = http.Serve(listener, mux)
|
||||||
|
|
Loading…
Reference in New Issue