all repos — honk @ 3f4e4a9dd65439abb761e7412b890d8faa7a5a1a

my fork of honk

views/honkpage.html (view raw)

 1{{ template "header.html" . }}
 2<main>
 3<div class="info" id="infobox">
 4{{ if .Name }}
 5<p>{{ .Name }} <span style="margin-left:1em;"><a href="/u/{{ .Name }}/rss">rss</a></span>
 6<p>{{ .WhatAbout }}
 7{{ end }}
 8<p>{{ .ServerMessage }}
 9{{ if .HonkCSRF }}
10{{ template "honkform.html" . }}
11{{ end }}
12</div>
13{{ $BonkCSRF := .HonkCSRF }}
14{{ range .Honks }}
15{{ template "honk.html" map "Honk" . "BonkCSRF" $BonkCSRF }}
16{{ end }}
17</main>
18{{ if $BonkCSRF }}
19<script>
20function encode(hash) {
21        var s = []
22        for (var key in hash) {
23                var val = hash[key]
24                s.push(escape(key) + "=" + escape(val))
25        }
26        return s.join("&")
27}
28function post(url, data) {
29	var x = new XMLHttpRequest()
30	x.open("POST", url)
31	x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
32	x.send(data)
33}
34function bonk(el, xid) {
35	el.innerHTML = "bonked"
36	el.disabled = true
37	post("/bonk", "CSRF={{ $BonkCSRF }}&xid=" + escape(xid))
38}
39function zonkit(el) {
40	el.innerHTML = "zonked"
41	el.disabled = true
42	var data = { }
43	for (var i in el.parentElement.elements) {
44		var e = el.parentElement.elements[i]
45		if (e.name) {
46			data[e.name] = e.value
47		}
48	}
49	post("/zonkit", encode(data))
50}
51</script>
52{{ end }}