honk/views/honkpage.html

75 lines
1.8 KiB
HTML
Raw Normal View History

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-06-16 00:46:00 +02:00
function muteit(el, convoy) {
el.innerHTML = "muted"
2019-04-23 17:22:31 +02:00
el.disabled = true
2019-06-17 18:10:36 +02:00
post("/zonkit", "CSRF={{ $BonkCSRF }}&wherefore=zonvoy&what=" + escape(convoy))
2019-06-16 00:46:00 +02:00
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-26 15:07:13 +02:00
}
}
2019-06-16 00:46:00 +02:00
}
function zonkit(el, xid) {
el.innerHTML = "zonked"
el.disabled = true
2019-06-17 18:10:36 +02:00
post("/zonkit", "CSRF={{ $BonkCSRF }}&wherefore=zonk&what=" + escape(xid))
2019-06-16 00:46:00 +02:00
var p = el
while (p && p.tagName != "ARTICLE") {
p = p.parentElement
}
if (p) {
p.remove()
}
2019-04-23 17:22:31 +02:00
}
2019-08-16 21:35:12 +02:00
function ackit(el, xid) {
el.innerHTML = "acked"
el.disabled = true
post("/zonkit", "CSRF={{ $BonkCSRF }}&wherefore=ack&what=" + escape(xid))
}
2019-08-19 06:01:00 +02:00
function deackit(el, xid) {
el.innerHTML = "deacked"
el.disabled = true
post("/zonkit", "CSRF={{ $BonkCSRF }}&wherefore=deack&what=" + escape(xid))
}
2019-04-23 17:22:31 +02:00
</script>
{{ end }}