Vote page: let the last progress segment fill before moving on
This commit is contained in:
+12
-4
@@ -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 */ } }
|
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) {
|
function renderDots(n) {
|
||||||
const box = $("#dots");
|
const box = $("#dots");
|
||||||
paintRing(box, n, required, 150);
|
paintRing(box, n, required, 150);
|
||||||
@@ -140,7 +144,7 @@ function stopScanner() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onScan(token) {
|
function onScan(token) {
|
||||||
if (sent.has(token)) return;
|
if (landing || sent.has(token)) return;
|
||||||
sent.add(token);
|
sent.add(token);
|
||||||
submitToken(token);
|
submitToken(token);
|
||||||
}
|
}
|
||||||
@@ -169,7 +173,11 @@ function handleScan(r) {
|
|||||||
$("#code").focus();
|
$("#code").focus();
|
||||||
break;
|
break;
|
||||||
case "enrolled":
|
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;
|
break;
|
||||||
case "closed":
|
case "closed":
|
||||||
block("Inscriptions closes.");
|
block("Inscriptions closes.");
|
||||||
@@ -332,11 +340,11 @@ function collectPresence(n) {
|
|||||||
$("#p-msg").textContent = "";
|
$("#p-msg").textContent = "";
|
||||||
dlg.showModal();
|
dlg.showModal();
|
||||||
const sc = makeScanner($("#p-video"), (t) => {
|
const sc = makeScanner($("#p-video"), (t) => {
|
||||||
if (got.includes(t)) return;
|
if (got.length >= n || got.includes(t)) return;
|
||||||
got.push(t);
|
got.push(t);
|
||||||
paint();
|
paint();
|
||||||
navigator.vibrate?.(15);
|
navigator.vibrate?.(15);
|
||||||
if (got.length >= n) finish(got);
|
if (got.length >= n) setTimeout(() => finish(got), FILL_MS);
|
||||||
});
|
});
|
||||||
let done, finished = false;
|
let done, finished = false;
|
||||||
const result = new Promise((res) => { done = res; });
|
const result = new Promise((res) => { done = res; });
|
||||||
|
|||||||
Reference in New Issue
Block a user