181 lines
10 KiB
JavaScript
181 lines
10 KiB
JavaScript
/* =====================================================================
|
||
DER PROBEABEND (05.11.2026, Perfektionsplan Runde 3)
|
||
|
||
In der Werkstatt-Tafel „Startklar“: sechs Punkte, die nur an Filipes
|
||
Rechner messbar sind. Jeder Punkt MISST SELBST, wo es geht, und sagt
|
||
sonst ehrlich „das sagst du mir“. Das Ergebnis geht an den Server
|
||
(/workspace/api/reaktion/probeabend, nur Regie) und steht beim nächsten
|
||
Mal mit Datum da. Drei Ausgänge je Punkt: geht · knapp · geht nicht –
|
||
und „offen“, solange nicht gemessen.
|
||
===================================================================== */
|
||
(() => {
|
||
'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 warte = (ms) => new Promise((r) => setTimeout(r, ms));
|
||
const WORT = { offen: 'noch offen', geht: 'geht', knapp: 'knapp', geht_nicht: 'geht nicht' };
|
||
let punkte = {};
|
||
let laeuft = '';
|
||
|
||
const PUNKTE = [
|
||
{ id: 'fenster', titel: 'Saal-Fenster über GTA',
|
||
satz: 'Öffnet das Saal-Fenster mit einem Knopf „Ich sehe dich“. Wechsle ins Spiel (Vollbild) und drück ihn dort innerhalb einer Minute.',
|
||
los: fensterMessen },
|
||
{ id: 'freistellen', titel: 'Freistellen auf deiner Grafikkarte',
|
||
satz: '30 Sekunden „Weich“ mit deiner Kamera; gemessen werden die Bilder pro Sekunde. Danach stellt sich alles zurück.',
|
||
los: freistellenMessen },
|
||
{ id: 'clip', titel: 'Clip aus OBS',
|
||
satz: 'Replaypuffer in OBS starten, Untertitel-Dienst verbinden, dann hier drücken – der Dienst meldet den gespeicherten Clip zurück.',
|
||
los: clipMessen },
|
||
{ id: 'streamdeck', titel: 'Stream Deck',
|
||
satz: 'Verbindet das Stream Deck und wartet, bis du eine Taste drückst.',
|
||
los: streamDeckMessen },
|
||
{ id: 'meinmix', titel: 'Mein Mix mit einem echten Zuschauer',
|
||
satz: 'Lass jemanden am Handy unter „Mein Mix“ das Spiel auf 0 drehen. Hat er es danach nicht mehr gehört?',
|
||
frage: true },
|
||
{ id: 'lautheit', titel: 'Lautheit gegen dein Pult',
|
||
satz: 'Sprich normal: Zeigt dein Pult etwa dasselbe wie die Lautheit im Ton-Bereich (Ziel −16 LUFS)?',
|
||
frage: true },
|
||
];
|
||
|
||
async function laden() {
|
||
try {
|
||
const a = await fetch('/workspace/api/reaktion/probeabend', { credentials: 'same-origin', cache: 'no-store' });
|
||
const j = await a.json().catch(() => null);
|
||
if (a.ok && j?.punkte) punkte = j.punkte;
|
||
} catch { /* dann bleibt es offen */ }
|
||
zeichnen();
|
||
}
|
||
async function merken(punkt, stand, wert) {
|
||
try {
|
||
const a = await fetch('/workspace/api/reaktion/probeabend', { method: 'PUT', credentials: 'same-origin', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ punkt, stand, wert }) });
|
||
const j = await a.json().catch(() => null);
|
||
if (a.ok && j?.punkte) punkte = j.punkte;
|
||
} catch { /* der nächste Versuch */ }
|
||
laeuft = '';
|
||
zeichnen();
|
||
}
|
||
function sagen(id, text) { const z = $(`pa-sagt-${id}`); if (z) z.textContent = text; }
|
||
|
||
/* ---- 1. Saal-Fenster über GTA ---- */
|
||
async function fensterMessen() {
|
||
if (!('documentPictureInPicture' in window)) return merken('fenster', 'geht_nicht', 'Dieser Browser kann kein Bild-im-Bild');
|
||
let pip;
|
||
try { pip = await window.documentPictureInPicture.requestWindow({ width: 320, height: 200 }); } catch { return merken('fenster', 'geht_nicht', 'Fenster ließ sich nicht öffnen'); }
|
||
const d = pip.document;
|
||
d.body.style.cssText = 'margin:0;display:grid;place-items:center;background:#07060d;font-family:system-ui;color:#e8f1fa';
|
||
const k = d.createElement('button');
|
||
k.textContent = 'Ich sehe dich'; k.style.cssText = 'min-height:64px;padding:0 24px;font-size:20px;font-weight:700;border-radius:14px;border:1px solid #8fd3ff;background:#10162a;color:#e8f1fa';
|
||
d.body.append(k);
|
||
sagen('fenster', 'Jetzt ins Spiel wechseln und dort im kleinen Fenster drücken …');
|
||
const ergebnis = await new Promise((fertig) => {
|
||
const uhr = setTimeout(() => fertig(null), 60_000);
|
||
k.addEventListener('click', () => { clearTimeout(uhr); fertig({ verdeckt: document.visibilityState === 'hidden' || !document.hasFocus() }); });
|
||
pip.addEventListener('pagehide', () => { clearTimeout(uhr); fertig(undefined); });
|
||
});
|
||
try { pip.close(); } catch { /* zu */ }
|
||
if (ergebnis === null) return merken('fenster', 'geht_nicht', 'In einer Minute kein Druck – vermutlich vom Spiel verdeckt');
|
||
if (ergebnis === undefined) return merken('fenster', 'offen', '');
|
||
return merken('fenster', ergebnis.verdeckt ? 'geht' : 'knapp', ergebnis.verdeckt ? 'Gedrückt, während das Spiel vorn war' : 'Gedrückt, aber der Saal war vorn – im Spiel noch einmal probieren');
|
||
}
|
||
|
||
/* ---- 2. Freistellen ---- */
|
||
async function freistellenMessen() {
|
||
const F = window.Freistellen;
|
||
const knopf = (art) => document.querySelector(`#fs-ton .fs-knopf[data-art="${art}"], #fs-fenster .fs-knopf[data-art="${art}"]`);
|
||
if (!F || !knopf('weich')) return merken('freistellen', 'geht_nicht', 'Freistellen nicht geladen – Ton-Bereich einmal öffnen');
|
||
const vorher = F.art();
|
||
knopf('weich').click();
|
||
const raten = [];
|
||
for (let i = 0; i < 30; i++) {
|
||
await warte(1000);
|
||
const r = F.rate();
|
||
if (r > 0) raten.push(r);
|
||
sagen('freistellen', `misst … ${i + 1}/30 s · ${r} Bilder/s`);
|
||
}
|
||
knopf(vorher)?.click();
|
||
if (!raten.length) return merken('freistellen', 'geht_nicht', F.grund() || 'kein Bild gerechnet');
|
||
raten.sort((a, b) => a - b);
|
||
const mitte = raten[Math.floor(raten.length / 2)];
|
||
return merken('freistellen', mitte >= 24 ? 'geht' : mitte >= 12 ? 'knapp' : 'geht_nicht', `${mitte} Bilder/s (Mitte von ${raten.length} Messungen), ${F.geraet() === 'GPU' ? 'Grafikkarte' : 'Prozessor'}`);
|
||
}
|
||
|
||
/* ---- 3. Clip ---- */
|
||
async function clipMessen() {
|
||
if (!window.Untertitel?.clip?.('probe')) return merken('clip', 'geht_nicht', 'Untertitel-Dienst nicht verbunden (Chatkopf → UT)');
|
||
sagen('clip', 'Clip wird gespeichert …');
|
||
const m = await new Promise((fertig) => {
|
||
const uhr = setTimeout(() => fertig(null), 20_000);
|
||
const hoeren = (ev) => { if (ev.detail?.art !== 'clip') return; clearTimeout(uhr); window.removeEventListener('ut:clip', hoeren); fertig(ev.detail); };
|
||
window.addEventListener('ut:clip', hoeren);
|
||
});
|
||
if (!m) return merken('clip', 'geht_nicht', 'Keine Antwort vom Dienst in 20 s');
|
||
return merken('clip', m.ok ? 'geht' : 'geht_nicht', m.ok ? `Gespeichert: ${m.datei}${m.untertitel ? ` (${m.untertitel} Untertitel)` : ''}` : (m.text || m.grund || 'abgelehnt'));
|
||
}
|
||
|
||
/* ---- 4. Stream Deck ---- */
|
||
async function streamDeckMessen() {
|
||
if (!window.Pads?.streamDeck) return merken('streamdeck', 'geht_nicht', 'Pads nicht geladen');
|
||
const stand = await window.Pads.streamDeck();
|
||
if (stand !== 'verbunden') return merken('streamdeck', 'geht_nicht', window.Pads.stand().wort);
|
||
sagen('streamdeck', 'Verbunden – jetzt eine Taste am Stream Deck drücken …');
|
||
const t = await new Promise((fertig) => {
|
||
const uhr = setTimeout(() => fertig(null), 30_000);
|
||
const hoeren = (ev) => { if (!String(ev.detail?.pad || '').startsWith('sd:')) return; clearTimeout(uhr); window.removeEventListener('pads:taste', hoeren); fertig(ev.detail); };
|
||
window.addEventListener('pads:taste', hoeren);
|
||
});
|
||
return merken('streamdeck', t ? 'geht' : 'knapp', t ? `Taste empfangen: ${t.text}` : 'Verbunden, aber keine Taste in 30 s');
|
||
}
|
||
|
||
/* ---------------------------------------------- Oberfläche */
|
||
function zeichnen() {
|
||
const tafel = $('werkstatt-startklar');
|
||
if (!tafel) return;
|
||
let b = $('pa');
|
||
if (!b) {
|
||
/* NEBEN „Startklar“, nicht darin: Startklar schaltet nichts – der
|
||
Probeabend misst und schaltet dafür kurz (Freistellen, Fenster). */
|
||
b = el('details', 'pa'); b.id = 'pa';
|
||
const h = el('summary', 'pult__ueber pa-titel'); h.id = 'pa-titel';
|
||
b.append(h, el('p', 'pult__klein', 'Was nur an deinem Rechner messbar ist. Einmal durchgehen (etwa 20 Minuten), das Ergebnis bleibt gespeichert.'));
|
||
const ol = el('ol', 'pa-liste'); ol.id = 'pa-liste';
|
||
b.append(ol);
|
||
tafel.after(b);
|
||
}
|
||
const fertig = PUNKTE.filter((p) => (punkte[p.id]?.stand || 'offen') !== 'offen').length;
|
||
$('pa-titel').textContent = `Probeabend · ${fertig} von ${PUNKTE.length} geprüft`;
|
||
const ol = $('pa-liste');
|
||
ol.textContent = '';
|
||
for (const p of PUNKTE) {
|
||
const e = punkte[p.id] || { stand: 'offen' };
|
||
const li = el('li', 'pa-punkt'); li.dataset.stand = e.stand; li.dataset.punkt = p.id;
|
||
const kopf = el('div', 'pa-kopf');
|
||
kopf.append(el('strong', null, p.titel), el('span', 'pa-stand', WORT[e.stand] || e.stand));
|
||
li.append(kopf, el('p', 'pa-satz', p.satz));
|
||
if (e.wert) li.append(el('p', 'pa-wert', `${e.wert}${e.wann ? ` · ${new Date(e.wann).toLocaleDateString('de-DE')}` : ''}`));
|
||
const reihe = el('div', 'pa-reihe');
|
||
if (p.frage) {
|
||
for (const [st, wort] of [['geht', 'Ja'], ['geht_nicht', 'Nein']]) {
|
||
const k = el('button', 'btn btn-klein btn-sekundaer', wort); k.type = 'button'; k.dataset.antwort = st;
|
||
k.addEventListener('click', () => merken(p.id, st, st === 'geht' ? 'von dir bestätigt' : 'von dir verneint'));
|
||
reihe.append(k);
|
||
}
|
||
} else {
|
||
const k = el('button', 'btn btn-klein btn-primaer', e.stand === 'offen' ? 'Messen' : 'Noch einmal messen'); k.type = 'button'; k.dataset.messen = p.id;
|
||
k.disabled = !!laeuft;
|
||
k.addEventListener('click', () => { if (laeuft) return; laeuft = p.id; zeichnen(); p.los(); });
|
||
reihe.append(k);
|
||
}
|
||
li.append(reihe);
|
||
const sagt = el('p', 'pa-sagt'); sagt.id = `pa-sagt-${p.id}`; sagt.setAttribute('aria-live', 'polite');
|
||
li.append(sagt);
|
||
ol.append(li);
|
||
}
|
||
}
|
||
|
||
let geladen = false;
|
||
window.addEventListener('saal:lage', (ev) => { if (!geladen && ev.detail?.ich?.host) { geladen = true; laden(); } });
|
||
setInterval(() => { if ($('werkstatt-startklar') && !$('pa')) zeichnen(); }, 1500);
|
||
window.Probeabend = { laden, punkte: () => ({ ...punkte }), messen: (id) => PUNKTE.find((p) => p.id === id)?.los?.() };
|
||
})();
|