Vote page: let the last progress segment fill before moving on

This commit is contained in:
2026-11-16 23:43:48 +01:00
parent 1d341cf32a
commit d4902da7c2
+12 -4
View File
@@ -34,6 +34,10 @@ function lsGet(k) { try { return localStorage.getItem(k); } catch { return null;
function lsSet(k, v) { try { localStorage.setItem(k, v); } catch { /* private mode */ } }
// the segment fill in app.css takes .5 s, plus a beat to see the ring complete
const FILL_MS = 650;
let landing = false;
function renderDots(n) {
const box = $("#dots");
paintRing(box, n, required, 150);
@@ -140,7 +144,7 @@ function stopScanner() {
}
function onScan(token) {
if (sent.has(token)) return;
if (landing || sent.has(token)) return;
sent.add(token);
submitToken(token);
}
@@ -169,7 +173,11 @@ function handleScan(r) {
$("#code").focus();
break;
case "enrolled":
enrolled();
// the 5th code answers "enrolled" straight away: fill the last segment and let it land first
if (landing) break;
landing = true;
renderDots(required);
setTimeout(() => { landing = false; enrolled(); }, FILL_MS);
break;
case "closed":
block("Inscriptions closes.");
@@ -332,11 +340,11 @@ function collectPresence(n) {
$("#p-msg").textContent = "";
dlg.showModal();
const sc = makeScanner($("#p-video"), (t) => {
if (got.includes(t)) return;
if (got.length >= n || got.includes(t)) return;
got.push(t);
paint();
navigator.vibrate?.(15);
if (got.length >= n) finish(got);
if (got.length >= n) setTimeout(() => finish(got), FILL_MS);
});
let done, finished = false;
const result = new Promise((res) => { done = res; });