/* ============================================================ DEMO.JS — nur für index.html, nicht Teil des Frameworks Früher Inline-Skript; ausgelagert, damit die Demo unter einer strengen CSP läuft. Das Theme übernimmt theme.js. ============================================================ */ // ---- DEMO: Toast-Typen durchrotieren ---- const demoToastTypes = [ { msg: 'Erfolgreich gespeichert!', type: 'success' }, { msg: 'Bitte überprüfe deine Eingabe.', type: 'warning' }, { msg: 'Verbindungsfehler aufgetreten.', type: 'danger' }, { msg: 'Neue Nachricht erhalten.', type: 'info' }, ]; let demoToastCount = 0; document.addEventListener('click', e => { if (!e.target.closest('[data-action="demo-toast"]')) return; const t = demoToastTypes[demoToastCount++ % demoToastTypes.length]; showToast(t.msg, t.type); }); // ---- ACTIVE NAV (Scroll-basiert) ---- const sections = document.querySelectorAll('section[id]'); const navLinks = document.querySelectorAll('.sidebar-nav a'); const observer = new IntersectionObserver(entries => { entries.forEach(entry => { if (entry.isIntersecting) { navLinks.forEach(a => a.classList.remove('active')); const active = document.querySelector(`.sidebar-nav a[href="#${entry.target.id}"]`); if (active) active.classList.add('active'); } }); }, { rootMargin: '-20% 0px -60% 0px' }); sections.forEach(s => observer.observe(s));