when zonking a convoy, remove it from the page
Ted Unangst tedu@tedunangst.com
Tue, 28 May 2019 20:57:55 -0400
2 files changed,
16 insertions(+),
1 deletions(-)
M
views/honk.html
→
views/honk.html
@@ -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 }} <header> <img alt="avatar" src="/a?a={{ .Honker}}">
M
views/honkpage.html
→
views/honkpage.html
@@ -40,13 +40,28 @@ function zonkit(el) {
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", 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> {{ end }}