Compare commits

...

8 Commits

Author SHA1 Message Date
Kantine Wrapper
6ed0831f5d chore: update build artifacts for v1.4.30 2026-02-26 10:18:50 +01:00
Kantine Wrapper
ba75544f68 fix: session loss and order alarm rendering across unauthenticated sessions (v1.4.30) 2026-02-26 10:18:50 +01:00
Kantine Wrapper
7fdf7f6f3e chore: update build artifacts for v1.4.29 2026-02-26 10:01:39 +01:00
Kantine Wrapper
614f498d11 fix: defer favicon injection with setTimeout for htmlpreview compat (v1.4.29) 2026-02-26 10:01:17 +01:00
Kantine Wrapper
5f30696315 chore: update build artifacts for v1.4.28 2026-02-26 09:57:46 +01:00
Kantine Wrapper
cb5aa28f94 feat: custom favicon from user design, resized to 32x32 (v1.4.28) 2026-02-26 09:57:11 +01:00
Kantine Wrapper
bc1a91b7d7 chore: update build artifacts for v1.4.27 2026-02-26 09:50:46 +01:00
Kantine Wrapper
7d5beedfbb feat: build-time favicon injection from favicon.png via placeholder (v1.4.27) 2026-02-26 09:50:17 +01:00
10 changed files with 123 additions and 76 deletions

View File

@@ -26,13 +26,14 @@ if [ ! -f "$CSS_FILE" ]; then echo "ERROR: $CSS_FILE not found"; exit 1; fi
if [ ! -f "$JS_FILE" ]; then echo "ERROR: $JS_FILE not found"; exit 1; fi if [ ! -f "$JS_FILE" ]; then echo "ERROR: $JS_FILE not found"; exit 1; fi
if [ ! -f "$FAVICON_FILE" ]; then echo "ERROR: $FAVICON_FILE not found"; exit 1; fi if [ ! -f "$FAVICON_FILE" ]; then echo "ERROR: $FAVICON_FILE not found"; exit 1; fi
# Favicon URL (served from GitHub raw) # Generate favicon Base64 data URI from PNG
FAVICON_URL="https://raw.githubusercontent.com/TauNeutrino/kantine-overview/main/favicon.png" FAVICON_B64=$(base64 -w0 "$FAVICON_FILE")
FAVICON_URL="data:image/png;base64,${FAVICON_B64}"
CSS_CONTENT=$(cat "$CSS_FILE") CSS_CONTENT=$(cat "$CSS_FILE")
# Inject version into JS # Inject version and favicon into JS
JS_CONTENT=$(cat "$JS_FILE" | sed "s|{{VERSION}}|$VERSION|g") JS_CONTENT=$(cat "$JS_FILE" | sed "s|{{VERSION}}|$VERSION|g" | sed "s|{{FAVICON_DATA_URI}}|$FAVICON_URL|g")
# === 1. Build standalone HTML (for local testing/dev) === # === 1. Build standalone HTML (for local testing/dev) ===
cat > "$DIST_DIR/kantine-standalone.html" << HTMLEOF cat > "$DIST_DIR/kantine-standalone.html" << HTMLEOF
@@ -206,9 +207,9 @@ echo "document.getElementById('bookmarklet-link').href = " >> "$DIST_DIR/install
echo "$JS_CONTENT" | python3 -c " echo "$JS_CONTENT" | python3 -c "
import sys, json, urllib.parse import sys, json, urllib.parse
# 1. Read JS and Replace VERSION # 1. Read JS and Replace VERSION + Favicon
js_template = sys.stdin.read() js_template = sys.stdin.read()
js = js_template.replace('{{VERSION}}', '$VERSION') js = js_template.replace('{{VERSION}}', '$VERSION').replace('{{FAVICON_DATA_URI}}', '$FAVICON_URL')
# 2. Prepare CSS for injection via createElement('style') # 2. Prepare CSS for injection via createElement('style')
css = open('$CSS_FILE').read().replace('\n', ' ').replace(' ', ' ') css = open('$CSS_FILE').read().replace('\n', ' ').replace(' ', ' ')
@@ -242,13 +243,16 @@ $CHANGELOG_HTML
EOF EOF
cat >> "$DIST_DIR/install.html" << INSTALLEOF cat >> "$DIST_DIR/install.html" << INSTALLEOF
// Dynamic favicon injection (overrides proxy defaults like htmlpreview.github.io) // Dynamic favicon injection — setTimeout ensures it runs AFTER
document.querySelectorAll('link[rel*="icon"]').forEach(function(el) { el.remove(); }); // htmlpreview.github.io's document.write() processing completes
var fi = document.createElement('link'); setTimeout(function() {
fi.rel = 'icon'; document.querySelectorAll('link[rel*="icon"]').forEach(function(el) { el.remove(); });
fi.type = 'image/png'; var fi = document.createElement('link');
fi.href = '$FAVICON_URL'; fi.rel = 'icon';
document.head.appendChild(fi); fi.type = 'image/png';
fi.href = '$FAVICON_URL';
document.head.appendChild(fi);
}, 0);
document.getElementById('bookmarklet-link').textContent = 'Kantine $VERSION'; document.getElementById('bookmarklet-link').textContent = 'Kantine $VERSION';
</script> </script>
</body> </body>

