From 92d192e314e8d0b577e471fae82bcab095f04358 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sat, 15 Jun 2019 18:46:00 -0400 Subject: [PATCH] rework mute and zonk buttons --- views/honk.html | 18 ++++------------- views/honkpage.html | 49 ++++++++++++++++++--------------------------- 2 files changed, 23 insertions(+), 44 deletions(-) diff --git a/views/honk.html b/views/honk.html index 53b8521..7148bb3 100644 --- a/views/honk.html +++ b/views/honk.html @@ -52,21 +52,11 @@ convoy: {{ .Convoy }}

{{ if .Honk.Public }} - + {{ end }} - -

- - - - - - -
+ + +

diff --git a/views/honkpage.html b/views/honkpage.html index b9d4919..f693b1c 100644 --- a/views/honkpage.html +++ b/views/honkpage.html @@ -36,39 +36,28 @@ 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", "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] + if (e.getAttribute("data-convoy") == convoy) { + e.remove() } } - 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() - } - } - } else if (wherefore == "this honk") { - var p = el - while (p && p.tagName != "ARTICLE") { - p = p.parentElement - } - if (p) { - p.remove() - } +} +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 + } + if (p) { + p.remove() } }