Camera app scan: the big qr rotates every 3 s and one scan with the phone's camera app enrolls or validates a vote (10 s), for browsers with the camera blocked; qr stays big beside the ring during a vote, step by step help on the phone
This commit is contained in:
+18
-12
@@ -52,10 +52,14 @@ function layout() {
|
||||
// qr stays up while enrolling, and during a vote that needs a presence scan
|
||||
const qrOn = st.enrollment_open || st.presence;
|
||||
const ring = st.code_style === "ring";
|
||||
const entryOn = !!(ring && st.enrollment_open && entry);
|
||||
// a closed vote whose results aren't shown has nothing to say: with the big entry qr on, it steps aside
|
||||
// the camera app code: enrolls, and proves presence for a vote, so it stays up whenever the ring does
|
||||
const entryOn = !!(ring && qrOn && entry);
|
||||
// with the big qr on, a vote waiting for scans (or closed with nothing to show) moves above it
|
||||
const f = st.focus, idleVote = f && f.state === "closed" && !f.results;
|
||||
const focus = idleVote && entryOn && st.entry_big ? null : f;
|
||||
// an upright screen has no room for the question above the qr (.entry-q hidden): it keeps its own block
|
||||
const openVote = f && f.state === "open" && st.presence && !matchMedia("(max-aspect-ratio: 1/1)").matches;
|
||||
const big = entryOn && st.entry_big && (!f || idleVote || openVote);
|
||||
const focus = big ? null : f;
|
||||
reveal($("#enroll"), qrOn);
|
||||
reveal($("#focus"), !!focus);
|
||||
reveal($("#idle"), !qrOn && !focus);
|
||||
@@ -64,22 +68,24 @@ function layout() {
|
||||
// a vote waiting for presence scans takes the title, even while late arrivals can still enroll
|
||||
$("#qr-title").textContent = st.presence || !st.enrollment_open ? (ring ? "Visez le cercle pour voter" : "Scannez pour voter") : "Inscription";
|
||||
$("#qr-steps").hidden = !st.enrollment_open;
|
||||
// rings can't be opened by the camera app, so a small fixed qr leads to the page
|
||||
$("#step1").textContent = ring ? "Ouvrez la page de vote" : "Scannez ce code";
|
||||
$("#step1").textContent = ring ? "Scannez le QR avec l'appareil photo" : "Scannez avec l'appareil photo";
|
||||
$("#step2").hidden = !ring;
|
||||
reveal($("#entry"), entryOn);
|
||||
document.body.classList.toggle("has-entry", entryOn);
|
||||
// big entry qr next to the ring (start of a meeting, between votes), back to the corner while a question is up
|
||||
const big = entryOn && st.entry_big && !focus;
|
||||
document.body.classList.toggle("entry-big", big);
|
||||
// the closed vote it replaced stays readable above the qr: question and ballot count
|
||||
const showQ = big && !!idleVote;
|
||||
const showQ = big && !!f;
|
||||
document.body.classList.toggle("entry-q-on", showQ);
|
||||
$("#entry-q").hidden = !showQ;
|
||||
if (showQ) {
|
||||
$("#entry-q-text").textContent = f.text;
|
||||
$("#entry-q-count").textContent = `Vote clos, ${f.participants} bulletin${f.participants > 1 ? "s" : ""}`;
|
||||
if (openVote) {
|
||||
const all = f.participants + (f.extra_ballots || 0);
|
||||
$("#entry-q-count").textContent = `${all} vote${all > 1 ? "s" : ""} sur ${st.voters + (f.extra_ballots || 0)}`;
|
||||
} else {
|
||||
$("#entry-q-count").textContent = `Vote clos, ${f.participants} bulletin${f.participants > 1 ? "s" : ""}`;
|
||||
}
|
||||
}
|
||||
$("#entry-hint").textContent = big ? "Scannez ici, puis visez le cercle" : "Pas encore sur la page ?";
|
||||
$("#entry-hint").textContent = "Scannez avec l'appareil photo";
|
||||
$(".qr-wrap").classList.toggle("ring", ring);
|
||||
flip(entryEl, before);
|
||||
}
|
||||
@@ -178,7 +184,7 @@ function animateTick() {
|
||||
}
|
||||
|
||||
let skew = 0;
|
||||
window.addEventListener("resize", paintQR);
|
||||
window.addEventListener("resize", () => { paintQR(); layout(); });
|
||||
|
||||
$("#fs").addEventListener("click", () => document.documentElement.requestFullscreen?.());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user