From 4fd7c2fa8c8cc23d8ae4e3c90aa0ec6055e35f1c Mon Sep 17 00:00:00 2001 From: simonpipe Date: Fri, 19 Dec 2025 15:34:50 +0100 Subject: [PATCH] Delete sleeptimer.js --- sleeptimer.js | 57 --------------------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 sleeptimer.js diff --git a/sleeptimer.js b/sleeptimer.js deleted file mode 100644 index 5640cb1..0000000 --- a/sleeptimer.js +++ /dev/null @@ -1,57 +0,0 @@ -// sleeptimer.js - Verwaltet die automatische Abschaltung und Restzeitanzeige -window.SleepTimer = { - timeoutId: null, - endTime: null, - onExpiry: null, - - init(onExpiryCallback) { - this.onExpiry = onExpiryCallback; - }, - - setTimer(minutes) { - this.clear(); - const durationMs = minutes * 60000; - this.endTime = Date.now() + durationMs; - - this.timeoutId = setTimeout(() => { - if (this.onExpiry) this.onExpiry(); - this.clear(); - }, durationMs); - - this.updateButtonUI(); - }, - - clear() { - if (this.timeoutId) { - clearTimeout(this.timeoutId); - this.timeoutId = null; - } - this.endTime = null; - this.updateButtonUI(); - }, - - updateButtonUI() { - const btn = document.getElementById('open-sleep-timer-modal'); - if (!btn) return; - - if (this.endTime) { - const remaining = Math.max(0, Math.ceil((this.endTime - Date.now()) / 60000)); - // Anzeige mit Icon und Restzeit - btn.innerHTML = ` ${remaining} Min`; - - // Selbst-Aktualisierung alle 10 Sekunden (nur wenn Timer aktiv) - if (this.timeoutId) { - setTimeout(() => this.updateButtonUI(), 10000); - } - } else { - // Standard-Text wenn kein Timer läuft - btn.textContent = 'Sleeptimer'; - } - - // Den "Timer aus"-Button im Modal zeigen/verstecken - const offBtn = document.getElementById('off-sleep-timer-modal'); - if (offBtn) { - offBtn.style.display = this.timeoutId ? 'inline-block' : 'none'; - } - } -}; \ No newline at end of file