]> git.scottworley.com Git - voter/commitdiff
Update vote counts to reflect local votes
authorScott Worley <scottworley@scottworley.com>
Sat, 19 Nov 2022 11:11:41 +0000 (03:11 -0800)
committerScott Worley <scottworley@scottworley.com>
Sat, 19 Nov 2022 11:11:41 +0000 (03:11 -0800)
src/main.rs

index a12f73a9c18328fd1d8742e8a0823754dd67a618..528a2301c04a44ba486551cb4e5568ff3e117075 100644 (file)
@@ -130,6 +130,9 @@ const HTML_HEADER: &str = "<!DOCTYPE html>
                 cb.parentElement.removeChild(cb.previousElementSibling)
                 if (req.status == 200) {
                     cb.style.display = ''
+                    const delta = cb.checked ? 1 : -1
+                    const count_td = cb.parentElement.previousElementSibling
+                    count_td.textContent = parseInt(count_td.textContent) + delta
                 } else {
                    cb.parentElement.insertBefore(document.createTextNode('❗'), cb)
                 }