when zonking a convoy, remove it from the page

This commit is contained in:
Ted Unangst 2019-05-28 20:57:55 -04:00
parent 1a88b3dbc9
commit 6e9a2308a0
2 changed files with 16 additions and 1 deletions

View File

@ -1,4 +1,4 @@
<article class="honk {{ .Honk.What }} {{ and (not .Honk.Public) "limited" }}"> <article class="honk {{ .Honk.What }} {{ and (not .Honk.Public) "limited" }}" data-convoy="{{ .Honk.Convoy }}">
{{ with .Honk }} {{ with .Honk }}
<header> <header>
<img alt="avatar" src="/a?a={{ .Honker}}"> <img alt="avatar" src="/a?a={{ .Honker}}">

View File

@ -40,13 +40,28 @@ function zonkit(el) {
el.innerHTML = "zonked" el.innerHTML = "zonked"
el.disabled = true el.disabled = true
var data = { } var data = { }
var convoy, wherefore
for (var i in el.parentElement.elements) { for (var i in el.parentElement.elements) {
var e = el.parentElement.elements[i] var e = el.parentElement.elements[i]
if (e.name) { if (e.name) {
data[e.name] = e.value data[e.name] = e.value
if (e.name == "convoy") {
convoy = e.value
} else if (e.name == "wherefore") {
wherefore = e.value
}
} }
} }
post("/zonkit", encode(data)) 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()
}
}
}
} }
</script> </script>
{{ end }} {{ end }}