Files
dogfather-universe/workspace/assets/js/foyer-nachschauen.js
T

34 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* =====================================================================
NACHSCHAUEN IM FOYER (05.11.2026, Perfektionsplan Runde 8)
„Zuletzt“ im Foyer öffnet den Nachbericht – und der hat seit heute
„Nachschauen“. Diese Datei sagt es an der Karte: „▶ Nachschauen“, und
„mit Chat von damals“, wenn die Regie ihn aufgehoben hat. Gelesen wird
die Liste, die der Nachbericht selbst benutzt.
===================================================================== */
(() => {
'use strict';
let liste = null;
const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e; };
async function laden() {
try {
const a = await fetch('/workspace/api/reaktion/nachschauen', { credentials: 'same-origin', cache: 'no-store' });
const j = await a.json().catch(() => null);
liste = a.ok && Array.isArray(j?.liste) ? j.liste : [];
} catch { liste = []; }
zeichnen();
}
function zeichnen() {
if (!liste) return;
for (const s of liste) {
const li = document.querySelector(`#zuletzt-liste [data-sendung="${CSS.escape(String(s.id))}"]`);
if (!li || li.querySelector('.fy-ns')) continue;
const z = el('span', 'fy-ns', s.chat ? '▶ Nachschauen · mit Chat von damals' : '▶ Nachschauen');
(li.querySelector('a') || li).append(z);
}
}
const ziel = document.getElementById('zuletzt-liste');
if (ziel) new MutationObserver(zeichnen).observe(ziel, { childList: true });
laden();
})();