all repos — honk @ 072be529fbbea94b584bc9cebe984d002b8ea625

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<input type="hidden" name="updatexid" value = "{{ .UpdateXID }}">
 8<p>
 9<label id="donker">attach: {{ if .SavedFile }} {{ .SavedFile }} {{ else }} <input onchange="updatedonker();" type="file" name="donk"><span></span> {{ end }}</label>
10<input type="hidden" name="donkxid" value="{{ .SavedFile }}">
11<p id="donkdescriptor">
12description: <input type="text" name="donkdesc" value="{{ .DonkDesc }}" autocomplete=off>
13<p>
14<textarea name="noise" id="honknoise">{{ .Noise }}</textarea>
15<p>
16<input type="submit" value="it's gonna be honked">
17<input type="submit" name="preview" value="preview">
18</form>
19<script>
20(function() {
21	var el = document.getElementById("donkdescriptor")
22	el.style.display = "none"
23})();
24function showhonkform(elem, rid, hname) {
25	var form = document.getElementById("honkform")
26	form.style = "display: block"
27	if (elem) {
28		form.remove()
29		elem.parentElement.insertAdjacentElement('beforebegin', form)
30	} else {
31		elem = document.getElementById("honkformhost")
32		elem.insertAdjacentElement('afterend', form)
33	}
34	var ridinput = document.getElementById("ridinput")
35	var honknoise = document.getElementById("honknoise")
36	if (rid) {
37		ridinput.value = rid
38		honknoise.value = "@" + hname + " "
39	}
40	document.getElementById("honknoise").focus()
41}
42function updatedonker() {
43	var el = document.getElementById("donker")
44	el.children[1].textContent = el.children[0].value.slice(-20)
45	var el = document.getElementById("donkdescriptor")
46	el.style.display = ""
47}
48</script>