From 02adb896ef1bfd1c236f1e480850ecbecbd82fac Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Mon, 7 Oct 2019 12:34:36 -0400 Subject: [PATCH] start including servermsg in updates --- views/honkfrags.html | 1 + views/honkpage.html | 2 +- views/honkpage.js | 8 +++++++- web.go | 8 ++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/views/honkfrags.html b/views/honkfrags.html index ad9ba6d..8d72f62 100644 --- a/views/honkfrags.html +++ b/views/honkfrags.html @@ -1,5 +1,6 @@
{{ .TopXID }}
{{ $BonkCSRF := .HonkCSRF }} +

{{ .ServerMessage }}

{{ range .Honks }} {{ template "honk.html" map "Honk" . "BonkCSRF" $BonkCSRF }} diff --git a/views/honkpage.html b/views/honkpage.html index 5f2cc69..d3036f9 100644 --- a/views/honkpage.html +++ b/views/honkpage.html @@ -5,7 +5,7 @@

{{ .Name }} rss

{{ .WhatAbout }} {{ end }} -

{{ .ServerMessage }} +

{{ .ServerMessage }}

{{ if .HonkCSRF }} {{ template "honkform.html" . }} {{ end }} diff --git a/views/honkpage.js b/views/honkpage.js index 5d262e0..40824c7 100644 --- a/views/honkpage.js +++ b/views/honkpage.js @@ -67,7 +67,13 @@ function fillinhonks(xhr) { var doc = xhr.responseXML var stash = curpagestate.name + ":" + curpagestate.arg topxid[stash] = doc.children[0].children[1].children[0].innerText - var honks = doc.children[0].children[1].children[1].children + var srvmsg = doc.children[0].children[1].children[1] + var honks = doc.children[0].children[1].children[2].children + + var srvel = document.getElementById("srvmsg") + srvel.children[0].remove() + srvel.prepend(srvmsg) + var honksonpage = document.getElementById("honksonpage") var holder = honksonpage.children[0] var lenhonks = honks.length diff --git a/web.go b/web.go index f935b44..c76025a 100644 --- a/web.go +++ b/web.go @@ -1509,24 +1509,32 @@ func webhydra(w http.ResponseWriter, r *http.Request) { switch page { case "atme": honks = gethonksforme(userid) + templinfo["ServerMessage"] = "at me!" case "home": honks = gethonksforuser(userid) honks = osmosis(honks, userid) + templinfo["ServerMessage"] = serverMsg case "first": honks = gethonksforuserfirstclass(userid) honks = osmosis(honks, userid) + templinfo["ServerMessage"] = "first class only" case "combo": c := r.FormValue("c") honks = gethonksbycombo(userid, c) + templinfo["ServerMessage"] = "honks by combo: " + c case "convoy": c := r.FormValue("c") honks = gethonksbyconvoy(userid, c) + templinfo["ServerMessage"] = "honks in convoy: " + c case "honker": xid := r.FormValue("xid") if strings.IndexByte(xid, '@') != -1 { xid = gofish(xid) } honks = gethonksbyxonker(userid, xid) + xid = html.EscapeString(xid) + msg := fmt.Sprintf(`honks by honker: %s`, xid, xid) + templinfo["ServerMessage"] = template.HTML(msg) default: http.NotFound(w, r) }