little better refresh indicator

This commit is contained in:
Ted Unangst 2019-08-19 21:03:44 -04:00
parent ed0b6c835d
commit 210e1893e2
2 changed files with 10 additions and 2 deletions

View File

@ -2,6 +2,8 @@ changelog
-- next -- next
+ Dynamic refresh.
++ Reply control. Ack replies to show them on the site. ++ Reply control. Ack replies to show them on the site.
+ Schema change. (add flags to honks table) + Schema change. (add flags to honks table)

View File

@ -15,19 +15,25 @@
<div class="info" id="refreshbox"> <div class="info" id="refreshbox">
<script> <script>
var topxid = "{{ .TopXID }}" var topxid = "{{ .TopXID }}"
function refreshhonks() { function refreshhonks(btn) {
btn.innerHTML = "refreshing"
btn.disabled = true
get("/?topxid=" + escape(topxid), function(xhr) { get("/?topxid=" + escape(topxid), function(xhr) {
var doc = xhr.responseXML var doc = xhr.responseXML
topxid = doc.children[0].children[1].children[0].innerText topxid = doc.children[0].children[1].children[0].innerText
var honks = doc.children[0].children[1].children var honks = doc.children[0].children[1].children
var mebox = document.getElementById("refreshbox") var mebox = document.getElementById("refreshbox")
var newhonks = honks.length - 1
for (var i = honks.length; i > 1; i--) { for (var i = honks.length; i > 1; i--) {
mebox.insertAdjacentElement('afterend', honks[i-1]) mebox.insertAdjacentElement('afterend', honks[i-1])
} }
btn.innerHTML = "refresh"
btn.disabled = false
btn.parentElement.children[1].innerHTML = " " + newhonks + " new"
}) })
} }
</script> </script>
<p><button onclick="refreshhonks()">refresh</button> <p><button onclick="refreshhonks(this)">refresh</button><span></span>
</div> </div>
{{ end }} {{ end }}
{{ range .Honks }} {{ range .Honks }}