rework mute and zonk buttons
This commit is contained in:
parent
fc67125854
commit
92d192e314
|
@ -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>
|
||||||
|
|
|
@ -36,39 +36,28 @@ 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
|
var els = document.querySelectorAll('article.honk')
|
||||||
for (var i in el.parentElement.elements) {
|
for (var i = 0; i < els.length; i++) {
|
||||||
var e = el.parentElement.elements[i]
|
var e = els[i]
|
||||||
if (e.name) {
|
if (e.getAttribute("data-convoy") == convoy) {
|
||||||
data[e.name] = e.value
|
e.remove()
|
||||||
if (e.name == "convoy") {
|
|
||||||
convoy = e.value
|
|
||||||
} else if (e.name == "wherefore") {
|
|
||||||
wherefore = e.value
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
post("/zonkit", encode(data))
|
}
|
||||||
if (wherefore == "this convoy") {
|
function zonkit(el, xid) {
|
||||||
var els = document.querySelectorAll('article.honk')
|
el.innerHTML = "zonked"
|
||||||
for (var i = 0; i < els.length; i++) {
|
el.disabled = true
|
||||||
var e = els[i]
|
post("/zonkit", "CSRF={{ $BonkCSRF }}&wherefore=this+honk&honk=" + escape(xid))
|
||||||
if (e.getAttribute("data-convoy") == convoy) {
|
var p = el
|
||||||
e.remove()
|
while (p && p.tagName != "ARTICLE") {
|
||||||
}
|
p = p.parentElement
|
||||||
}
|
}
|
||||||
} else if (wherefore == "this honk") {
|
if (p) {
|
||||||
var p = el
|
p.remove()
|
||||||
while (p && p.tagName != "ARTICLE") {
|
|
||||||
p = p.parentElement
|
|
||||||
}
|
|
||||||
if (p) {
|
|
||||||
p.remove()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue