all repos — honk @ d7f4297dae03a4fa6097da17c7ea1d5b15eac4a7

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