views/homepage.html (view raw)
1{{ template "header.html" . }}
2<div class="center">
3<div class="info" id="infobox">
4<p>{{ .ServerMessage }}
5{{ if .HonkCSRF }}
6{{ template "honkform.html" . }}
7{{ end }}
8</div>
9<div>
10{{ $BonkCSRF := .HonkCSRF }}
11{{ range .Honks }}
12{{ template "honk.html" map "Honk" . "Bonk" $BonkCSRF }}
13{{ end }}
14</div>
15{{ if $BonkCSRF }}
16<script>
17function post(url, data) {
18 var x = new XMLHttpRequest()
19 x.open("POST", url)
20 x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
21 x.send(data)
22}
23function bonk(el, xid) {
24 el.innerHTML = "bonked"
25 el.disabled = true
26 post("/bonk", "CSRF={{ $BonkCSRF }}&xid=" + xid)
27}
28function zonkit(el, xid) {
29 el.innerHTML = "zonked"
30 el.disabled = true
31 post("/zonkit", "CSRF={{ $BonkCSRF }}&xid=" + xid)
32}
33</script>
34{{ end }}