all repos — honk @ 88e64f0afccd8b646d57f7a2a4138d74ad9cfb7a

my fork of honk

views/honkform.html (view raw)

 1<p id="honkformhost">
 2<button onclick="showhonkform(); return false"><a href="/newhonk">it's honking time</a></button>
 3<form id="honkform" action="/honk" method="POST" enctype="multipart/form-data" style="display: none">
 4<p>
 5in reply to: <input type="text" name="rid" id="ridinput" value="{{ .InReplyTo }}" autocomplete=off>
 6<input type="hidden" name="CSRF" value="{{ .HonkCSRF }}">
 7<p>
 8<label id="donker">attach: {{ if .SavedFile }} {{ .SavedFile }} {{ else }} <input onchange="updatedonker();" type="file" name="donk"><span></span> {{ end }}</label>
 9<input type="hidden" name="donkxid" value="{{ .SavedFile }}">
10<p>
11<textarea name="noise" id="honknoise">{{ .Noise }}</textarea>
12<p>
13<input type="submit" value="it's gonna be honked">
14<input type="submit" name="preview" value="preview">
15</form>
16<script>
17function showhonkform(elem, rid, hname) {
18	var form = document.getElementById("honkform")
19	form.style = "display: block"
20	if (elem) {
21		form.remove()
22		elem.parentElement.insertAdjacentElement('beforebegin', form)
23	} else {
24		elem = document.getElementById("honkformhost")
25		elem.insertAdjacentElement('afterend', form)
26	}
27	var ridinput = document.getElementById("ridinput")
28	var honknoise = document.getElementById("honknoise")
29	if (rid) {
30		ridinput.value = rid
31		honknoise.value = "@" + hname + " "
32	}
33	document.getElementById("honknoise").focus()
34}
35function updatedonker() {
36	var el = document.getElementById("donker")
37	el.children[1].textContent = el.children[0].value.slice(-20)
38}
39</script>