honk/views/honkform.html

39 lines
1.3 KiB
HTML

<p id="honkformhost">
<button onclick="showhonkform(); return false"><a href="/newhonk">it's honking time</a></button>
<form id="honkform" action="/honk" method="POST" enctype="multipart/form-data" style="display: none">
<p>
in reply to: <input type="text" name="rid" id="ridinput" value="" autocomplete=off>
<input type="hidden" name="CSRF" value="{{ .HonkCSRF }}">
<p>
<label id="donker">attach: <input onchange="updatedonker();" type="file" name="donk"><span></span></label>
<p>
<textarea name="noise" id="honknoise">{{ .Noise }}</textarea>
<p>
<input type="submit" value="it's gonna be honked">
<input type="submit" name="preview" value="preview">
</form>
<script>
function showhonkform(elem, rid, hname) {
var form = document.getElementById("honkform")
form.style = "display: block"
if (elem) {
form.remove()
elem.parentElement.insertAdjacentElement('beforebegin', form)
} else {
elem = document.getElementById("honkformhost")
elem.insertAdjacentElement('afterend', form)
}
var ridinput = document.getElementById("ridinput")
var honknoise = document.getElementById("honknoise")
if (rid) {
ridinput.value = rid
honknoise.value = "@" + hname + " "
}
//document.getElementById("infobox").scrollIntoView()
}
function updatedonker() {
var el = document.getElementById("donker")
el.children[1].textContent = el.children[0].value.slice(-20)
}
</script>