101 lines
2.5 KiB
HTML
101 lines
2.5 KiB
HTML
{{ template "header.html" . }}
|
|
<main>
|
|
<div class="info" id="infobox">
|
|
{{ if .Name }}
|
|
<p>{{ .Name }} <span style="margin-left:1em;"><a href="/u/{{ .Name }}/rss">rss</a></span>
|
|
<p>{{ .WhatAbout }}
|
|
{{ end }}
|
|
<p>{{ .ServerMessage }}
|
|
{{ if .HonkCSRF }}
|
|
{{ template "honkform.html" . }}
|
|
{{ end }}
|
|
</div>
|
|
{{ $BonkCSRF := .HonkCSRF }}
|
|
{{ if .TopXID }}
|
|
<div class="info" id="refreshbox">
|
|
<script>
|
|
var topxid = "{{ .TopXID }}"
|
|
function refreshhonks() {
|
|
get("/?topxid=" + escape(topxid), function(xhr) {
|
|
var doc = xhr.responseXML
|
|
topxid = doc.children[0].children[1].children[0].innerText
|
|
var honks = doc.children[0].children[1].children
|
|
var mebox = document.getElementById("refreshbox")
|
|
for (var i = honks.length; i > 1; i--) {
|
|
mebox.insertAdjacentElement('afterend', honks[i-1])
|
|
}
|
|
})
|
|
}
|
|
</script>
|
|
<p><button onclick="refreshhonks()">refresh</button>
|
|
</div>
|
|
{{ end }}
|
|
{{ range .Honks }}
|
|
{{ template "honk.html" map "Honk" . "BonkCSRF" $BonkCSRF }}
|
|
{{ end }}
|
|
</main>
|
|
{{ if $BonkCSRF }}
|
|
<script>
|
|
function encode(hash) {
|
|
var s = []
|
|
for (var key in hash) {
|
|
var val = hash[key]
|
|
s.push(escape(key) + "=" + escape(val))
|
|
}
|
|
return s.join("&")
|
|
}
|
|
function post(url, data) {
|
|
var x = new XMLHttpRequest()
|
|
x.open("POST", url)
|
|
x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
|
|
x.send(data)
|
|
}
|
|
function get(url, whendone) {
|
|
var x = new XMLHttpRequest()
|
|
x.open("GET", url)
|
|
x.responseType = "document"
|
|
x.onload = function() { whendone(x) }
|
|
x.send()
|
|
}
|
|
function bonk(el, xid) {
|
|
el.innerHTML = "bonked"
|
|
el.disabled = true
|
|
post("/bonk", "CSRF={{ $BonkCSRF }}&xid=" + escape(xid))
|
|
}
|
|
function muteit(el, convoy) {
|
|
el.innerHTML = "muted"
|
|
el.disabled = true
|
|
post("/zonkit", "CSRF={{ $BonkCSRF }}&wherefore=zonvoy&what=" + escape(convoy))
|
|
var els = document.querySelectorAll('article.honk')
|
|
for (var i = 0; i < els.length; i++) {
|
|
var e = els[i]
|
|
if (e.getAttribute("data-convoy") == convoy) {
|
|
e.remove()
|
|
}
|
|
}
|
|
}
|
|
function zonkit(el, xid) {
|
|
el.innerHTML = "zonked"
|
|
el.disabled = true
|
|
post("/zonkit", "CSRF={{ $BonkCSRF }}&wherefore=zonk&what=" + escape(xid))
|
|
var p = el
|
|
while (p && p.tagName != "ARTICLE") {
|
|
p = p.parentElement
|
|
}
|
|
if (p) {
|
|
p.remove()
|
|
}
|
|
}
|
|
function ackit(el, xid) {
|
|
el.innerHTML = "acked"
|
|
el.disabled = true
|
|
post("/zonkit", "CSRF={{ $BonkCSRF }}&wherefore=ack&what=" + escape(xid))
|
|
}
|
|
function deackit(el, xid) {
|
|
el.innerHTML = "deacked"
|
|
el.disabled = true
|
|
post("/zonkit", "CSRF={{ $BonkCSRF }}&wherefore=deack&what=" + escape(xid))
|
|
}
|
|
</script>
|
|
{{ end }}
|