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>
<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>

View File

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