chore: complete update

This commit is contained in:
2025-07-17 16:24:20 +02:00
parent 899227b0a4
commit 64a7051137
1300 changed files with 85570 additions and 2756 deletions

View File

@@ -0,0 +1,50 @@
// 📦 Automatischer Video-Loader (Bandbreiten- & Auflösungs-bewusst)
// Erkennt automatisch <video data-src="basename"> Elemente
// Lädt passende Variante: basename-480.webm, -720.webm, -1080.webm etc.
export function autoLoadResponsiveVideos() {
const videos = document.querySelectorAll('video[data-src]');
const width = window.innerWidth;
const connection = navigator.connection || {};
const net = connection.effectiveType || '4g';
videos.forEach(video => {
const base = video.dataset.src;
let suffix = '480';
if (net === '2g' || net === 'slow-2g') {
suffix = '480';
} else if (net === '3g') {
suffix = width >= 1200 ? '720' : '480';
} else {
suffix = width >= 1200 ? '1080' : width >= 800 ? '720' : '480';
}
const src = `${base}-${suffix}.webm`;
const newVideo = document.createElement('video');
newVideo.autoplay = true;
newVideo.loop = true;
newVideo.muted = true;
newVideo.playsInline = true;
newVideo.poster = video.getAttribute('poster') || '';
newVideo.setAttribute('width', video.getAttribute('width') || '100%');
const source = document.createElement('source');
source.src = src;
source.type = 'video/webm';
newVideo.appendChild(source);
video.replaceWith(newVideo);
});
}
/*
<video data-src="/media/video" poster="/media/preview.jpg" width="100%">
<!-- Optionaler Fallback -->
<source src="/media/video-480.mp4" type="video/mp4"/>
</video>
*/

View File

@@ -0,0 +1,34 @@
export class SimpleCache {
constructor(maxSize = 20, ttl = 60000) {
this.cache = new Map();
this.maxSize = maxSize;
this.ttl = ttl;
}
get(key) {
const cached = this.cache.get(key);
if (!cached) return null;
if (Date.now() - cached.timestamp > this.ttl) {
this.cache.delete(key);
return null;
}
return cached.data;
}
set(key, data) {
if (this.cache.size >= this.maxSize) {
// Entferne das älteste Element
const oldest = [...this.cache.entries()].sort((a, b) => a[1].timestamp - b[1].timestamp)[0][0];
this.cache.delete(oldest);
}
this.cache.set(key, { data, timestamp: Date.now() });
}
has(key) {
return this.get(key) !== null;
}
clear() {
this.cache.clear();
}
}

View File

@@ -0,0 +1 @@
export * from './cache'