Reopen a closed vote until its results are shown; check mark in the center mark and on the phone; vote title during enrollment; projector opens in a window

This commit is contained in:
2026-08-17 01:52:30 +01:00
parent cd693d1a7c
commit a28971e36d
10 changed files with 87 additions and 7 deletions
+4 -2
View File
@@ -21,6 +21,7 @@ function errMsg(e) {
not_draft: "La question n'est plus en brouillon",
not_open: "La question n'est pas ouverte",
not_closed: "La question n'est pas close",
already_shown: "Résultats déjà publiés, le vote ne peut plus être rouvert",
};
return m[e.code] || e.message;
}
@@ -113,11 +114,12 @@ function questionCard(q) {
actions.push(act("Lancer le vote", "open", "small go"));
actions.push(act("Supprimer", "delete", "small danger", "Supprimer ce brouillon ?"));
} else if (q.state === "open") {
actions.push(act("Clore le vote", "close", "small primary", `Clore le vote (${q.participants} vote${q.participants > 1 ? "s" : ""}) ? Définitif.`));
actions.push(act("Clore le vote", "close", "small primary", `Clore le vote (${q.participants} vote${q.participants > 1 ? "s" : ""}) ?`));
} else {
actions.push(q.results_public
? act("Masquer les résultats", "unpublish")
: act("Publier les résultats", "publish", "small primary"));
: act("Publier les résultats", "publish", "small primary", "Publier les résultats ? Le vote ne pourra plus être rouvert."));
if (!q.shown) actions.push(act("Rouvrir le vote", "reopen"));
}
if (q.state !== "draft" && !focused) actions.push(act([icon("screen", 15), "Afficher à l'écran"], "focus"));
+7
View File
@@ -43,3 +43,10 @@ for (const [btn, input] of [["#copy-admin", "#admin-link"], ["#copy-screen", "#s
catch { $(input).select(); }
});
}
// a real window, not a tab: it can be dragged onto the projected display and put full screen there
$("#go-screen").addEventListener("click", (e) => {
const w = window.open($("#go-screen").href, "_blank", "popup,width=1280,height=720");
// blocked popup: the plain link still opens a tab
if (w) { w.opener = null; e.preventDefault(); }
});
+5
View File
@@ -163,6 +163,11 @@ function logo(ctx, cx, cy, r) {
ctx.strokeStyle = j === 0 ? "#ffcc00" : "#ffffff";
ctx.beginPath(); ctx.arc(cx, cy, rr, a, a + dash); ctx.stroke();
}
// check mark inside, same one the phone shows once its scans count
ctx.strokeStyle = "#ffffff";
ctx.lineWidth = 2.4 * u;
ctx.lineJoin = "round";
ctx.beginPath(); ctx.moveTo(cx - 3.2 * u, cy + 0.15 * u); ctx.lineTo(cx - 0.9 * u, cy + 2.45 * u); ctx.lineTo(cx + 3.35 * u, cy - 2.3 * u); ctx.stroke();
}
const EASE = {
+2 -1
View File
@@ -40,7 +40,8 @@ function layout() {
reveal($("#idle"), !qrOn && !focus);
$(".s-main").classList.toggle("split", qrOn && !!focus);
const ring = st.code_style === "ring";
$("#qr-title").textContent = st.enrollment_open ? "Inscription" : ring ? "Visez le cercle pour voter" : "Scannez pour voter";
// 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";
+26 -1
View File
@@ -192,9 +192,34 @@ function enrolled() {
stopScanner();
lsSet(DONE_KEY, "1");
navigator.vibrate?.([40, 60, 40]);
celebrate("Inscription validée");
boot();
}
// 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) {
const svg = document.createElementNS(MARK_NS, "svg");
svg.setAttribute("viewBox", "0 0 32 32");
svg.setAttribute("aria-hidden", "true");
const g = document.createElementNS(MARK_NS, "g");
g.setAttribute("transform", "rotate(-90 16 16)");
for (const [stroke, dash] of [["currentColor", "4.52 7"], ["#ffcc00", "4.52 64.6"]]) {
const c = document.createElementNS(MARK_NS, "circle");
for (const [k, v] of Object.entries({ cx: 16, cy: 16, r: 11, fill: "none", stroke, "stroke-width": 5,
"stroke-linecap": "round", "stroke-dasharray": dash, "stroke-dashoffset": -3.5 })) c.setAttribute(k, v);
g.append(c);
}
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));
document.body.append(el);
setTimeout(() => el.classList.add("out"), 1300);
setTimeout(() => el.remove(), 1700);
}
$("#start-cam").addEventListener("click", startScanner);
$("#no-cam").addEventListener("click", () => { stopScanner(); show("#v-rescue"); $("#rescue-code").focus(); });
@@ -321,7 +346,7 @@ async function confirmVote(q) {
try {
await api("POST", `${apiBase}/vote`, { question_id: q.id, choices: s.blank ? [] : choices, presence });
selections.delete(q.id);
toast("Vote enregistré", "ok");
celebrate("Vote enregistré");
navigator.vibrate?.(60);
} catch (e) {
const m = { already_voted: "Déjà voté.", not_open: "Vote clos.", not_enrolled: "Appareil non inscrit.",