Hand-added votes per question (paper, show of hands): counted in the turnout and shown hatched orange at the end of each result bar, kept apart from phone ballots
This commit is contained in:
+18
-9
@@ -1,4 +1,4 @@
|
||||
import { $, h, pollId, takeKey, liveSocket, drawQR, resultsView, fill, pct } from "./common.js";
|
||||
import { $, h, pollId, takeKey, liveSocket, drawQR, resultsView, pct } from "./common.js";
|
||||
import { render as drawRing, DISC } from "./ringcode.js";
|
||||
|
||||
const pid = pollId();
|
||||
@@ -80,13 +80,10 @@ function render() {
|
||||
|
||||
const f = st.focus;
|
||||
const box = $("#focus");
|
||||
const view = f ? `${f.id}|${f.state}|${f.results ? 1 : 0}|${f.text}` : "";
|
||||
const view = f ? `${f.id}|${f.state}|${f.results ? JSON.stringify(f.results) : 0}|${f.text}` : "";
|
||||
if (f && view === focusView && f.state === "open") {
|
||||
// same question still open: only the turnout moves, in place so the bar slides
|
||||
const t = box.querySelector(".turnout");
|
||||
t.querySelector("b").textContent = f.participants;
|
||||
t.querySelector(".t-of").textContent = ` vote${f.participants > 1 ? "s" : ""} sur ${st.voters}`;
|
||||
t.querySelector(".progress > div").style.width = `${pct(f.participants, st.voters)}%`;
|
||||
paintTurnout(box.querySelector(".turnout"), f);
|
||||
} else if (view !== focusView) {
|
||||
focusView = view;
|
||||
if (f) {
|
||||
@@ -95,9 +92,9 @@ function render() {
|
||||
if (f.state === "open") {
|
||||
box.append(
|
||||
h("ul", { class: "opts" }, f.options.map((o) => h("li", {}, o))),
|
||||
h("div", { class: "turnout" },
|
||||
h("b", {}, f.participants), h("span", { class: "t-of" }, ` vote${f.participants > 1 ? "s" : ""} sur ${st.voters}`),
|
||||
h("div", { class: "progress" }, fill(pct(f.participants, st.voters), ""))),
|
||||
paintTurnout(h("div", { class: "turnout" },
|
||||
h("b", {}), h("span", { class: "t-of" }),
|
||||
h("div", { class: "progress" }, h("div", {}), h("div", { class: "p-extra" }))), f),
|
||||
);
|
||||
} else if (f.results) {
|
||||
box.append(resultsView(f));
|
||||
@@ -110,6 +107,18 @@ function render() {
|
||||
layout();
|
||||
}
|
||||
|
||||
// "9 votes sur 10, dont 3 ajoutés": hand-added votes count in, and show hatched at the end of the bar
|
||||
function paintTurnout(t, f) {
|
||||
const extra = f.extra_ballots || 0, all = f.participants + extra, of = st.voters + extra;
|
||||
t.querySelector("b").textContent = all;
|
||||
t.querySelector(".t-of").textContent = ` vote${all > 1 ? "s" : ""} sur ${of}` +
|
||||
(extra ? `, dont ${extra} ajouté${extra > 1 ? "s" : ""}` : "");
|
||||
const [phone, added] = t.querySelectorAll(".progress > div");
|
||||
phone.style.width = `${pct(f.participants, of)}%`;
|
||||
added.style.width = `${pct(extra, of)}%`;
|
||||
return t;
|
||||
}
|
||||
|
||||
function paintQR() {
|
||||
if (!qr || qr.type !== "qr") return;
|
||||
const c = $("#qr");
|
||||
|
||||
Reference in New Issue
Block a user