68 lines
1.6 KiB
HTML
68 lines
1.6 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 }}
|
|
{{ 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 bonk(el, xid) {
|
|
el.innerHTML = "bonked"
|
|
el.disabled = true
|
|
post("/bonk", "CSRF={{ $BonkCSRF }}&xid=" + escape(xid))
|
|
}
|
|
function zonkit(el) {
|
|
el.innerHTML = "zonked"
|
|
el.disabled = true
|
|
var data = { }
|
|
var convoy, wherefore
|
|
for (var i in el.parentElement.elements) {
|
|
var e = el.parentElement.elements[i]
|
|
if (e.name) {
|
|
data[e.name] = e.value
|
|
if (e.name == "convoy") {
|
|
convoy = e.value
|
|
} else if (e.name == "wherefore") {
|
|
wherefore = e.value
|
|
}
|
|
}
|
|
}
|
|
post("/zonkit", encode(data))
|
|
if (wherefore == "this 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()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
{{ end }}
|