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
+19
View File
@@ -50,3 +50,22 @@ dialog[open] { animation: rise .2s ease-out; }
#confirm-choices { list-style: none; padding: 0; margin: 0 0 8px; }
#confirm-choices li { font: 700 1.2rem var(--round); background: var(--mark); border-radius: 12px; padding: 10px 14px; margin: 6px 0; }
dialog .actions button { flex: 1; }
/* confirmation after enrolling or voting: the projector's mark, its check drawing in */
.celebrate {
position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 18px;
background: color-mix(in srgb, var(--bg) 92%, transparent); color: var(--ink);
animation: cel-in .3s ease both;
}
.celebrate svg { width: 132px; height: 132px; animation: cel-pop .5s cubic-bezier(.2, .9, .3, 1.25) both; }
.celebrate .tick { stroke-dasharray: 1; stroke-dashoffset: 1; animation: cel-tick .45s .25s cubic-bezier(.3, .7, .2, 1) forwards; }
.celebrate p { margin: 0; font: 700 1.3rem var(--round); animation: cel-in .4s .35s ease both; }
.celebrate.out { animation: cel-out .4s ease forwards; }
@keyframes cel-in { from { opacity: 0; } }
@keyframes cel-out { to { opacity: 0; } }
@keyframes cel-pop { from { transform: scale(.6) rotate(-40deg); opacity: 0; } }
@keyframes cel-tick { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
.celebrate, .celebrate svg, .celebrate p { animation: none; }
.celebrate .tick { animation: none; stroke-dashoffset: 0; }
}
+1 -1
View File
@@ -74,7 +74,7 @@
<div class="pane">
<div class="pane-head"><svg class="icon" viewBox="0 0 24 24" width="26" height="26" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 5h16v11H4z"/><path d="M2 19.5h20"/><path d="M8 9h8"/><path d="M8 12.5h5"/></svg><p><b>Administration</b><span>Sur votre écran</span></p></div>
<div class="linkbox"><input id="admin-link" type="text" readonly aria-label="Lien d'administration"><button id="copy-admin" class="small" type="button">Copier</button></div>
<a id="go-admin" class="btn primary block" href="#">Ouvrir l'administration</a>
<a id="go-admin" class="btn primary block" href="#" target="_blank" rel="noopener">Ouvrir l'administration</a>
</div>
<div class="pane">
<div class="pane-head"><svg class="icon" viewBox="0 0 24 24" width="26" height="26" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 4h20"/><path d="M4 4v10h16V4"/><path d="M12 14v3"/><path d="M8.5 21l3.5-4 3.5 4"/></svg><p><b>Projecteur</b><span>Affiché à la salle, à ouvrir sur l'écran projeté</span></p></div>
+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.",