]> git.scottworley.com Git - voter/blobdiff - src/main.rs
Update vote counts to reflect local votes
[voter] / 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)
                 }