all repos — honk @ 33eddd2dd9c9ed854a8549a8fda45d6c2ea91bc6

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{{ if .HonkCSRF }}
 7<div>
 8<form id="aboutform" action="/saveuser" method="POST">
 9<input type="hidden" name="CSRF" value="{{ .UserCSRF }}">
10<textarea name="whatabout">{{ .RawWhatAbout }}</textarea>
11<p>
12<input type="submit" value="update">
13</form>
14</div>
15{{ else }}
16<p>{{ .WhatAbout }}
17{{ end }}
18{{ end }}
19<p>{{ .ServerMessage }}
20{{ if .HonkCSRF }}
21{{ template "honkform.html" . }}
22{{ end }}
23</div>
24{{ $BonkCSRF := .HonkCSRF }}
25{{ range .Honks }}
26{{ template "honk.html" map "Honk" . "BonkCSRF" $BonkCSRF }}
27{{ end }}
28</main>
29{{ if $BonkCSRF }}
30<script>
31function encode(hash) {
32        var s = []
33        for (var key in hash) {
34                var val = hash[key]
35                s.push(escape(key) + "=" + escape(val))
36        }
37        return s.join("&")
38}
39function post(url, data) {
40	var x = new XMLHttpRequest()
41	x.open("POST", url)
42	x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
43	x.send(data)
44}
45function bonk(el, xid) {
46	el.innerHTML = "bonked"
47	el.disabled = true
48	post("/bonk", "CSRF={{ $BonkCSRF }}&xid=" + escape(xid))
49}
50function zonkit(el) {
51	el.innerHTML = "zonked"
52	el.disabled = true
53	var data = { }
54	for (var i in el.parentElement.elements) {
55		var e = el.parentElement.elements[i]
56		if (e.name) {
57			data[e.name] = e.value
58		}
59	}
60	post("/zonkit", encode(data))
61}
62</script>
63{{ end }}