cleanup javascript a touch

This commit is contained in:
Ted Unangst 2019-08-19 03:21:53 -04:00
parent 072890112c
commit bdda6a5880
1 changed files with 3 additions and 5 deletions

View File

@ -14,13 +14,12 @@
{{ if .TopXID }} {{ if .TopXID }}
<div class="info" id="refreshbox"> <div class="info" id="refreshbox">
<script> <script>
var topxid = {{ .TopXID }} var topxid = "{{ .TopXID }}"
function refreshhonks() { function refreshhonks() {
get("/?topxid=" + escape(topxid), function(xhr) { get("/?topxid=" + escape(topxid), function(xhr) {
var doc = xhr.responseXML var doc = xhr.responseXML
topel = doc.children[0].children[1].children[0] topxid = doc.children[0].children[1].children[0].innerText
topxid = topel.innerText var honks = doc.children[0].children[1].children
honks = doc.children[0].children[1].children
var mebox = document.getElementById("refreshbox") var mebox = document.getElementById("refreshbox")
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])
@ -30,7 +29,6 @@ function refreshhonks() {
</script> </script>
<p><button onclick="refreshhonks()">refresh</button> <p><button onclick="refreshhonks()">refresh</button>
</div> </div>
{{ end }} {{ end }}
{{ range .Honks }} {{ range .Honks }}
{{ template "honk.html" map "Honk" . "BonkCSRF" $BonkCSRF }} {{ template "honk.html" map "Honk" . "BonkCSRF" $BonkCSRF }}