From 3ebbb67817e0a46cd3140cf03111c3147ee39776 Mon Sep 17 00:00:00 2001 From: Showdown76py Date: Wed, 18 Nov 2026 01:30:38 +0100 Subject: [PATCH] =?UTF-8?q?Vote=20page:=201=20s=20V=C3=A9rification=20spin?= =?UTF-8?q?ner=20while=20a=20camera=20app=20scan=20is=20checked;=20no=20co?= =?UTF-8?q?mma=20in=20the=20via-qr=20note?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/css/vote.css | 5 ++++- static/js/vote.js | 22 +++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/static/css/vote.css b/static/css/vote.css index 1b3a50a..202c486 100644 --- a/static/css/vote.css +++ b/static/css/vote.css @@ -66,8 +66,11 @@ dialog .actions button { flex: 1; } @keyframes cel-out { to { opacity: 0; } } @keyframes cel-pop { from { transform: scale(.6) rotate(-40deg); opacity: 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) { - .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; } } diff --git a/static/js/vote.js b/static/js/vote.js index a9e1c86..86aaa41 100644 --- a/static/js/vote.js +++ b/static/js/vote.js @@ -7,7 +7,7 @@ const apiBase = `/api/v/${pid}`; const PENDING_KEY = `rv_pending_${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 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 const MARK_NS = "http://www.w3.org/2000/svg"; -function celebrate(text, sub = "") { +function mark(withTick) { const svg = document.createElementNS(MARK_NS, "svg"); svg.setAttribute("viewBox", "0 0 32 32"); svg.setAttribute("aria-hidden", "true"); @@ -401,8 +401,13 @@ function celebrate(text, sub = "") { 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, "stroke-linecap": "round", "stroke-linejoin": "round", pathLength: 1, class: "tick" })) tick.setAttribute(k, v); - svg.append(g, tick); - const el = h("div", { class: "celebrate", role: "status" }, svg, h("p", {}, text), sub ? h("small", {}, sub) : ""); + svg.append(g); + 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); // a second line takes longer to read const hold = sub ? 2000 : 1300; @@ -688,7 +693,14 @@ async function start() { await boot(); // 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; - 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" }); if (!lastState) lsSet(ARRIVED_KEY, String(Date.now())); }