rework mute and zonk buttons
Ted Unangst tedu@tedunangst.com
Sat, 15 Jun 2019 18:46:00 -0400
2 files changed,
23 insertions(+),
44 deletions(-)
M
views/honk.html
→
views/honk.html
@@ -52,21 +52,11 @@ </summary>
<div> <p> {{ if .Honk.Public }} -<button onclick="bonk(this, '{{ .Honk.XID }}'); return false;"><a href="/bonk">bonk</a></button> +<button onclick="bonk(this, '{{ .Honk.XID }}');">bonk</button> {{ end }} -<button onclick="showhonkform('{{ .Honk.XID }}', '{{ .Honk.Handle }}'); return false;"><a href="/newhonk">tonk</a></button> -<form class="inlineform" action="/zonkit" method="POST"> -<input type="hidden" name="CSRF" value="{{ .BonkCSRF }}"> -<input type="hidden" name="honk" value="{{ .Honk.XID }}"> -<input type="hidden" name="honker" value="{{ .Honk.Honker }}"> -<input type="hidden" name="convoy" value="{{ .Honk.Convoy }}"> -<button onclick="zonkit(this); return false;"><a href="/zonkit">zonk</a></button> -<select name="wherefore"> -<option>this honk</option> -<option>this honker</option> -<option selected>this convoy</option> -</select> -</form> +<button onclick="showhonkform('{{ .Honk.XID }}', '{{ .Honk.Handle }}');">tonk</button> +<button onclick="muteit(this, '{{ .Honk.Convoy }}');">mute</button> +<button onclick="zonkit(this, '{{ .Honk.XID }}');">zonk</button> </div> </details> <p>
M
views/honkpage.html
→
views/honkpage.html
@@ -36,39 +36,28 @@ el.innerHTML = "bonked"
el.disabled = true post("/bonk", "CSRF={{ $BonkCSRF }}&xid=" + escape(xid)) } -function zonkit(el) { +function muteit(el, convoy) { + el.innerHTML = "muted" + el.disabled = true + post("/zonkit", "CSRF={{ $BonkCSRF }}&wherefore=this+convoy&convoy=" + escape(convoy)) + var els = document.querySelectorAll('article.honk') + for (var i = 0; i < els.length; i++) { + var e = els[i] + if (e.getAttribute("data-convoy") == convoy) { + e.remove() + } + } +} +function zonkit(el, xid) { el.innerHTML = "zonked" el.disabled = true - var data = { } - var convoy, wherefore - for (var i in el.parentElement.elements) { - var e = el.parentElement.elements[i] - if (e.name) { - data[e.name] = e.value - if (e.name == "convoy") { - convoy = e.value - } else if (e.name == "wherefore") { - wherefore = e.value - } - } + post("/zonkit", "CSRF={{ $BonkCSRF }}&wherefore=this+honk&honk=" + escape(xid)) + var p = el + while (p && p.tagName != "ARTICLE") { + p = p.parentElement } - post("/zonkit", encode(data)) - if (wherefore == "this convoy") { - var els = document.querySelectorAll('article.honk') - for (var i = 0; i < els.length; i++) { - var e = els[i] - if (e.getAttribute("data-convoy") == convoy) { - e.remove() - } - } - } else if (wherefore == "this honk") { - var p = el - while (p && p.tagName != "ARTICLE") { - p = p.parentElement - } - if (p) { - p.remove() - } + if (p) { + p.remove() } } </script>