gross hack to hide refresh when it won't work
Ted Unangst tedu@tedunangst.com
Fri, 21 Feb 2020 09:54:25 -0500
2 files changed,
14 insertions(+),
13 deletions(-)
M
views/honkpage.html
→
views/honkpage.html
@@ -1,5 +1,17 @@
{{ template "header.html" . }} <main> +{{ if .HonkCSRF }} +<script> +var csrftoken = {{ .HonkCSRF }} +var honksforpage = { } +var curpagestate = { name: "{{ .PageName }}", arg : "{{ .PageArg }}" } +var tophid = { } +tophid[curpagestate.name + ":" + curpagestate.arg] = "{{ .TopHID }}" +var servermsgs = { } +servermsgs[curpagestate.name + ":" + curpagestate.arg] = "{{ .ServerMessage }}" +</script> +<script src="/honkpage.js{{ .JSParam }}"></script> +{{ end }} <div class="info" id="infobox"> <div id="srvmsg"> {{ if .Name }}@@ -17,19 +29,7 @@ <div class="info" id="refreshbox">
<p><button onclick="refreshhonks(this)">refresh</button><span></span> <button onclick="oldestnewest(this)">scroll down</button> </div> -{{ end }} -{{ if .HonkCSRF }} -<script> -var csrftoken = {{ .HonkCSRF }} -var honksforpage = { } -var curpagestate = { name: "{{ .PageName }}", arg : "{{ .PageArg }}" } -var tophid = { } -tophid[curpagestate.name + ":" + curpagestate.arg] = "{{ .TopHID }}" -var servermsgs = { } -servermsgs[curpagestate.name + ":" + curpagestate.arg] = "{{ .ServerMessage }}" - -</script> -<script src="/honkpage.js{{ .JSParam }}"></script> +{{ if eq .ServerMessage "one honk maybe more" }} <script> hideelement("refreshbox")</script> {{ end }} {{ end }} <div id="honksonpage"> <div>
M
views/honkpage.js
→
views/honkpage.js
@@ -167,6 +167,7 @@ if (msg) {
msg.remove() servermsgs[stash] = msg } + showelement("refreshbox") honksforpage[stash] = holder