honk/views/honkform.html

48 lines
1.7 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="{{ .InReplyTo }}" autocomplete=off>
<input type="hidden" name="CSRF" value="{{ .HonkCSRF }}">
<p>
<label id="donker">attach: {{ if .SavedFile }} {{ .SavedFile }} {{ else }} <input onchange="updatedonker();" type="file" name="donk"><span></span> {{ end }}</label>
<input type="hidden" name="donkxid" value="{{ .SavedFile }}">
<p id="donkdescriptor">
description: <input type="text" name="donkdesc" value="{{ .DonkDesc }}" autocomplete=off>
<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() {
var el = document.getElementById("donkdescriptor")
el.style.display = "none"
})();
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("honknoise").focus()
}
function updatedonker() {
var el = document.getElementById("donker")
el.children[1].textContent = el.children[0].value.slice(-20)
var el = document.getElementById("donkdescriptor")
el.style.display = ""
}
</script>