X-Git-Url: http://git.scottworley.com/voter/blobdiff_plain/9543206967816cd9427588a2c29468fff133a65e..f724d95fdf704f2480581d7de85f0198a5c049e8:/src/main.rs?ds=inline 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