View File

@@ -1,3 +1,16 @@
## v1.4.30
- 🐛 **Bugfix**: Login-Sitzung (`authToken` etc.) wird nun in der `localStorage` statt `sessionStorage` gespeichert, wodurch die Anmeldung beim Öffnen von Bookmarklets in neuen Tabs/Fenstern erhalten bleibt.
- 🐛 **Bugfix**: Bestell-Erinnerungscountdown und Alarm-Notifications erscheinen nun nur noch für angemeldete Nutzer.
## v1.4.29
- 🐛 **Bugfix**: Favicon-Injection in `install.html` mit `setTimeout(0)` verzögert, sodass sie nach dem `document.write()` von htmlpreview.github.io läuft. Chrome erkennt Favicon-Änderungen erst im nächsten Event-Loop-Tick.
## v1.4.28
- 🎨 **Favicon**: Eigenes Favicon-Design aus `favicon_base.png` (2048x2048) auf 32x32 skaliert. Wird beim Build automatisch als PNG-Data-URI in Bookmarklet und Installer injiziert.
## v1.4.27
- 🔧 **Build**: Favicon wird jetzt sauber aus `favicon.png` per Build-Script als PNG-Base64-Data-URI generiert und über `{{FAVICON_DATA_URI}}` Platzhalter in `kantine.js` + `install.html` injiziert. Funktioniert auf allen Browsern und Proxy-Diensten.
## v1.4.26 ## v1.4.26
- 🎨 **Favicon**: Von SVG-Base64 auf PNG-Datei (`favicon.png`) umgestellt, verlinkt via raw.githubusercontent.com. Funktioniert zuverlässig auf allen Browsern und Proxy-Diensten (htmlpreview.github.io). - 🎨 **Favicon**: Von SVG-Base64 auf PNG-Datei (`favicon.png`) umgestellt, verlinkt via raw.githubusercontent.com. Funktioniert zuverlässig auf allen Browsern und Proxy-Diensten (htmlpreview.github.io).

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

48
dist/install.html vendored

File diff suppressed because one or more lines are too long

View File

