Camera app scan: the first scan only opens the page, joining takes the ring or a second scan read within 4 s of the qr leaving the screen (votes keep 12 s); organizers can turn it off; open vote options and turnout bar stay above the big qr; native scan noted under the check
This commit is contained in:
+15
-7
@@ -53,11 +53,12 @@ function layout() {
|
||||
const qrOn = st.enrollment_open || st.presence;
|
||||
const ring = st.code_style === "ring";
|
||||
// the camera app code: enrolls, and proves presence for a vote, so it stays up whenever the ring does
|
||||
const entryOn = !!(ring && qrOn && entry);
|
||||
const cam = st.camera_pass !== false;
|
||||
const entryOn = !!(ring && entry && (st.enrollment_open || (cam && st.presence)));
|
||||
// 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;
|
||||
// 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 openVote = cam && 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);
|
||||
@@ -68,7 +69,7 @@ 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;
|
||||
$("#step1").textContent = ring ? "Scannez le QR avec l'appareil photo" : "Scannez avec l'appareil photo";
|
||||
$("#step1").textContent = ring ? (cam ? "Scannez le QR avec l'appareil photo" : "Ouvrez la page de vote") : "Scannez avec l'appareil photo";
|
||||
$("#step2").hidden = !ring;
|
||||
reveal($("#entry"), entryOn);
|
||||
document.body.classList.toggle("has-entry", entryOn);
|
||||
@@ -76,16 +77,23 @@ function layout() {
|
||||
const showQ = big && !!f;
|
||||
document.body.classList.toggle("entry-q-on", showQ);
|
||||
$("#entry-q").hidden = !showQ;
|
||||
// an open vote keeps its options and turnout bar on screen, just above the qr
|
||||
const opts = showQ && !!openVote;
|
||||
document.body.classList.toggle("entry-opts-on", opts);
|
||||
$("#entry-q-opts").hidden = !opts;
|
||||
$("#entry-q-turnout").hidden = !opts;
|
||||
$("#entry-q-count").hidden = opts;
|
||||
if (showQ) {
|
||||
$("#entry-q-text").textContent = f.text;
|
||||
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)}`;
|
||||
if (opts) {
|
||||
const ul = $("#entry-q-opts"), key = JSON.stringify(f.options);
|
||||
if (ul.dataset.key !== key) { ul.dataset.key = key; ul.replaceChildren(...f.options.map((o) => h("li", {}, o))); }
|
||||
paintTurnout($("#entry-q-turnout"), f);
|
||||
} else {
|
||||
$("#entry-q-count").textContent = `Vote clos, ${f.participants} bulletin${f.participants > 1 ? "s" : ""}`;
|
||||
}
|
||||
}
|
||||
$("#entry-hint").textContent = "Scannez avec l'appareil photo";
|
||||
$("#entry-hint").textContent = cam ? "Scannez avec l'appareil photo" : big ? "Scannez ici, puis visez le cercle" : "Pas encore sur la page ?";
|
||||
$(".qr-wrap").classList.toggle("ring", ring);
|
||||
flip(entryEl, before);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user