rework mute and zonk buttons

This commit is contained in:
Ted Unangst 2019-06-15 18:46:00 -04:00
parent fc67125854
commit 92d192e314
2 changed files with 23 additions and 44 deletions

View File

@ -52,21 +52,11 @@ convoy: <a href="/t?c={{ .Convoy }}">{{ .Convoy }}</a>
<div> <div>
<p> <p>
{{ if .Honk.Public }} {{ 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 }} {{ end }}
<button onclick="showhonkform('{{ .Honk.XID }}', '{{ .Honk.Handle }}'); return false;"><a href="/newhonk">tonk</a></button> <button onclick="showhonkform('{{ .Honk.XID }}', '{{ .Honk.Handle }}');">tonk</button>
<form class="inlineform" action="/zonkit" method="POST"> <button onclick="muteit(this, '{{ .Honk.Convoy }}');">mute</button>
<input type="hidden" name="CSRF" value="{{ .BonkCSRF }}"> <button onclick="zonkit(this, '{{ .Honk.XID }}');">zonk</button>
<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>
</div> </div>
</details> </details>
<p> <p>

View File

@ -36,24 +36,10 @@ function bonk(el, xid) {
el.disabled = true el.disabled = true
post("/bonk", "CSRF={{ $BonkCSRF }}&xid=" + escape(xid)) post("/bonk", "CSRF={{ $BonkCSRF }}&xid=" + escape(xid))
} }
function zonkit(el) { function muteit(el, convoy) {
el.innerHTML = "zonked" el.innerHTML = "muted"
el.disabled = true el.disabled = true
var data = { } post("/zonkit", "CSRF={{ $BonkCSRF }}&wherefore=this+convoy&convoy=" + escape(convoy))
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", encode(data))
if (wherefore == "this convoy") {
var els = document.querySelectorAll('article.honk') var els = document.querySelectorAll('article.honk')
for (var i = 0; i < els.length; i++) { for (var i = 0; i < els.length; i++) {
var e = els[i] var e = els[i]
@ -61,7 +47,11 @@ function zonkit(el) {
e.remove() e.remove()
} }
} }
} else if (wherefore == "this honk") { }
function zonkit(el, xid) {
el.innerHTML = "zonked"
el.disabled = true
post("/zonkit", "CSRF={{ $BonkCSRF }}&wherefore=this+honk&honk=" + escape(xid))
var p = el var p = el
while (p && p.tagName != "ARTICLE") { while (p && p.tagName != "ARTICLE") {
p = p.parentElement p = p.parentElement
@ -69,7 +59,6 @@ function zonkit(el) {
if (p) { if (p) {
p.remove() p.remove()
} }
}
} }
</script> </script>
{{ end }} {{ end }}