@@ -1979,8 +1979,8 @@ body {
let currentWeekNumber = getISOWeek(new Date()); let currentWeekNumber = getISOWeek(new Date());
let currentYear = new Date().getFullYear(); let currentYear = new Date().getFullYear();
let displayMode = 'this-week'; let displayMode = 'this-week';
let authToken = sessionStorage.getItem('kantine_authToken'); let authToken = localStorage.getItem('kantine_authToken');
let currentUser = sessionStorage.getItem('kantine_currentUser'); let currentUser = localStorage.getItem('kantine_currentUser');
let orderMap = new Map(); let orderMap = new Map();
let userFlags = new Set(JSON.parse(localStorage.getItem('kantine_flags') || '[]')); let userFlags = new Set(JSON.parse(localStorage.getItem('kantine_flags') || '[]'));
let pollIntervalId = null; let pollIntervalId = null;
@@ -2007,7 +2007,7 @@ body {
const favicon = document.createElement('link'); const favicon = document.createElement('link');
favicon.rel = 'icon'; favicon.rel = 'icon';
favicon.type = 'image/png'; favicon.type = 'image/png';
favicon.href = 'https://raw.githubusercontent.com/TauNeutrino/kantine-overview/main/favicon.png'; favicon.href = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAIwUlEQVR4nL2XeZBVxRXGf933vjePASKGRGUCmGKRlCZiSqNYLkW0ikQjkTGYFEJprKgpd6IxpiylCiRqISTBgBhZTOKKxgWSMowsQRatGgUBkWWGdQYcRSTIMvPeu9395Y97580bk0pV/kj6Vde9r2/3Od3nfN/pc4z3ZWGEJMDQ2Uz2KgQCYwygdEwQ2QiIcb6YfevejEnngU3XGYGq5wmwWNGpvPpDOibRbZEEIQhjYvbt3cOC2TOJowIhhIpSUzW3S57pFFuRbzAYI2zXabtOmL6b7Jetz6wQQsCaiFmPzeInt02kdU8zUZQnhFDRYYzJrNLZAVkwVMaFQUrtkwpHVSfoskjqgnTU+0AcF9jTvI0nnpwPwC/vuRdrosxaaU+tJ1CnJUMqp8rCkFoN54tyoSjni3K+lL5X/hflXCkd9yWVyiVJ0jVjrxKgfE1eBrRqeYMkqVQ+LqmsEMryIX0Gn/VQUnddRTmfqGsDVYqcK3fvPlGpVJQkrV2xVAYUxbFyuViAzvvmcLmkqMQV9Y/2IyomHSq5DnUk7SomHVlvz+QX5Xw57S6RcaEoumHQYEyEFKiCFCFAZA0XjRjBW++uI87FeO+JogiX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+7NGIO1tqscEwSFytpKq+Sa3Z/WWoIPDKzrx1PPPoPxvihrc1UrLf+bVp2SAfI45zEulKQQqo7dGSA7t159DEgrmqo7vVvRWcnusrG0BlR1JdRZ9tn0SorJUu/O+6BLSSq4y4JdjqlMM6oqOE3XWLeNBYyp+p4lwEbpxqqS0v+ifV7ev0z4TyiqnmX5J77N5NA1WjeLAAAAAElFTkSuQmCC';
document.head.appendChild(favicon); document.head.appendChild(favicon);
// Inject Google Fonts if not already present // Inject Google Fonts if not already present
@@ -2031,7 +2031,7 @@ body {
<div class="brand"> <div class="brand">
<span class="material-icons-round logo-icon">restaurant_menu</span> <span class="material-icons-round logo-icon">restaurant_menu</span>
<div class="header-left"> <div class="header-left">
<h1>Kantinen Übersicht <small class="version-tag" style="font-size: 0.6em; opacity: 0.7; font-weight: 400; cursor: pointer;" title="Klick für Versionsmenü">v1.4.26</small></h1> <h1>Kantinen Übersicht <small class="version-tag" style="font-size: 0.6em; opacity: 0.7; font-weight: 400; cursor: pointer;" title="Klick für Versionsmenü">v1.4.30</small></h1>
<div id="last-updated-subtitle" class="subtitle"></div> <div id="last-updated-subtitle" class="subtitle"></div>
</div> </div>
<div class="nav-group" style="margin-left: 1rem;"> <div class="nav-group" style="margin-left: 1rem;">
@@ -2173,7 +2173,7 @@ body {
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div style="margin-bottom: 1rem;"> <div style="margin-bottom: 1rem;">
<strong>Aktuell:</strong> <span id="version-current">v1.4.26</span> <strong>Aktuell:</strong> <span id="version-current">v1.4.30</span>
</div> </div>
<div class="dev-toggle"> <div class="dev-toggle">
<label style="display:flex;align-items:center;gap:8px;cursor:pointer;"> <label style="display:flex;align-items:center;gap:8px;cursor:pointer;">
@@ -2295,7 +2295,6 @@ body {
btnClearCache.addEventListener('click', () => { btnClearCache.addEventListener('click', () => {
if (confirm('Möchtest du wirklich alle lokalen Daten (inkl. Login-Session, Cache und Einstellungen) löschen? Die Seite wird danach neu geladen.')) { if (confirm('Möchtest du wirklich alle lokalen Daten (inkl. Login-Session, Cache und Einstellungen) löschen? Die Seite wird danach neu geladen.')) {
localStorage.clear(); localStorage.clear();
sessionStorage.clear();
window.location.reload(); window.location.reload();
} }
}); });
@@ -2409,8 +2408,8 @@ body {
if (response.ok) { if (response.ok) {
authToken = data.key; authToken = data.key;
currentUser = employeeId; currentUser = employeeId;
sessionStorage.setItem('kantine_authToken', data.key); localStorage.setItem('kantine_authToken', data.key);
sessionStorage.setItem('kantine_currentUser', employeeId); localStorage.setItem('kantine_currentUser', employeeId);
// Fetch user name // Fetch user name
try { try {
@@ -2419,8 +2418,8 @@ body {
}); });
if (userResp.ok) { if (userResp.ok) {
const userData = await userResp.json(); const userData = await userResp.json();
if (userData.first_name) sessionStorage.setItem('kantine_firstName', userData.first_name); if (userData.first_name) localStorage.setItem('kantine_firstName', userData.first_name);
if (userData.last_name) sessionStorage.setItem('kantine_lastName', userData.last_name); if (userData.last_name) localStorage.setItem('kantine_lastName', userData.last_name);
} }
} catch (err) { } catch (err) {
console.error('Failed to fetch user info:', err); console.error('Failed to fetch user info:', err);
@@ -2450,10 +2449,10 @@ body {
// Logout // Logout
btnLogout.addEventListener('click', () => { btnLogout.addEventListener('click', () => {
sessionStorage.removeItem('kantine_authToken'); localStorage.removeItem('kantine_authToken');
sessionStorage.removeItem('kantine_currentUser'); localStorage.removeItem('kantine_currentUser');
sessionStorage.removeItem('kantine_firstName'); localStorage.removeItem('kantine_firstName');
sessionStorage.removeItem('kantine_lastName'); localStorage.removeItem('kantine_lastName');
authToken = null; authToken = null;
currentUser = null; currentUser = null;
orderMap = new Map(); orderMap = new Map();
@@ -2474,13 +2473,13 @@ body {
if (parsed.auth && parsed.auth.token) { if (parsed.auth && parsed.auth.token) {
console.log('Found existing Bessa session!'); console.log('Found existing Bessa session!');
authToken = parsed.auth.token; authToken = parsed.auth.token;
sessionStorage.setItem('kantine_authToken', authToken); localStorage.setItem('kantine_authToken', authToken);
if (parsed.auth.user) { if (parsed.auth.user) {
currentUser = parsed.auth.user.id || 'unknown'; currentUser = parsed.auth.user.id || 'unknown';
sessionStorage.setItem('kantine_currentUser', currentUser); localStorage.setItem('kantine_currentUser', currentUser);
if (parsed.auth.user.firstName) sessionStorage.setItem('kantine_firstName', parsed.auth.user.firstName); if (parsed.auth.user.firstName) localStorage.setItem('kantine_firstName', parsed.auth.user.firstName);
if (parsed.auth.user.lastName) sessionStorage.setItem('kantine_lastName', parsed.auth.user.lastName); if (parsed.auth.user.lastName) localStorage.setItem('kantine_lastName', parsed.auth.user.lastName);
} }
} }
} }
@@ -2489,9 +2488,9 @@ body {
} }
} }
authToken = sessionStorage.getItem('kantine_authToken'); authToken = localStorage.getItem('kantine_authToken');
currentUser = sessionStorage.getItem('kantine_currentUser'); currentUser = localStorage.getItem('kantine_currentUser');
const firstName = sessionStorage.getItem('kantine_firstName'); const firstName = localStorage.getItem('kantine_firstName');
const btnLoginOpen = document.getElementById('btn-login-open'); const btnLoginOpen = document.getElementById('btn-login-open');
const userInfo = document.getElementById('user-info'); const userInfo = document.getElementById('user-info');
const userIdDisplay = document.getElementById('user-id-display'); const userIdDisplay = document.getElementById('user-id-display');
@@ -4026,7 +4025,7 @@ body {
// Periodic update check (runs on init + every hour) // Periodic update check (runs on init + every hour)
async function checkForUpdates() { async function checkForUpdates() {
const currentVersion = 'v1.4.26'; const currentVersion = 'v1.4.30';
const devMode = localStorage.getItem('kantine_dev_mode') === 'true'; const devMode = localStorage.getItem('kantine_dev_mode') === 'true';
try { try {
@@ -4067,7 +4066,7 @@ body {
const modal = document.getElementById('version-modal'); const modal = document.getElementById('version-modal');
const container = document.getElementById('version-list-container'); const container = document.getElementById('version-list-container');
const devToggle = document.getElementById('dev-mode-toggle'); const devToggle = document.getElementById('dev-mode-toggle');
const currentVersion = 'v1.4.26'; const currentVersion = 'v1.4.30';
if (!modal) return; if (!modal) return;
modal.classList.remove('hidden'); modal.classList.remove('hidden');
@@ -4164,6 +4163,12 @@ body {
// === Order Countdown === // === Order Countdown ===
function updateCountdown() { function updateCountdown() {
// Only show order alarms for logged-in users
if (!authToken || !currentUser) {
removeCountdown();
return;
}
const now = new Date(); const now = new Date();
const currentDay = now.getDay(); const currentDay = now.getDay();
// Skip weekends (0=Sun, 6=Sat) // Skip weekends (0=Sun, 6=Sat)
@@ -4228,7 +4233,7 @@ body {
// Notification logic (One time) // Notification logic (One time)
const notifiedKey = `kantine_notified_${todayStr}`; const notifiedKey = `kantine_notified_${todayStr}`;
if (!sessionStorage.getItem(notifiedKey)) { if (!localStorage.getItem(notifiedKey)) {
if (Notification.permission === 'granted') { if (Notification.permission === 'granted') {
new Notification('Kantine: Bestellschluss naht!', { new Notification('Kantine: Bestellschluss naht!', {
body: 'Du hast heute noch nichts bestellt. Nur noch 1 Stunde!', body: 'Du hast heute noch nichts bestellt. Nur noch 1 Stunde!',
@@ -4237,7 +4242,7 @@ body {
} else if (Notification.permission === 'default') { } else if (Notification.permission === 'default') {
Notification.requestPermission(); Notification.requestPermission();
} }
sessionStorage.setItem(notifiedKey, 'true'); localStorage.setItem(notifiedKey, 'true');
} }
} else { } else {
countdownEl.classList.remove('urgent'); countdownEl.classList.remove('urgent');

Binary file not shown.

Before

Width:  |  Height:  |  Size: 832 B

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
favicon_base.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 MiB

View File

@@ -29,8 +29,8 @@
let currentWeekNumber = getISOWeek(new Date()); let currentWeekNumber = getISOWeek(new Date());
let currentYear = new Date().getFullYear(); let currentYear = new Date().getFullYear();
let displayMode = 'this-week'; let displayMode = 'this-week';
let authToken = sessionStorage.getItem('kantine_authToken'); let authToken = localStorage.getItem('kantine_authToken');
let currentUser = sessionStorage.getItem('kantine_currentUser'); let currentUser = localStorage.getItem('kantine_currentUser');
let orderMap = new Map(); let orderMap = new Map();
let userFlags = new Set(JSON.parse(localStorage.getItem('kantine_flags') || '[]')); let userFlags = new Set(JSON.parse(localStorage.getItem('kantine_flags') || '[]'));
let pollIntervalId = null; let pollIntervalId = null;
@@ -57,7 +57,7 @@
const favicon = document.createElement('link'); const favicon = document.createElement('link');
favicon.rel = 'icon'; favicon.rel = 'icon';
favicon.type = 'image/png'; favicon.type = 'image/png';
favicon.href = 'https://raw.githubusercontent.com/TauNeutrino/kantine-overview/main/favicon.png'; favicon.href = '{{FAVICON_DATA_URI}}';
document.head.appendChild(favicon); document.head.appendChild(favicon);
// Inject Google Fonts if not already present // Inject Google Fonts if not already present
@@ -345,7 +345,6 @@
btnClearCache.addEventListener('click', () => { btnClearCache.addEventListener('click', () => {
if (confirm('Möchtest du wirklich alle lokalen Daten (inkl. Login-Session, Cache und Einstellungen) löschen? Die Seite wird danach neu geladen.')) { if (confirm('Möchtest du wirklich alle lokalen Daten (inkl. Login-Session, Cache und Einstellungen) löschen? Die Seite wird danach neu geladen.')) {
localStorage.clear(); localStorage.clear();
sessionStorage.clear();
window.location.reload(); window.location.reload();
} }
}); });
@@ -459,8 +458,8 @@
if (response.ok) { if (response.ok) {
authToken = data.key; authToken = data.key;
currentUser = employeeId; currentUser = employeeId;
sessionStorage.setItem('kantine_authToken', data.key); localStorage.setItem('kantine_authToken', data.key);
sessionStorage.setItem('kantine_currentUser', employeeId); localStorage.setItem('kantine_currentUser', employeeId);
// Fetch user name // Fetch user name
try { try {
@@ -469,8 +468,8 @@
}); });
if (userResp.ok) { if (userResp.ok) {
const userData = await userResp.json(); const userData = await userResp.json();
if (userData.first_name) sessionStorage.setItem('kantine_firstName', userData.first_name); if (userData.first_name) localStorage.setItem('kantine_firstName', userData.first_name);
if (userData.last_name) sessionStorage.setItem('kantine_lastName', userData.last_name); if (userData.last_name) localStorage.setItem('kantine_lastName', userData.last_name);
} }
} catch (err) { } catch (err) {
console.error('Failed to fetch user info:', err); console.error('Failed to fetch user info:', err);
@@ -500,10 +499,10 @@
// Logout // Logout
btnLogout.addEventListener('click', () => { btnLogout.addEventListener('click', () => {
sessionStorage.removeItem('kantine_authToken'); localStorage.removeItem('kantine_authToken');
sessionStorage.removeItem('kantine_currentUser'); localStorage.removeItem('kantine_currentUser');
sessionStorage.removeItem('kantine_firstName'); localStorage.removeItem('kantine_firstName');
sessionStorage.removeItem('kantine_lastName'); localStorage.removeItem('kantine_lastName');
authToken = null; authToken = null;
currentUser = null; currentUser = null;
orderMap = new Map(); orderMap = new Map();
@@ -524,13 +523,13 @@
if (parsed.auth && parsed.auth.token) { if (parsed.auth && parsed.auth.token) {
console.log('Found existing Bessa session!'); console.log('Found existing Bessa session!');
authToken = parsed.auth.token; authToken = parsed.auth.token;
sessionStorage.setItem('kantine_authToken', authToken); localStorage.setItem('kantine_authToken', authToken);
if (parsed.auth.user) { if (parsed.auth.user) {
currentUser = parsed.auth.user.id || 'unknown'; currentUser = parsed.auth.user.id || 'unknown';
sessionStorage.setItem('kantine_currentUser', currentUser); localStorage.setItem('kantine_currentUser', currentUser);
if (parsed.auth.user.firstName) sessionStorage.setItem('kantine_firstName', parsed.auth.user.firstName); if (parsed.auth.user.firstName) localStorage.setItem('kantine_firstName', parsed.auth.user.firstName);
if (parsed.auth.user.lastName) sessionStorage.setItem('kantine_lastName', parsed.auth.user.lastName); if (parsed.auth.user.lastName) localStorage.setItem('kantine_lastName', parsed.auth.user.lastName);
} }
} }
} }
@@ -539,9 +538,9 @@
} }
} }
authToken = sessionStorage.getItem('kantine_authToken'); authToken = localStorage.getItem('kantine_authToken');
currentUser = sessionStorage.getItem('kantine_currentUser'); currentUser = localStorage.getItem('kantine_currentUser');
const firstName = sessionStorage.getItem('kantine_firstName'); const firstName = localStorage.getItem('kantine_firstName');
const btnLoginOpen = document.getElementById('btn-login-open'); const btnLoginOpen = document.getElementById('btn-login-open');
const userInfo = document.getElementById('user-info'); const userInfo = document.getElementById('user-info');
const userIdDisplay = document.getElementById('user-id-display'); const userIdDisplay = document.getElementById('user-id-display');
@@ -2214,6 +2213,12 @@
// === Order Countdown === // === Order Countdown ===
function updateCountdown() { function updateCountdown() {
// Only show order alarms for logged-in users
if (!authToken || !currentUser) {
removeCountdown();
return;
}
const now = new Date(); const now = new Date();
const currentDay = now.getDay(); const currentDay = now.getDay();
// Skip weekends (0=Sun, 6=Sat) // Skip weekends (0=Sun, 6=Sat)
@@ -2278,7 +2283,7 @@
// Notification logic (One time) // Notification logic (One time)
const notifiedKey = `kantine_notified_${todayStr}`; const notifiedKey = `kantine_notified_${todayStr}`;
if (!sessionStorage.getItem(notifiedKey)) { if (!localStorage.getItem(notifiedKey)) {
if (Notification.permission === 'granted') { if (Notification.permission === 'granted') {
new Notification('Kantine: Bestellschluss naht!', { new Notification('Kantine: Bestellschluss naht!', {
body: 'Du hast heute noch nichts bestellt. Nur noch 1 Stunde!', body: 'Du hast heute noch nichts bestellt. Nur noch 1 Stunde!',
@@ -2287,7 +2292,7 @@
} else if (Notification.permission === 'default') { } else if (Notification.permission === 'default') {
Notification.requestPermission(); Notification.requestPermission();
} }
sessionStorage.setItem(notifiedKey, 'true'); localStorage.setItem(notifiedKey, 'true');
} }
} else { } else {
countdownEl.classList.remove('urgent'); countdownEl.classList.remove('urgent');

View File

@@ -1 +1 @@
v1.4.26 v1.4.30