Vote page: 1 s Vérification spinner while a camera app scan is checked; no comma in the via-qr note

This commit is contained in:
2026-11-18 01:30:38 +01:00
parent 28b255e41b
commit 3ebbb67817
2 changed files with 21 additions and 6 deletions
+4 -1
View File
@@ -66,8 +66,11 @@ dialog .actions button { flex: 1; }
@keyframes cel-out { to { opacity: 0; } } @keyframes cel-out { to { opacity: 0; } }
@keyframes cel-pop { from { transform: scale(.6) rotate(-40deg); opacity: 0; } } @keyframes cel-pop { from { transform: scale(.6) rotate(-40deg); opacity: 0; } }
@keyframes cel-tick { to { stroke-dashoffset: 0; } } @keyframes cel-tick { to { stroke-dashoffset: 0; } }
.celebrate.verifying svg { animation: cel-spin 1s linear infinite; }
.celebrate.verifying p { animation-delay: 0s; }
@keyframes cel-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { @media (prefers-reduced-motion: reduce) {
.celebrate, .celebrate svg, .celebrate p, .celebrate small { animation: none; } .celebrate, .celebrate svg, .celebrate p, .celebrate small, .celebrate.verifying svg { animation: none; }
.celebrate .tick { animation: none; stroke-dashoffset: 0; } .celebrate .tick { animation: none; stroke-dashoffset: 0; }
} }
+17 -5
View File
@@ -7,7 +7,7 @@ const apiBase = `/api/v/${pid}`;
const PENDING_KEY = `rv_pending_${pid}`; const PENDING_KEY = `rv_pending_${pid}`;
const ARRIVED_KEY = `rv_arrived_${pid}`; const ARRIVED_KEY = `rv_arrived_${pid}`;
const VIA_QR = "Avec la caméra native, via le QR"; const VIA_QR = "Avec la caméra native via le QR";
// the camera app redirect leaves a one-time claim (or why there is none) in the hash. off the url bar at once // the camera app redirect leaves a one-time claim (or why there is none) in the hash. off the url bar at once
const hash = new URLSearchParams(location.hash.slice(1)); const hash = new URLSearchParams(location.hash.slice(1));
@@ -386,7 +386,7 @@ function enrolled(viaCam = false) {
// the projector's center mark with its check, drawn in, held a moment, then gone // the projector's center mark with its check, drawn in, held a moment, then gone
const MARK_NS = "http://www.w3.org/2000/svg"; const MARK_NS = "http://www.w3.org/2000/svg";
function celebrate(text, sub = "") { function mark(withTick) {
const svg = document.createElementNS(MARK_NS, "svg"); const svg = document.createElementNS(MARK_NS, "svg");
svg.setAttribute("viewBox", "0 0 32 32"); svg.setAttribute("viewBox", "0 0 32 32");
svg.setAttribute("aria-hidden", "true"); svg.setAttribute("aria-hidden", "true");
@@ -401,8 +401,13 @@ function celebrate(text, sub = "") {
const tick = document.createElementNS(MARK_NS, "path"); const tick = document.createElementNS(MARK_NS, "path");
for (const [k, v] of Object.entries({ d: "M12.8 16.15l2.3 2.3 4.25-4.75", fill: "none", stroke: "currentColor", "stroke-width": 2.4, for (const [k, v] of Object.entries({ d: "M12.8 16.15l2.3 2.3 4.25-4.75", fill: "none", stroke: "currentColor", "stroke-width": 2.4,
"stroke-linecap": "round", "stroke-linejoin": "round", pathLength: 1, class: "tick" })) tick.setAttribute(k, v); "stroke-linecap": "round", "stroke-linejoin": "round", pathLength: 1, class: "tick" })) tick.setAttribute(k, v);
svg.append(g, tick); svg.append(g);
const el = h("div", { class: "celebrate", role: "status" }, svg, h("p", {}, text), sub ? h("small", {}, sub) : ""); if (withTick) svg.append(tick);
return svg;
}
function celebrate(text, sub = "") {
const el = h("div", { class: "celebrate", role: "status" }, mark(true), h("p", {}, text), sub ? h("small", {}, sub) : "");
document.body.append(el); document.body.append(el);
// a second line takes longer to read // a second line takes longer to read
const hold = sub ? 2000 : 1300; const hold = sub ? 2000 : 1300;
@@ -688,7 +693,14 @@ async function start() {
await boot(); await boot();
// the scan that brings someone here only opens the page: joining takes the ring, or a second scan // the scan that brings someone here only opens the page: joining takes the ring, or a second scan
const arrived = +lsGet(ARRIVED_KEY) > Date.now() - 3 * 3600e3; const arrived = +lsGet(ARRIVED_KEY) > Date.now() - 3 * 3600e3;
if (claim && (lastState || arrived)) afterPass(await redeem({ claim })); if (claim && (lastState || arrived)) {
// the check takes a few ms: held a second so people see their scan was taken and checked
const wait = h("div", { class: "celebrate verifying", role: "status" }, mark(false), h("p", {}, "Vérification"));
document.body.append(wait);
const [r] = await Promise.all([redeem({ claim }), new Promise((res) => setTimeout(res, 1000))]);
wait.remove();
afterPass(r);
}
else if (camExpired) afterPass({ status: "expired" }); else if (camExpired) afterPass({ status: "expired" });
if (!lastState) lsSet(ARRIVED_KEY, String(Date.now())); if (!lastState) lsSet(ARRIVED_KEY, String(Date.now()));
} }