honk/views/honkpage.html

53 lines
1.2 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-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 = { }
for (var i in el.parentElement.elements) {
var e = el.parentElement.elements[i]
if (e.name) {
data[e.name] = e.value
}
}
post("/zonkit", encode(data))
2019-04-23 17:22:31 +02:00
}
</script>
{{ end }}