Zusammenführen: neu-puls (Rudel-Puls, Nochmal!)
Co-Authored-By: Claude Opus 5.5 <[email protected]> # Conflicts: # server/pruef-reaktion.mjs # server/workspace-reaktion.js
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
/* =====================================================================
|
||||
DER RUDEL-PULS IM NACHBERICHT (04.11.2026, Neuplan M1.5)
|
||||
|
||||
Eine zusätzliche Kurve: Reaktionen und Chat-Beiträge je Sekunde über
|
||||
die ganze Sendung, mit den Momenten als Marken. Nur, wenn es für diese
|
||||
Sendung einen Puls gibt (aufgezeichnet wird seit dem 04.11.2026).
|
||||
|
||||
Die Regie bekommt die Zahlen, alle anderen nur die Form (Stufen 0–10)
|
||||
– das entscheidet der Server (/workspace/api/reaktion/puls/verlauf),
|
||||
diese Seite blendet nichts „aus“, was sie gar nicht bekommen hat.
|
||||
|
||||
Hört auf `nb:geladen` (nachbericht.js) und baut ihren Abschnitt selbst;
|
||||
`window.__nbPuls` trägt den Stand für die Prüfung.
|
||||
===================================================================== */
|
||||
(() => {
|
||||
'use strict';
|
||||
const $ = (id) => document.getElementById(id);
|
||||
const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e; };
|
||||
const svgEl = (tag, attr) => { const e = document.createElementNS('http://www.w3.org/2000/svg', tag); for (const [k, v] of Object.entries(attr)) e.setAttribute(k, v); return e; };
|
||||
const mmss = (s) => (s >= 3600 ? `${Math.floor(s / 3600)}:${String(Math.floor((s % 3600) / 60)).padStart(2, '0')} h` : `${Math.floor(s / 60)}:${String(Math.floor(s % 60)).padStart(2, '0')} min`);
|
||||
let folge = 0;
|
||||
|
||||
function bauen() {
|
||||
if ($('nb-puls')) return $('nb-puls');
|
||||
const nach = $('nb-technik') || $('nb-verlauf');
|
||||
if (!nach) return null;
|
||||
const teil = el('section', 'nb__puls');
|
||||
teil.id = 'nb-puls';
|
||||
teil.hidden = true;
|
||||
teil.setAttribute('aria-labelledby', 'nb-puls-titel');
|
||||
const h = el('h2', '', 'Rudel-Puls');
|
||||
h.id = 'nb-puls-titel';
|
||||
const legende = el('p', 'nb__legende');
|
||||
legende.append(el('span', 'nb__l nb__l--puls', 'Reaktionen + Chat je Sekunde'), ' ', el('span', 'nb__l nb__l--moment', 'Momente'));
|
||||
const svg = svgEl('svg', { class: 'nb__pulskurve', id: 'nb-pulskurve', viewBox: '0 0 800 90', preserveAspectRatio: 'none', role: 'img', 'aria-label': 'Rudel-Puls' });
|
||||
const text = el('p', 'nb__hinweis', '');
|
||||
text.id = 'nb-puls-text';
|
||||
teil.append(h, legende, svg, text);
|
||||
nach.after(teil);
|
||||
return teil;
|
||||
}
|
||||
|
||||
async function laden(j) {
|
||||
const meine = ++folge;
|
||||
const teil = bauen();
|
||||
if (!teil) return;
|
||||
teil.hidden = true;
|
||||
window.__nbPuls = null;
|
||||
if (!j?.da || !j.sendung?.id) return;
|
||||
let p = null;
|
||||
try {
|
||||
const a = await fetch(`/workspace/api/reaktion/puls/verlauf?id=${encodeURIComponent(j.sendung.id)}`, { credentials: 'same-origin', cache: 'no-store' });
|
||||
p = await a.json().catch(() => null);
|
||||
if (!a.ok) p = null;
|
||||
} catch { p = null; }
|
||||
if (meine !== folge) return;
|
||||
window.__nbPuls = p;
|
||||
if (!p?.da) return;
|
||||
zeichnen(p, j);
|
||||
teil.hidden = false;
|
||||
}
|
||||
|
||||
function zeichnen(p, j) {
|
||||
const svg = $('nb-pulskurve');
|
||||
svg.textContent = '';
|
||||
const reihe = p.regie ? p.werte : p.stufen;
|
||||
const n = reihe.length;
|
||||
const B = 800, H = 90, P = 6;
|
||||
/* Höchstens 400 Säulen: Je Säule die SPITZE ihres Abschnitts – ein
|
||||
Mittelwert würde einen kurzen Ausbruch glattbügeln, und genau den
|
||||
sucht man hier. */
|
||||
const stuecke = Math.min(400, n);
|
||||
const je = n / stuecke;
|
||||
const spitzen = [];
|
||||
for (let i = 0; i < stuecke; i++) {
|
||||
let m = 0;
|
||||
for (let k = Math.floor(i * je); k < Math.max(Math.floor(i * je) + 1, Math.floor((i + 1) * je)); k++) m = Math.max(m, reihe[k] || 0);
|
||||
spitzen.push(m);
|
||||
}
|
||||
const max = spitzen.reduce((a, v) => (v > a ? v : a), 0) || 1;
|
||||
const x = (i) => P + (i / Math.max(1, stuecke - 1)) * (B - 2 * P);
|
||||
const y = (v) => H - P - (v / max) * (H - 2 * P);
|
||||
const punkte = spitzen.map((v, i) => `${x(i).toFixed(1)},${y(v).toFixed(1)}`);
|
||||
svg.append(svgEl('path', { d: `M${x(0)},${H - P} L${punkte.join(' L')} L${x(stuecke - 1)},${H - P} Z`, class: 'nb__pulsflaeche' }));
|
||||
svg.append(svgEl('polyline', { points: punkte.join(' '), class: 'nb__pulslinie', fill: 'none' }));
|
||||
const start = Date.parse(j.sendung.begonnen || '') || null;
|
||||
const momente = (j.momente || []).filter((m) => m.zeit);
|
||||
if (start) {
|
||||
for (const m of momente) {
|
||||
const s = (Date.parse(m.zeit) - start) / 1000;
|
||||
if (!(s >= 0 && s <= n)) continue;
|
||||
const mx = Math.min(B - P, Math.max(P, P + (s / Math.max(1, n)) * (B - 2 * P)));
|
||||
svg.append(svgEl('line', { x1: mx, x2: mx, y1: P, y2: H - P, class: `nb__marke nb__marke--${m.art || 'markiert'}` }));
|
||||
}
|
||||
}
|
||||
/* Wo war am meisten los? Die Stelle in Minuten nach dem Start. */
|
||||
let spitzeBei = 0;
|
||||
reihe.forEach((v, i) => { if (v > reihe[spitzeBei]) spitzeBei = i; });
|
||||
const satz = p.regie
|
||||
? `Am meisten los nach ${mmss(spitzeBei)}: ${p.max} Reaktionen und Beiträge in einer Sekunde.`
|
||||
: `Am meisten los nach ${mmss(spitzeBei)}.`;
|
||||
$('nb-puls-text').textContent = satz;
|
||||
svg.setAttribute('aria-label', `Rudel-Puls über ${mmss(n)}. ${satz}${momente.length ? ` ${momente.length} Momente.` : ''}`);
|
||||
}
|
||||
|
||||
window.addEventListener('nb:geladen', (e) => { laden(e.detail); });
|
||||
})();
|
||||
@@ -33,6 +33,8 @@
|
||||
if (!a.ok || !j) { $('nb-unter').textContent = 'Der Nachbericht ging gerade nicht.'; return; }
|
||||
window.__nb = j;
|
||||
zeichnen(j);
|
||||
/* Für Zusätze wie den Rudel-Puls (nachbericht-puls.js). */
|
||||
window.dispatchEvent(new CustomEvent('nb:geladen', { detail: j }));
|
||||
}
|
||||
|
||||
function zeichnen(j) {
|
||||
|
||||
@@ -7159,9 +7159,12 @@
|
||||
beim nächsten Zweig vergessen wird. Dass dabei auch
|
||||
Rundrufe mitzählen, die `lage` gar nicht anfassen, ist
|
||||
die sichere Richtung: Im Zweifel behält die Seite, was
|
||||
sie über den Strom weiß. */
|
||||
standFolge++;
|
||||
sie über den Strom weiß.
|
||||
AUSSER PULS UND NOCHMAL (04.11.2026, rudelpuls.js): reine
|
||||
Anzeige, im Zwei-Sekunden-Takt – sie tragen keinen Stand und
|
||||
dürfen den Takt der Seite nicht laufend verwerfen. */
|
||||
const d = JSON.parse(e.data);
|
||||
if (d.was !== 'puls' && d.was !== 'nochmal') standFolge++;
|
||||
window.dispatchEvent(new CustomEvent('saal:strom', { detail: d }));
|
||||
if (d.was === 'video') {
|
||||
/* WER STEUERT, FOLGT SEINEM EIGENEN ECHO NICHT (29.09.2026).
|
||||
|
||||
@@ -0,0 +1,321 @@
|
||||
/* =====================================================================
|
||||
DAS RUDEL SPIELT MIT: RUDEL-PULS UND „NOCHMAL!“ (04.11.2026)
|
||||
Neuplan M1.5 und M3. Server: workspace-puls.js, workspace-nochmal.js.
|
||||
|
||||
DER PULS ist eine flache Welle am unteren Rand der Saalleiste (der
|
||||
Kopfleiste oben) – über die ganze Breite und NIE auf dem YouTube-Bild.
|
||||
Sie zeigt Reaktionen und Chat-Beiträge je Sekunde der letzten Minute,
|
||||
gleitend gemittelt. Bewegt wird nur `transform` (jeder Balken skaliert
|
||||
in der Höhe); bei „weniger Bewegung“ springen die Balken ohne
|
||||
Übergang. Die Zahlen kommen gebündelt alle zwei Sekunden über den
|
||||
vorhandenen Strom (`saal:strom`, was: "puls"); ist der Saal still,
|
||||
kommt nichts, und die Welle klingt hier von selbst ab.
|
||||
|
||||
„NOCHMAL!“ ist ein kleiner Knopf im Kopf des Live-Chats – nur für
|
||||
Zuschauer, nur bei Reaction (beim Zocken gibt es kein Video zum
|
||||
Zurücksetzen). Eine Bitte je Person und Minute. Die Regie bekommt ab
|
||||
der Schwelle (mindestens 10 Leute UND die Hälfte des Saals) EINE Karte
|
||||
in der Regie; ihr Druck räumt zuerst die Karte ab (damit die zweite
|
||||
Regie nicht ein zweites Mal springt), drückt dann den vorhandenen
|
||||
−10-Knopf (`#v-zurueck`, derselbe Weg wie die Pfeiltaste) und markiert
|
||||
den Moment über das Cockpit (`/workspace/api/reaktion/moment`).
|
||||
KEIN ZUSCHAUER BEWEGT DAS VIDEO – er bittet nur.
|
||||
|
||||
Eigene Datei wegen der 200-KB-Grenze von reaktion.js. Alle Texte über
|
||||
textContent. `window.__rpuls` trägt den Stand für die Prüfung.
|
||||
===================================================================== */
|
||||
(() => {
|
||||
'use strict';
|
||||
const $ = (id) => document.getElementById(id);
|
||||
const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e; };
|
||||
const FENSTER = 60;
|
||||
const GLEITEND = 3;
|
||||
let lage = null;
|
||||
|
||||
/* ================================================================ PULS */
|
||||
const werte = new Map(); /* Server-Sekunde -> Anzahl */
|
||||
let rechts = 0; /* jüngste bekannte Server-Sekunde */
|
||||
let rechtsAm = 0; /* performance.now(), als `rechts` ankam */
|
||||
let balken = [];
|
||||
let geladenFuer = '';
|
||||
let stufeAlt = '';
|
||||
|
||||
function welleBauen() {
|
||||
if ($('rpuls')) return;
|
||||
const kopf = document.querySelector('body > .kopfleiste');
|
||||
if (!kopf) return;
|
||||
const w = el('div', 'rpuls');
|
||||
w.id = 'rpuls';
|
||||
w.hidden = true;
|
||||
w.setAttribute('role', 'img');
|
||||
w.setAttribute('aria-label', 'Rudel-Puls: ruhig');
|
||||
for (let i = 0; i < FENSTER; i++) w.append(el('i', 'rpuls__balken'));
|
||||
kopf.append(w);
|
||||
balken = [...w.children];
|
||||
}
|
||||
|
||||
/** Wie weit „jetzt“ ist – in Server-Sekunden, ohne die Uhr des Geräts:
|
||||
die jüngste gemeldete Sekunde plus die Zeit seither. */
|
||||
const jetztSek = () => (rechts ? rechts + Math.floor((performance.now() - rechtsAm) / 1000) : 0);
|
||||
|
||||
function aufnehmen(ab, liste) {
|
||||
if (!Number.isInteger(ab) || !Array.isArray(liste)) return;
|
||||
liste.forEach((n, i) => werte.set(ab + i, Math.max(0, Number(n) || 0)));
|
||||
const bis = ab + liste.length - 1;
|
||||
if (bis >= rechts) { rechts = bis; rechtsAm = performance.now(); }
|
||||
for (const s of werte.keys()) if (s < rechts - FENSTER - GLEITEND) werte.delete(s);
|
||||
}
|
||||
|
||||
function welleZeichnen() {
|
||||
const w = $('rpuls');
|
||||
if (!w || w.hidden || !balken.length) return;
|
||||
const ende = jetztSek();
|
||||
const roh = [];
|
||||
for (let s = ende - FENSTER - GLEITEND + 2; s <= ende; s++) roh.push(werte.get(s) || 0);
|
||||
/* Gleitend über drei Sekunden: Ein einzelner Beitrag ist ein kleiner
|
||||
Hügel, kein Strich – und zwanzig in zwei Sekunden eine Welle. */
|
||||
const glatt = [];
|
||||
for (let i = GLEITEND - 1; i < roh.length; i++) {
|
||||
let summe = 0;
|
||||
for (let j = 0; j < GLEITEND; j++) summe += roh[i - j];
|
||||
glatt.push(summe / GLEITEND);
|
||||
}
|
||||
/* Der Maßstab hat einen Boden: Ein Beitrag allein füllt nicht die
|
||||
ganze Höhe, sonst sähe jeder stille Abend aufgeregt aus. */
|
||||
const max = Math.max(3, ...glatt);
|
||||
glatt.forEach((v, i) => {
|
||||
const b = balken[i];
|
||||
if (b) b.style.transform = `scaleY(${Math.max(0.04, v / max).toFixed(3)})`;
|
||||
});
|
||||
const spitze = Math.max(...glatt.slice(-10));
|
||||
const stufe = spitze >= 3 ? 'sehr lebhaft' : spitze >= 1 ? 'lebhaft' : spitze > 0 ? 'leise' : 'ruhig';
|
||||
if (stufe !== stufeAlt) { stufeAlt = stufe; w.setAttribute('aria-label', `Rudel-Puls: ${stufe}`); w.dataset.stufe = stufe; }
|
||||
}
|
||||
|
||||
async function pulsLaden(schluessel) {
|
||||
if (geladenFuer === schluessel) return;
|
||||
geladenFuer = schluessel;
|
||||
werte.clear(); rechts = 0;
|
||||
try {
|
||||
const a = await fetch('/workspace/api/reaktion/puls', { credentials: 'same-origin', cache: 'no-store' });
|
||||
const j = await a.json().catch(() => null);
|
||||
if (a.ok && j?.live) aufnehmen(j.ab, j.werte);
|
||||
} catch { /* dann fängt die Welle eben leer an */ }
|
||||
welleZeichnen();
|
||||
}
|
||||
|
||||
/* ============================================================= NOCHMAL */
|
||||
let nochmal = { anzahl: 0, schwelle: 10, saal: 0, karte: false, gebeten: false, noch_sek: 0 };
|
||||
let gebetenBis = 0;
|
||||
let unterwegs = false;
|
||||
let blaseUhr = null;
|
||||
|
||||
const darfBitten = () => !!lage && lage.stand === 'live' && lage.art !== 'spiel' && !!lage.video && !lage.ich?.host;
|
||||
const istRegie = () => !!lage?.ich?.host;
|
||||
|
||||
function knopfBauen() {
|
||||
if ($('nochmal-knopf')) return;
|
||||
/* IN DER EINGABEZEILE, links vom Feld – dort, wo man ohnehin reagiert.
|
||||
Im Kopf des Chats war kein Platz: Gemessen brach er dort am Rechner
|
||||
um, und der Chat verlor eine Zeile. */
|
||||
const feld = $('chat-feld');
|
||||
const form = $('chat-form');
|
||||
if (!feld || !form) return;
|
||||
const k = el('button', 'btn btn-icon btn-sekundaer nochmal-knopf');
|
||||
k.type = 'button';
|
||||
k.id = 'nochmal-knopf';
|
||||
k.hidden = true;
|
||||
k.setAttribute('aria-pressed', 'false');
|
||||
k.setAttribute('aria-describedby', 'nochmal-blase');
|
||||
const svgNs = 'http://www.w3.org/2000/svg';
|
||||
const svg = document.createElementNS(svgNs, 'svg');
|
||||
svg.setAttribute('viewBox', '0 0 24 24');
|
||||
svg.setAttribute('aria-hidden', 'true');
|
||||
const p = document.createElementNS(svgNs, 'path');
|
||||
p.setAttribute('d', 'M4.5 12a7.5 7.5 0 1 0 2.2-5.3M4.5 4.5v4h4');
|
||||
svg.append(p);
|
||||
const zahl = el('span', 'nochmal-knopf__zahl', '');
|
||||
zahl.id = 'nochmal-zahl';
|
||||
zahl.hidden = true;
|
||||
k.append(svg, zahl);
|
||||
k.title = 'Nochmal! – um die Wiederholung der letzten Sekunden bitten';
|
||||
k.addEventListener('click', bitten);
|
||||
feld.before(k);
|
||||
const blase = el('p', 'nochmal-blase', '');
|
||||
blase.id = 'nochmal-blase';
|
||||
blase.setAttribute('role', 'status');
|
||||
blase.dataset.zeigt = 'nein';
|
||||
form.append(blase);
|
||||
}
|
||||
|
||||
function knopfZeichnen() {
|
||||
const k = $('nochmal-knopf');
|
||||
if (!k) return;
|
||||
k.hidden = !darfBitten();
|
||||
const gebeten = gebetenBis > Date.now();
|
||||
k.setAttribute('aria-pressed', String(gebeten));
|
||||
k.dataset.gebeten = gebeten ? 'ja' : 'nein';
|
||||
const z = $('nochmal-zahl');
|
||||
z.hidden = !(nochmal.anzahl > 0);
|
||||
z.textContent = String(nochmal.anzahl || '');
|
||||
k.setAttribute('aria-label', gebeten
|
||||
? `Nochmal – du hast gebeten. ${nochmal.anzahl} von ${nochmal.schwelle} nötig.`
|
||||
: `Nochmal: um die Wiederholung der letzten Sekunden bitten${nochmal.anzahl ? ` (${nochmal.anzahl} bitten schon)` : ''}`);
|
||||
}
|
||||
|
||||
function blaseZeigen(text) {
|
||||
const b = $('nochmal-blase');
|
||||
if (!b) return;
|
||||
b.textContent = text;
|
||||
b.dataset.zeigt = 'ja';
|
||||
clearTimeout(blaseUhr);
|
||||
blaseUhr = setTimeout(() => { b.dataset.zeigt = 'nein'; }, 4500);
|
||||
}
|
||||
|
||||
function stand(j) {
|
||||
if (!j) return;
|
||||
for (const f of ['anzahl', 'schwelle', 'saal', 'karte']) if (j[f] !== undefined) nochmal[f] = j[f];
|
||||
if (j.noch_sek !== undefined) gebetenBis = j.gebeten ? Date.now() + j.noch_sek * 1000 : 0;
|
||||
knopfZeichnen();
|
||||
karteZeichnen();
|
||||
}
|
||||
|
||||
async function bitten() {
|
||||
if (unterwegs || !darfBitten()) return;
|
||||
if (gebetenBis > Date.now()) {
|
||||
const wieder = `Wieder in ${Math.ceil((gebetenBis - Date.now()) / 1000)} s.`;
|
||||
blaseZeigen(nochmal.anzahl ? `Schon gebeten – ${nochmal.anzahl} von ${nochmal.schwelle} nötig. ${wieder}` : `Du hast gerade schon gebeten. ${wieder}`);
|
||||
return;
|
||||
}
|
||||
unterwegs = true;
|
||||
try {
|
||||
const a = await fetch('/workspace/api/reaktion/nochmal', {
|
||||
method: 'POST', credentials: 'same-origin',
|
||||
headers: { 'Content-Type': 'application/json' }, body: '{}',
|
||||
});
|
||||
const j = await a.json().catch(() => null);
|
||||
if (!a.ok) {
|
||||
blaseZeigen(j?.fehler === 'nicht_dabei' ? 'Du bist gerade nicht im Saal – kurz neu laden.' : 'Das ging gerade nicht.');
|
||||
return;
|
||||
}
|
||||
stand(j);
|
||||
blaseZeigen(j.karte
|
||||
? `Die Regie hat eure Bitte (${j.anzahl}). Sie entscheidet.`
|
||||
: `Gebeten – ${j.anzahl} von ${j.schwelle} nötig. Ab ${j.schwelle} geht die Bitte an die Regie.`);
|
||||
} catch { blaseZeigen('Das ging gerade nicht.'); } finally { unterwegs = false; }
|
||||
}
|
||||
|
||||
/* ---- Die Karte der Regie ------------------------------------------ */
|
||||
function karteBauen() {
|
||||
if ($('nochmalkarte')) return;
|
||||
const leiste = document.querySelector('#pult .pult__leiste');
|
||||
if (!leiste) return;
|
||||
const karte = el('section', 'nochmalkarte');
|
||||
karte.id = 'nochmalkarte';
|
||||
karte.hidden = true;
|
||||
karte.setAttribute('aria-labelledby', 'nochmal-ueber');
|
||||
karte.setAttribute('aria-live', 'polite');
|
||||
const ueber = el('h4', 'nochmalkarte__ueber', 'Das Rudel will’s nochmal sehen');
|
||||
ueber.id = 'nochmal-ueber';
|
||||
const satz = el('p', 'nochmalkarte__satz', '');
|
||||
satz.id = 'nochmal-satz';
|
||||
const tun = el('div', 'nochmalkarte__tun');
|
||||
const ja = el('button', 'btn btn-klein btn-primaer', 'Für alle nochmal (−10 s)');
|
||||
ja.type = 'button';
|
||||
ja.id = 'nochmal-ja';
|
||||
ja.addEventListener('click', () => entscheiden('nochmal'));
|
||||
const spaeter = el('button', 'btn btn-klein btn-sekundaer', 'Später');
|
||||
spaeter.type = 'button';
|
||||
spaeter.id = 'nochmal-spaeter';
|
||||
spaeter.addEventListener('click', () => entscheiden('spaeter'));
|
||||
tun.append(ja, spaeter);
|
||||
karte.append(ueber, satz, tun);
|
||||
/* IN die Leiste, die immer steht (eine eigene Zeile am Ende), und
|
||||
nicht darunter: Das Pult ist ein Raster aus Kopf und Inhalt – ein
|
||||
drittes Kind dazwischen nähme dem Inhalt seine Höhe. */
|
||||
leiste.append(karte);
|
||||
}
|
||||
|
||||
function karteZeichnen() {
|
||||
const karte = $('nochmalkarte');
|
||||
if (!karte) return;
|
||||
const zeigen = istRegie() && lage?.stand === 'live' && lage.art !== 'spiel' && !!nochmal.karte;
|
||||
karte.hidden = !zeigen;
|
||||
if (!zeigen) return;
|
||||
$('nochmal-ueber').textContent = `Das Rudel will’s nochmal sehen (${nochmal.anzahl})`;
|
||||
$('nochmal-satz').textContent = `${nochmal.anzahl} von ${nochmal.saal} im Saal · zurück um 10 Sekunden · der Moment wird markiert`;
|
||||
}
|
||||
|
||||
let entscheidet = false;
|
||||
async function entscheiden(art) {
|
||||
if (entscheidet) return;
|
||||
entscheidet = true;
|
||||
try {
|
||||
const a = await fetch('/workspace/api/reaktion/nochmal/erledigt', {
|
||||
method: 'POST', credentials: 'same-origin',
|
||||
headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ art }),
|
||||
});
|
||||
const j = await a.json().catch(() => null);
|
||||
nochmal.karte = false;
|
||||
karteZeichnen();
|
||||
/* 409 „keine_karte“: Die andere Regie war schneller – dann wird hier
|
||||
NICHT noch einmal gesprungen. */
|
||||
if (!a.ok || art !== 'nochmal') return;
|
||||
/* Derselbe Weg wie der −10-Knopf (und die Pfeiltaste links). */
|
||||
$('v-zurueck')?.click();
|
||||
const gemerkt = window.Cockpit?.moment ? await window.Cockpit.moment() : false;
|
||||
if (gemerkt === false) {
|
||||
await fetch('/workspace/api/reaktion/moment', {
|
||||
method: 'POST', credentials: 'same-origin',
|
||||
headers: { 'Content-Type': 'application/json' }, body: '{}',
|
||||
}).then((x) => x.arrayBuffer()).catch(() => {});
|
||||
}
|
||||
window.__rpuls.zuletzt = { art, anzahl: j?.anzahl };
|
||||
} catch { /* die Karte ist weg; im Zweifel drückt die Regie selbst −10 */ } finally { entscheidet = false; }
|
||||
}
|
||||
|
||||
/* ================================================================ LAGE */
|
||||
let nochmalFuer = '';
|
||||
function lageAnwenden(l) {
|
||||
lage = l;
|
||||
if (!l) return;
|
||||
welleBauen();
|
||||
knopfBauen();
|
||||
if (istRegie()) karteBauen();
|
||||
const live = l.stand === 'live' && !!l.gestartet_am;
|
||||
const w = $('rpuls');
|
||||
if (w) w.hidden = !live;
|
||||
if (live) pulsLaden(l.gestartet_am); else { geladenFuer = ''; werte.clear(); rechts = 0; }
|
||||
const schluessel = live && l.art !== 'spiel' ? `${l.gestartet_am}|${l.video}` : '';
|
||||
if (schluessel && schluessel !== nochmalFuer) {
|
||||
nochmalFuer = schluessel;
|
||||
fetch('/workspace/api/reaktion/nochmal', { credentials: 'same-origin', cache: 'no-store' })
|
||||
.then((a) => a.json()).then((j) => { if (j?.geht) stand(j); }).catch(() => {});
|
||||
}
|
||||
if (!schluessel) { nochmalFuer = ''; nochmal = { ...nochmal, anzahl: 0, karte: false }; gebetenBis = 0; }
|
||||
knopfZeichnen();
|
||||
karteZeichnen();
|
||||
welleZeichnen();
|
||||
}
|
||||
|
||||
window.addEventListener('saal:lage', (e) => lageAnwenden(e.detail));
|
||||
window.addEventListener('saal:strom', (e) => {
|
||||
const d = e.detail;
|
||||
if (d?.was === 'puls') { aufnehmen(d.ab, d.werte); welleZeichnen(); }
|
||||
if (d?.was === 'nochmal') {
|
||||
stand(d);
|
||||
if (d.erledigt === 'nochmal' && darfBitten()) blaseZeigen('Die Regie spult für alle zurück.');
|
||||
}
|
||||
});
|
||||
/* Abklingen ohne Nachricht: Der Server schweigt, wenn der Saal still
|
||||
ist – die Welle wandert hier trotzdem weiter nach links. */
|
||||
setInterval(welleZeichnen, 2000);
|
||||
setInterval(knopfZeichnen, 5000);
|
||||
|
||||
window.__rpuls = {
|
||||
werte: () => [...werte.entries()],
|
||||
rechts: () => rechts,
|
||||
nochmal: () => ({ ...nochmal, gebeten: gebetenBis > Date.now() }),
|
||||
zuletzt: null,
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user