Delete sleeptimer.js

This commit is contained in:
simonpipe 2025-12-19 15:34:50 +01:00
parent 6ef6adc961
commit 4fd7c2fa8c

View file

@ -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 = `<i class="fas fa-hourglass-half"></i> ${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';
}
}
};