From f724d95fdf704f2480581d7de85f0198a5c049e8 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sat, 19 Nov 2022 01:29:43 -0800 Subject: [PATCH 1/1] Send votes --- src/main.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main.rs b/src/main.rs index 5c4ad90..920384e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -97,6 +97,18 @@ const HTML_HEADER: &str = " const spin = document.createElement('div') spin.appendChild(document.createTextNode('⏳')) cb.parentElement.insertBefore(spin, cb) + + const req = new XMLHttpRequest() + req.addEventListener('load', function(e) { + cb.parentElement.removeChild(cb.previousElementSibling) + if (req.status == 200) { + cb.style.display = '' + } else { + cb.parentElement.insertBefore(document.createTextNode('❗'), cb) + } + }) + req.open('PUT', window.location.href) + req.send((cb.checked ? 1 : 0) + ' ' + cb.parentElement.nextSibling.innerHTML) } })(cb)) cb.disabled = false -- 2.44.1