2019-04-09 13:59:33 +02:00
|
|
|
{{ template "header.html" . }}
|
2019-04-29 01:16:24 +02:00
|
|
|
<main>
|
2019-04-23 17:22:31 +02:00
|
|
|
<div class="info" id="infobox">
|
2019-04-09 13:59:33 +02:00
|
|
|
{{ if .Name }}
|
|
|
|
<p>{{ .Name }} <span style="margin-left:1em;"><a href="/u/{{ .Name }}/rss">rss</a></span>
|
|
|
|
<p>{{ .WhatAbout }}
|
|
|
|
{{ end }}
|
2019-04-23 17:22:31 +02:00
|
|
|
<p>{{ .ServerMessage }}
|
|
|
|
{{ if .HonkCSRF }}
|
|
|
|
{{ template "honkform.html" . }}
|
|
|
|
{{ end }}
|
|
|
|
</div>
|
|
|
|
{{ $BonkCSRF := .HonkCSRF }}
|
2019-04-09 13:59:33 +02:00
|
|
|
{{ range .Honks }}
|
2019-04-26 15:07:13 +02:00
|
|
|
{{ template "honk.html" map "Honk" . "BonkCSRF" $BonkCSRF }}
|
2019-04-09 13:59:33 +02:00
|
|
|
{{ end }}
|
2019-04-29 01:16:24 +02:00
|
|
|
</main>
|
2019-04-23 17:22:31 +02:00
|
|
|
{{ if $BonkCSRF }}
|
|
|
|
<script>
|
2019-04-26 15:07:13 +02:00
|
|
|
function encode(hash) {
|
|
|
|
var s = []
|
|
|
|
for (var key in hash) {
|
|
|
|
var val = hash[key]
|
|
|
|
s.push(escape(key) + "=" + escape(val))
|
|
|
|
}
|
|
|
|
return s.join("&")
|
|
|
|
}
|
2019-04-23 17:22:31 +02:00
|
|
|
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
|
2019-04-26 15:07:13 +02:00
|
|
|
post("/bonk", "CSRF={{ $BonkCSRF }}&xid=" + escape(xid))
|
2019-04-23 17:22:31 +02:00
|
|
|
}
|
2019-04-26 15:07:13 +02:00
|
|
|
function zonkit(el) {
|
2019-04-23 17:22:31 +02:00
|
|
|
el.innerHTML = "zonked"
|
|
|
|
el.disabled = true
|
2019-04-26 15:07:13 +02:00
|
|
|
var data = { }
|
2019-05-29 02:57:55 +02:00
|
|
|
var convoy, wherefore
|
2019-04-26 15:07:13 +02:00
|
|
|
for (var i in el.parentElement.elements) {
|
|
|
|
var e = el.parentElement.elements[i]
|
|
|
|
if (e.name) {
|
|
|
|
data[e.name] = e.value
|
2019-05-29 02:57:55 +02:00
|
|
|
if (e.name == "convoy") {
|
|
|
|
convoy = e.value
|
|
|
|
} else if (e.name == "wherefore") {
|
|
|
|
wherefore = e.value
|
|
|
|
}
|
2019-04-26 15:07:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
post("/zonkit", encode(data))
|
2019-05-29 02:57:55 +02:00
|
|
|
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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-23 17:22:31 +02:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
{{ end }}
|