some more consistency in the honkform shenanigans
Ted Unangst tedu@tedunangst.com
Sun, 20 Oct 2019 15:06:15 -0400
2 files changed,
23 insertions(+),
4 deletions(-)
M
views/honkform.html
→
views/honkform.html
@@ -1,5 +1,5 @@
<p id="honkformhost"> -<button onclick="return showhonkform();"><a href="/newhonk">it's honking time</a></button> +<button id="honkingtime" onclick="return showhonkform();"><a href="/newhonk">it's honking time</a></button> <form id="honkform" action="/honk" method="POST" enctype="multipart/form-data" {{ if not .IsPreview }}style="display: none"{{ end }}> <input type="hidden" name="CSRF" value="{{ .HonkCSRF }}"> <input type="hidden" name="updatexid" value = "{{ .UpdateXID }}">@@ -33,4 +33,5 @@ <textarea name="noise" id="honknoise">{{ .Noise }}</textarea>
<p> <button>it's gonna be honked</button> <button name="preview" value="preview">preview</button> +<button type=button name="cancel" value="cancel" onclick="cancelhonking()">cancel</button> </form>
M
views/honkpage.js
→
views/honkpage.js
@@ -62,6 +62,10 @@ el.innerHTML = s
el.disabled = true post("/zonkit", encode({"CSRF": csrftoken, "wherefore": how, "what": xid})) } + +var lehonkform = document.getElementById("honkform") +var lehonkbutton = document.getElementById("honkingtime") + function fillinhonks(xhr) { var doc = xhr.responseXML var stash = curpagestate.name + ":" + curpagestate.arg@@ -223,12 +227,13 @@ var el = document.getElementById("donkdescriptor")
el.style.display = "none" })(); function showhonkform(elem, rid, hname) { - var form = document.getElementById("honkform") + var form = lehonkform form.style = "display: block" if (elem) { form.remove() elem.parentElement.parentElement.parentElement.insertAdjacentElement('beforebegin', form) } else { + hideelement(lehonkbutton) elem = document.getElementById("honkformhost") elem.insertAdjacentElement('afterend', form) }@@ -237,13 +242,26 @@ var honknoise = document.getElementById("honknoise")
if (rid) { ridinput.value = rid honknoise.value = "@" + hname + " " + } else { + ridinput.value = "" + honknoise.value = "" } document.getElementById("honknoise").focus() return false } -function showelement(id) { - var el = document.getElementById(id) +function cancelhonking() { + hideelement(lehonkform) + showelement(lehonkbutton) +} +function showelement(el) { + if (typeof(el) == "string") + el = document.getElementById(el) el.style.display = "block" +} +function hideelement(el) { + if (typeof(el) == "string") + el = document.getElementById(el) + el.style.display = "none" } function updatedonker() { var el = document.getElementById("donker")