Neues Widget notice (ADR-59): vollständiger Text und Kurztext als formatierte Texte, drei Modi (Volltext, responsiv mit Zeilengrenze, immer mit Kurzdarstellung), Symbol, Schriftgrößen XS bis L, Fläche, Rahmen und Akzentlinie. Der Server liefert immer den vollständigen Text; notice.js klappt ein und steht beim ersten Hinweis inline, damit nichts nach dem Laden springt (CLS 0,000). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
102 lines
2.4 KiB
JavaScript
102 lines
2.4 KiB
JavaScript
import Hls from 'hls.js';
|
|
import './site-nav.js';
|
|
import './card-clip.js';
|
|
import './notice.js';
|
|
import './hero-video.js';
|
|
import './member-nav.js';
|
|
|
|
function attachPlayback(video) {
|
|
if (!(video instanceof HTMLVideoElement) || video.dataset.playbackReady === '1') {
|
|
return;
|
|
}
|
|
|
|
const source = video.dataset.hls;
|
|
|
|
if (!source) {
|
|
return;
|
|
}
|
|
|
|
video.dataset.playbackReady = '1';
|
|
|
|
if (Hls.isSupported()) {
|
|
const playback = new Hls();
|
|
playback.loadSource(source);
|
|
playback.attachMedia(video);
|
|
|
|
return;
|
|
}
|
|
|
|
if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
|
video.src = source;
|
|
}
|
|
}
|
|
|
|
function scanPlayback(root) {
|
|
if (root instanceof HTMLVideoElement) {
|
|
attachPlayback(root);
|
|
}
|
|
|
|
// Der Anfangsscan übergibt das Dokument selbst; es ist kein Element und wurde bisher übersprungen,
|
|
// sodass im Quelltext stehende HLS-Filme nie angebunden wurden.
|
|
if (root instanceof Element || root instanceof Document) {
|
|
root.querySelectorAll('video[data-hls]').forEach(attachPlayback);
|
|
}
|
|
}
|
|
|
|
scanPlayback(document);
|
|
|
|
new MutationObserver((records) => {
|
|
records.forEach((record) => {
|
|
record.addedNodes.forEach((node) => {
|
|
if (node instanceof Element) {
|
|
scanPlayback(node);
|
|
}
|
|
});
|
|
});
|
|
}).observe(document.documentElement, { childList: true, subtree: true });
|
|
|
|
document.addEventListener('click', (event) => {
|
|
const fullscreen = event.target.closest('[data-fullscreen]');
|
|
|
|
if (fullscreen) {
|
|
// Der Vollbild-Knopf steht im Player oder, im Mitgliederbereich, neben ihm in derselben Spalte bzw. Zeile.
|
|
const media = fullscreen.closest('.player, .mb-content-main, .mb-outline-item')?.querySelector('video, audio');
|
|
|
|
if (media?.requestFullscreen) {
|
|
media.requestFullscreen();
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
const decision = event.target.closest('[data-course-decision]');
|
|
const restart = event.target.closest('[data-course-restart]');
|
|
const button = decision || restart;
|
|
|
|
if (!button) {
|
|
return;
|
|
}
|
|
|
|
const video = button.closest('li')?.querySelector('video');
|
|
|
|
if (!video) {
|
|
return;
|
|
}
|
|
|
|
if (restart) {
|
|
video.currentTime = 0;
|
|
video.play();
|
|
|
|
return;
|
|
}
|
|
|
|
const at = Number(video.dataset.decision);
|
|
|
|
if (Number.isNaN(at)) {
|
|
return;
|
|
}
|
|
|
|
video.currentTime = at;
|
|
video.pause();
|
|
});
|