Results share link: read-only /r page with a revocable key, the admin ticks which closed questions it shows (sharing locks reopen like publish), refreshes every 15 s
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { $, h, api, pollId, hashKey, resultsView } from "./common.js";
|
||||
|
||||
const pid = pollId();
|
||||
// the key stays in the address bar so the link can be passed on as is
|
||||
const key = hashKey();
|
||||
|
||||
async function load() {
|
||||
let data;
|
||||
try { data = await api("GET", `/api/r/${pid}`, undefined, key); }
|
||||
catch {
|
||||
$("#denied").hidden = false;
|
||||
$("#list").replaceChildren();
|
||||
return;
|
||||
}
|
||||
$("#denied").hidden = true;
|
||||
$("#title").textContent = data.title;
|
||||
document.title = `Résultats · ${data.title}`;
|
||||
const qs = data.questions.sort((a, b) => a.id - b.id);
|
||||
$("#list").replaceChildren(...(qs.length
|
||||
? qs.map((q) => h("article", { class: "q" }, h("div", { class: "q-text" }, q.text), resultsView(q)))
|
||||
: [h("p", { class: "muted" }, "Aucun résultat pour l'instant.")]));
|
||||
}
|
||||
|
||||
load();
|
||||
// questions get added as the meeting goes on
|
||||
setInterval(() => { if (!document.hidden) load(); }, 15000);
|
||||
document.addEventListener("visibilitychange", () => { if (!document.hidden) load(); });
|
||||
Reference in New Issue
Block a user