all repos — honk @ 171c92443fcb0790fb5f2004d50969a70b604cc0

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 muteit(el, convoy) {
40	el.innerHTML = "muted"
41	el.disabled = true
42	post("/zonkit", "CSRF={{ $BonkCSRF }}&wherefore=zonvoy&what=" + escape(convoy))
43	var els = document.querySelectorAll('article.honk')
44	for (var i = 0; i < els.length; i++) {
45		var e = els[i]
46		if (e.getAttribute("data-convoy") == convoy) {
47			e.remove()
48		}
49	}
50}
51function zonkit(el, xid) {
52	el.innerHTML = "zonked"
53	el.disabled = true
54	post("/zonkit", "CSRF={{ $BonkCSRF }}&wherefore=zonk&what=" + escape(xid))
55	var p = el
56	while (p && p.tagName != "ARTICLE") {
57		p = p.parentElement
58	}
59	if (p) {
60		p.remove()
61	}
62}
63</script>
64{{ end }}