all repos — honk @ 15d6fd92771656efcc2b09feb9e1cba2b3333fd4

my fork of honk

views/honkpage.html (view raw)

 1{{ template "header.html" . }}
 2<div class="center">
 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<div>
25{{ $BonkCSRF := .HonkCSRF }}
26{{ range .Honks }}
27{{ template "honk.html" map "Honk" . "BonkCSRF" $BonkCSRF }}
28{{ end }}
29</div>
30{{ if $BonkCSRF }}
31<script>
32function encode(hash) {
33        var s = []
34        for (var key in hash) {
35                var val = hash[key]
36                s.push(escape(key) + "=" + escape(val))
37        }
38        return s.join("&")
39}
40function post(url, data) {
41	var x = new XMLHttpRequest()
42	x.open("POST", url)
43	x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
44	x.send(data)
45}
46function bonk(el, xid) {
47	el.innerHTML = "bonked"
48	el.disabled = true
49	post("/bonk", "CSRF={{ $BonkCSRF }}&xid=" + escape(xid))
50}
51function zonkit(el) {
52	el.innerHTML = "zonked"
53	el.disabled = true
54	var data = { }
55	for (var i in el.parentElement.elements) {
56		var e = el.parentElement.elements[i]
57		if (e.name) {
58			data[e.name] = e.value
59		}
60	}
61	post("/zonkit", encode(data))
62}
63</script>
64{{ end }}