Fix: Umlaute in index.html korrigiert + Feature: Tee-Timer
- index.html: "Jährlicher Konsum nach Sorte" sowie "Geräten", "Hinzufügen", "Brühzeit", "Einträge" korrigiert (Umlaute fehlten) - Neuer Tee-Timer: Presets 3/5 Min., eigene Zeit (Min/Sek. einstellbar), Start/Pause/Weiter/Zurücksetzen, Restzeit driftfrei über Endzeit, akustischer Alarm (WebAudio) + Toast bei Ablauf - styles.css: Timer-Styles (Display, Presets, Controls, Status) Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
36
index.html
36
index.html
@ -28,7 +28,7 @@
|
|||||||
<section id="auth-section" class="auth-section hidden">
|
<section id="auth-section" class="auth-section hidden">
|
||||||
<div class="auth-card">
|
<div class="auth-card">
|
||||||
<h2>🔐 Anmeldung</h2>
|
<h2>🔐 Anmeldung</h2>
|
||||||
<p>Melden Sie sich an, um Ihre Daten auf allen Geraeten zu synchronisieren.</p>
|
<p>Melden Sie sich an, um Ihre Daten auf allen Geräten zu synchronisieren.</p>
|
||||||
<button id="googleSignIn" class="btn btn-primary google-btn">
|
<button id="googleSignIn" class="btn btn-primary google-btn">
|
||||||
<span class="google-icon">G</span> Mit Google anmelden
|
<span class="google-icon">G</span> Mit Google anmelden
|
||||||
</button>
|
</button>
|
||||||
@ -76,7 +76,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="chart-container full-width">
|
<div class="chart-container full-width">
|
||||||
<h3>Ja hrlicher Konsum nach Sorte</h3>
|
<h3>Jährlicher Konsum nach Sorte</h3>
|
||||||
<canvas id="yearChart"></canvas>
|
<canvas id="yearChart"></canvas>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@ -88,7 +88,7 @@
|
|||||||
<form id="addTeaForm" class="add-form">
|
<form id="addTeaForm" class="add-form">
|
||||||
<input type="text" id="teaName" placeholder="Name der Teesorte" required>
|
<input type="text" id="teaName" placeholder="Name der Teesorte" required>
|
||||||
<input type="color" id="teaColor" value="#4CAF50">
|
<input type="color" id="teaColor" value="#4CAF50">
|
||||||
<button type="submit" class="btn btn-primary">Hinzufugen</button>
|
<button type="submit" class="btn btn-primary">Hinzufügen</button>
|
||||||
</form>
|
</form>
|
||||||
<div id="teaList" class="tea-list"></div>
|
<div id="teaList" class="tea-list"></div>
|
||||||
</div>
|
</div>
|
||||||
@ -108,7 +108,7 @@
|
|||||||
<select id="trackTea" required></select>
|
<select id="trackTea" required></select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Bruhzeit:</label>
|
<label>Brühzeit:</label>
|
||||||
<div class="radio-group">
|
<div class="radio-group">
|
||||||
<label class="radio-label">
|
<label class="radio-label">
|
||||||
<input type="radio" name="brewTime" value="kurz" checked>
|
<input type="radio" name="brewTime" value="kurz" checked>
|
||||||
@ -137,9 +137,35 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<!-- Tea Timer Section -->
|
||||||
|
<section class="timer-section">
|
||||||
|
<h2>⏱️ Tee-Timer</h2>
|
||||||
|
<div class="form-container">
|
||||||
|
<div class="timer-display" id="timerDisplay">03:00</div>
|
||||||
|
<div class="timer-presets">
|
||||||
|
<button type="button" class="btn btn-secondary timer-preset" data-minutes="3">3 Min.</button>
|
||||||
|
<button type="button" class="btn btn-secondary timer-preset" data-minutes="5">5 Min.</button>
|
||||||
|
</div>
|
||||||
|
<div class="timer-custom">
|
||||||
|
<label for="timerMinutes">Eigene Zeit:</label>
|
||||||
|
<input type="number" id="timerMinutes" min="0" max="180" step="1" value="3">
|
||||||
|
<span>Min</span>
|
||||||
|
<input type="number" id="timerSeconds" min="0" max="59" step="1" value="0">
|
||||||
|
<span>Sek</span>
|
||||||
|
<button type="button" id="timerCustomSet" class="btn btn-secondary btn-small">Übernehmen</button>
|
||||||
|
</div>
|
||||||
|
<div class="timer-controls">
|
||||||
|
<button type="button" id="timerStart" class="btn btn-primary">Start</button>
|
||||||
|
<button type="button" id="timerPause" class="btn btn-secondary" disabled>Pause</button>
|
||||||
|
<button type="button" id="timerReset" class="btn btn-danger">Zurücksetzen</button>
|
||||||
|
</div>
|
||||||
|
<div id="timerStatus" class="timer-status"></div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<!-- Consumption History Section -->
|
<!-- Consumption History Section -->
|
||||||
<section class="history-section">
|
<section class="history-section">
|
||||||
<h2>📊 Letzte Eintrage</h2>
|
<h2>📊 Letzte Einträge</h2>
|
||||||
<div class="history-controls">
|
<div class="history-controls">
|
||||||
<button id="filterToday" class="btn btn-secondary">Heute</button>
|
<button id="filterToday" class="btn btn-secondary">Heute</button>
|
||||||
<button id="filterWeek" class="btn btn-secondary">Letzte 7 Tage</button>
|
<button id="filterWeek" class="btn btn-secondary">Letzte 7 Tage</button>
|
||||||
|
|||||||
207
script.js
207
script.js
@ -8,7 +8,14 @@ const App = {
|
|||||||
consumption: [],
|
consumption: [],
|
||||||
currentFilter: 'all',
|
currentFilter: 'all',
|
||||||
currentUser: null,
|
currentUser: null,
|
||||||
loading: true
|
loading: true,
|
||||||
|
timer: {
|
||||||
|
totalSeconds: 180,
|
||||||
|
remainingSeconds: 180,
|
||||||
|
endTime: null,
|
||||||
|
intervalId: null,
|
||||||
|
running: false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Initialisierung
|
// Initialisierung
|
||||||
@ -16,6 +23,8 @@ const App = {
|
|||||||
this.bindEvents();
|
this.bindEvents();
|
||||||
this.setupFirebaseAuth();
|
this.setupFirebaseAuth();
|
||||||
this.updateDate();
|
this.updateDate();
|
||||||
|
this.updateTimerDisplay();
|
||||||
|
this.updateTimerButtons();
|
||||||
},
|
},
|
||||||
|
|
||||||
// Firebase Auth einrichten
|
// Firebase Auth einrichten
|
||||||
@ -160,6 +169,28 @@ const App = {
|
|||||||
e.target.value = '';
|
e.target.value = '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Tee-Timer: Presets (3 / 5 Min.)
|
||||||
|
var presetButtons = document.querySelectorAll('.timer-preset');
|
||||||
|
for (var i = 0; i < presetButtons.length; i++) {
|
||||||
|
presetButtons[i].addEventListener('click', (e) => {
|
||||||
|
this.setTimerPreset(parseInt(e.currentTarget.getAttribute('data-minutes')));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tee-Timer: eigene Zeit
|
||||||
|
el = document.getElementById('timerCustomSet');
|
||||||
|
if (el) el.addEventListener('click', () => { this.setTimerCustom(); });
|
||||||
|
|
||||||
|
// Tee-Timer: Start / Pause / Reset
|
||||||
|
el = document.getElementById('timerStart');
|
||||||
|
if (el) el.addEventListener('click', () => { this.startTimer(); });
|
||||||
|
|
||||||
|
el = document.getElementById('timerPause');
|
||||||
|
if (el) el.addEventListener('click', () => { this.pauseTimer(); });
|
||||||
|
|
||||||
|
el = document.getElementById('timerReset');
|
||||||
|
if (el) el.addEventListener('click', () => { this.resetTimer(); });
|
||||||
},
|
},
|
||||||
|
|
||||||
// Google Sign-In
|
// Google Sign-In
|
||||||
@ -902,6 +933,180 @@ const App = {
|
|||||||
return div.innerHTML;
|
return div.innerHTML;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ===== Tee-Timer =====
|
||||||
|
|
||||||
|
// Preset setzen (z. B. 3 oder 5 Minuten)
|
||||||
|
setTimerPreset(minutes) {
|
||||||
|
var total = (parseInt(minutes) || 0) * 60;
|
||||||
|
if (total <= 0) return;
|
||||||
|
var t = this.state.timer;
|
||||||
|
t.totalSeconds = total;
|
||||||
|
t.remainingSeconds = total;
|
||||||
|
t.endTime = null;
|
||||||
|
this.updateTimerDisplay();
|
||||||
|
this.updateTimerButtons();
|
||||||
|
this.setTimerStatus('Timer auf ' + this.formatTime(total) + ' gesetzt');
|
||||||
|
this.markPresetActive(minutes);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Eigene Zeit aus den Eingabefeldern übernehmen
|
||||||
|
setTimerCustom() {
|
||||||
|
var minEl = document.getElementById('timerMinutes');
|
||||||
|
var secEl = document.getElementById('timerSeconds');
|
||||||
|
var minutes = parseInt((minEl && minEl.value) || '0') || 0;
|
||||||
|
var seconds = parseInt((secEl && secEl.value) || '0') || 0;
|
||||||
|
if (minutes < 0) minutes = 0;
|
||||||
|
if (minutes > 180) minutes = 180;
|
||||||
|
if (seconds < 0) seconds = 0;
|
||||||
|
if (seconds > 59) seconds = 59;
|
||||||
|
var total = minutes * 60 + seconds;
|
||||||
|
if (total <= 0) {
|
||||||
|
this.showToast('Bitte eine Zeit größer als 0 eingeben', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var t = this.state.timer;
|
||||||
|
t.totalSeconds = total;
|
||||||
|
t.remainingSeconds = total;
|
||||||
|
t.endTime = null;
|
||||||
|
this.updateTimerDisplay();
|
||||||
|
this.updateTimerButtons();
|
||||||
|
this.setTimerStatus('Timer auf ' + this.formatTime(total) + ' gesetzt');
|
||||||
|
this.markPresetActive(null);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Timer starten (bzw. nach Pause fortsetzen)
|
||||||
|
startTimer() {
|
||||||
|
var t = this.state.timer;
|
||||||
|
if (t.running) return;
|
||||||
|
// Nach vollständigem Ablauf: gleiche Zeit erneut starten
|
||||||
|
if (t.remainingSeconds <= 0) {
|
||||||
|
t.remainingSeconds = t.totalSeconds;
|
||||||
|
}
|
||||||
|
t.running = true;
|
||||||
|
t.endTime = Date.now() + t.remainingSeconds * 1000;
|
||||||
|
var self = this;
|
||||||
|
t.intervalId = setInterval(function() { self.tickTimer(); }, 250);
|
||||||
|
this.updateTimerButtons();
|
||||||
|
this.setTimerStatus('Timer läuft…');
|
||||||
|
},
|
||||||
|
|
||||||
|
// Timer pausieren
|
||||||
|
pauseTimer() {
|
||||||
|
var t = this.state.timer;
|
||||||
|
if (!t.running) return;
|
||||||
|
t.remainingSeconds = Math.max(0, Math.round((t.endTime - Date.now()) / 1000));
|
||||||
|
clearInterval(t.intervalId);
|
||||||
|
t.intervalId = null;
|
||||||
|
t.running = false;
|
||||||
|
t.endTime = null;
|
||||||
|
this.updateTimerDisplay();
|
||||||
|
this.updateTimerButtons();
|
||||||
|
this.setTimerStatus('Timer pausiert');
|
||||||
|
},
|
||||||
|
|
||||||
|
// Timer auf die eingestellte Gesamtzeit zurücksetzen
|
||||||
|
resetTimer() {
|
||||||
|
var t = this.state.timer;
|
||||||
|
clearInterval(t.intervalId);
|
||||||
|
t.intervalId = null;
|
||||||
|
t.running = false;
|
||||||
|
t.endTime = null;
|
||||||
|
t.remainingSeconds = t.totalSeconds;
|
||||||
|
this.updateTimerDisplay();
|
||||||
|
this.updateTimerButtons();
|
||||||
|
this.setTimerStatus('');
|
||||||
|
},
|
||||||
|
|
||||||
|
// Ein Intervall-Tick: Restzeit anhand der Endzeit neu berechnen
|
||||||
|
tickTimer() {
|
||||||
|
var t = this.state.timer;
|
||||||
|
var remaining = Math.max(0, Math.round((t.endTime - Date.now()) / 1000));
|
||||||
|
t.remainingSeconds = remaining;
|
||||||
|
this.updateTimerDisplay();
|
||||||
|
if (remaining <= 0) {
|
||||||
|
clearInterval(t.intervalId);
|
||||||
|
t.intervalId = null;
|
||||||
|
t.running = false;
|
||||||
|
t.endTime = null;
|
||||||
|
this.updateTimerButtons();
|
||||||
|
this.setTimerStatus('⏱️ Tee ist fertig!');
|
||||||
|
this.showToast('⏱️ Der Tee ist fertig!', 'success');
|
||||||
|
this.playTimerAlarm();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Anzeige aktualisieren
|
||||||
|
updateTimerDisplay() {
|
||||||
|
var el = document.getElementById('timerDisplay');
|
||||||
|
if (el) el.textContent = this.formatTime(this.state.timer.remainingSeconds);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Start/Pause-Buttons je nach Zustand (de)aktivieren
|
||||||
|
updateTimerButtons() {
|
||||||
|
var t = this.state.timer;
|
||||||
|
var startBtn = document.getElementById('timerStart');
|
||||||
|
var pauseBtn = document.getElementById('timerPause');
|
||||||
|
if (startBtn) {
|
||||||
|
startBtn.disabled = t.running;
|
||||||
|
var label = 'Start';
|
||||||
|
if (t.running) label = 'Läuft…';
|
||||||
|
else if (t.remainingSeconds > 0 && t.remainingSeconds < t.totalSeconds) label = 'Weiter';
|
||||||
|
startBtn.textContent = label;
|
||||||
|
}
|
||||||
|
if (pauseBtn) pauseBtn.disabled = !t.running;
|
||||||
|
},
|
||||||
|
|
||||||
|
// Statuszeile unter dem Timer
|
||||||
|
setTimerStatus(text) {
|
||||||
|
var el = document.getElementById('timerStatus');
|
||||||
|
if (el) el.textContent = text;
|
||||||
|
},
|
||||||
|
|
||||||
|
// Aktiven Preset-Button hervorheben
|
||||||
|
markPresetActive(minutes) {
|
||||||
|
var buttons = document.querySelectorAll('.timer-preset');
|
||||||
|
for (var i = 0; i < buttons.length; i++) {
|
||||||
|
var active = buttons[i].getAttribute('data-minutes') == String(minutes);
|
||||||
|
buttons[i].classList.toggle('active', active);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Sekunden als MM:SS formatieren
|
||||||
|
formatTime(totalSeconds) {
|
||||||
|
var s = Math.max(0, parseInt(totalSeconds) || 0);
|
||||||
|
var m = Math.floor(s / 60);
|
||||||
|
var r = s % 60;
|
||||||
|
return (m < 10 ? '0' + m : '' + m) + ':' + (r < 10 ? '0' + r : '' + r);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Akustisches Signal bei Ablauf (3 Pieptöne via WebAudio)
|
||||||
|
playTimerAlarm() {
|
||||||
|
try {
|
||||||
|
var AudioCtx = window.AudioContext || window.webkitAudioContext;
|
||||||
|
if (!AudioCtx) return;
|
||||||
|
var ctx = new AudioCtx();
|
||||||
|
for (var i = 0; i < 3; i++) {
|
||||||
|
(function(n) {
|
||||||
|
var start = ctx.currentTime + n * 0.35;
|
||||||
|
var osc = ctx.createOscillator();
|
||||||
|
var gain = ctx.createGain();
|
||||||
|
osc.type = 'sine';
|
||||||
|
osc.frequency.value = 880;
|
||||||
|
gain.gain.setValueAtTime(0.0001, start);
|
||||||
|
gain.gain.exponentialRampToValueAtTime(0.3, start + 0.02);
|
||||||
|
gain.gain.exponentialRampToValueAtTime(0.0001, start + 0.3);
|
||||||
|
osc.connect(gain);
|
||||||
|
gain.connect(ctx.destination);
|
||||||
|
osc.start(start);
|
||||||
|
osc.stop(start + 0.32);
|
||||||
|
})(i);
|
||||||
|
}
|
||||||
|
setTimeout(function() { ctx.close(); }, 1500);
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('Alarm konnte nicht abgespielt werden', e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// Toast-Nachricht anzeigen
|
// Toast-Nachricht anzeigen
|
||||||
showToast(message, type = 'success') {
|
showToast(message, type = 'success') {
|
||||||
// Entferne bestehende Toasts
|
// Entferne bestehende Toasts
|
||||||
|
|||||||
57
styles.css
57
styles.css
@ -704,3 +704,60 @@ section h2 {
|
|||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Tea Timer Section */
|
||||||
|
.timer-section {
|
||||||
|
background: var(--card-background);
|
||||||
|
}
|
||||||
|
|
||||||
|
.timer-display {
|
||||||
|
font-size: 3.5rem;
|
||||||
|
font-weight: 700;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
text-align: center;
|
||||||
|
color: var(--primary-color);
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
letter-spacing: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timer-presets {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timer-custom {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timer-custom input[type="number"] {
|
||||||
|
width: 70px;
|
||||||
|
padding: 8px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
font-size: 1rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timer-controls {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
justify-content: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timer-controls .btn:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timer-status {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
min-height: 1.2em;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user