Duplicated screen mode: /present shows the projector view with the admin in a drawer (Gérer); both modes offered on the links page and the share tab
This commit is contained in:
@@ -321,3 +321,6 @@ liveSocket(`/ws/${pid}/admin`, {
|
||||
c.textContent = "Reconnexion…";
|
||||
},
|
||||
});
|
||||
|
||||
// duplicated screen: the projector view with this admin in a drawer, same admin key
|
||||
$("#open-present").href = `/present/${pid}#${encodeURIComponent(key)}`;
|
||||
|
||||
@@ -28,6 +28,7 @@ $("#form").addEventListener("submit", async (e) => {
|
||||
$("#screen-link").value = screen;
|
||||
$("#go-admin").href = admin;
|
||||
$("#go-screen").href = screen;
|
||||
$("#go-present").href = `${location.origin}/present/${res.id}#${res.admin_key}`;
|
||||
$("#create").hidden = true;
|
||||
$("#try-link").hidden = true;
|
||||
$("#done").hidden = false;
|
||||
|
||||
+23
-1
@@ -2,7 +2,9 @@ import { $, h, pollId, takeKey, liveSocket, drawQR, resultsView, pct } from "./c
|
||||
import { render as drawRing, DISC } from "./ringcode.js";
|
||||
|
||||
const pid = pollId();
|
||||
const key = takeKey(`rv_screen_${pid}`);
|
||||
// /present/: duplicated screen, the laptop shows what the projector shows. admin key, admin in a drawer
|
||||
const present = location.pathname.startsWith("/present/");
|
||||
const key = takeKey(present ? `rv_present_${pid}` : `rv_screen_${pid}`);
|
||||
let st = null;
|
||||
let qr = null; // current code message, qr or ring
|
||||
let raf = 0;
|
||||
@@ -224,3 +226,23 @@ liveSocket(`/ws/${pid}/screen`, {
|
||||
if (s !== "online") { qr = null; const cv = $("#qr"); cv.getContext("2d").clearRect(0, 0, cv.width, cv.height); }
|
||||
},
|
||||
});
|
||||
|
||||
if (present) {
|
||||
const btn = h("button", { class: "small ctl-btn", type: "button", "aria-expanded": "false" }, "Gérer");
|
||||
const close = h("button", { class: "small", type: "button" }, "Fermer");
|
||||
const drawer = h("aside", { class: "ctl", "aria-label": "Gestion du scrutin" },
|
||||
h("div", { class: "ctl-head" }, h("b", {}, "Gestion"), close));
|
||||
document.body.append(drawer);
|
||||
$(".s-tools").prepend(btn);
|
||||
const toggle = (open) => {
|
||||
// the admin page loads on first open only, and keeps its state when the drawer closes
|
||||
if (open && !drawer.querySelector("iframe")) {
|
||||
drawer.append(h("iframe", { src: `/admin/${pid}#${encodeURIComponent(key)}`, title: "Administration" }));
|
||||
}
|
||||
drawer.classList.toggle("open", open);
|
||||
btn.setAttribute("aria-expanded", String(open));
|
||||
};
|
||||
btn.addEventListener("click", () => toggle(!drawer.classList.contains("open")));
|
||||
close.addEventListener("click", () => toggle(false));
|
||||
document.addEventListener("keydown", (e) => { if (e.key === "Escape") toggle(false); });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user