Compare commits
10 Commits
v1.4.26
...
984a897f73
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
984a897f73 | ||
|
|
ae54d97d96 | ||
|
|
6ed0831f5d | ||
|
|
ba75544f68 | ||
|
|
7fdf7f6f3e | ||
|
|
614f498d11 | ||
|
|
5f30696315 | ||
|
|
cb5aa28f94 | ||
|
|
bc1a91b7d7 | ||
|
|
7d5beedfbb |
@@ -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 "$FAVICON_FILE" ]; then echo "ERROR: $FAVICON_FILE not found"; exit 1; fi
|
||||
|
||||
# Favicon URL (served from GitHub raw)
|
||||
FAVICON_URL="https://raw.githubusercontent.com/TauNeutrino/kantine-overview/main/favicon.png"
|
||||
# Generate favicon Base64 data URI from PNG
|
||||
FAVICON_B64=$(base64 -w0 "$FAVICON_FILE")
|
||||
FAVICON_URL="data:image/png;base64,${FAVICON_B64}"
|
||||
|
||||
CSS_CONTENT=$(cat "$CSS_FILE")
|
||||
|
||||
# Inject version into JS
|
||||
JS_CONTENT=$(cat "$JS_FILE" | sed "s|{{VERSION}}|$VERSION|g")
|
||||
# Inject version and favicon into JS
|
||||
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) ===
|
||||
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 "
|
||||
import sys, json, urllib.parse
|
||||
|
||||
# 1. Read JS and Replace VERSION
|
||||
# 1. Read JS and Replace VERSION + Favicon
|
||||
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')
|
||||
css = open('$CSS_FILE').read().replace('\n', ' ').replace(' ', ' ')
|
||||
@@ -242,13 +243,16 @@ $CHANGELOG_HTML
|
||||
EOF
|
||||
|
||||
cat >> "$DIST_DIR/install.html" << INSTALLEOF
|
||||
// Dynamic favicon injection (overrides proxy defaults like htmlpreview.github.io)
|
||||
document.querySelectorAll('link[rel*="icon"]').forEach(function(el) { el.remove(); });
|
||||
var fi = document.createElement('link');
|
||||
fi.rel = 'icon';
|
||||
fi.type = 'image/png';
|
||||
fi.href = '$FAVICON_URL';
|
||||
document.head.appendChild(fi);
|
||||
// Dynamic favicon injection — setTimeout ensures it runs AFTER
|
||||
// htmlpreview.github.io's document.write() processing completes
|
||||
setTimeout(function() {
|
||||
document.querySelectorAll('link[rel*="icon"]').forEach(function(el) { el.remove(); });
|
||||
var fi = document.createElement('link');
|
||||
fi.rel = 'icon';
|
||||
fi.type = 'image/png';
|
||||
fi.href = '$FAVICON_URL';
|
||||
document.head.appendChild(fi);
|
||||
}, 0);
|
||||
document.getElementById('bookmarklet-link').textContent = 'Kantine $VERSION';
|
||||
</script>
|
||||
</body>
|
||||
|
||||
16
changelog.md
16
changelog.md
@@ -1,3 +1,19 @@
|
||||
## v1.4.31
|
||||
- 🐛 **Bugfix**: Der "Lokalen Cache leeren"-Button löscht nun gezielt nur noch Kantine-spezifische Daten (`kantine_` Präfix). Bisher wurde die gesamte `localStorage` geleert, was dazu führte, dass man auch aus der zugrundeliegenden bessa.app-Sitzung ausgeloggt wurde.
|
||||
|
||||
## 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
|
||||
- 🎨 **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).
|
||||
|
||||
|
||||
2
dist/bookmarklet-payload.js
vendored
2
dist/bookmarklet-payload.js
vendored
File diff suppressed because one or more lines are too long
2
dist/bookmarklet.txt
vendored
2
dist/bookmarklet.txt
vendored
File diff suppressed because one or more lines are too long
52
dist/install.html
vendored
52
dist/install.html
vendored
File diff suppressed because one or more lines are too long
62
dist/kantine-standalone.html
vendored
62
dist/kantine-standalone.html
vendored
@@ -1979,8 +1979,8 @@ body {
|
||||
let currentWeekNumber = getISOWeek(new Date());
|
||||
let currentYear = new Date().getFullYear();
|
||||
let displayMode = 'this-week';
|
||||
let authToken = sessionStorage.getItem('kantine_authToken');
|
||||
let currentUser = sessionStorage.getItem('kantine_currentUser');
|
||||
let authToken = localStorage.getItem('kantine_authToken');
|
||||
let currentUser = localStorage.getItem('kantine_currentUser');
|
||||
let orderMap = new Map();
|
||||
let userFlags = new Set(JSON.parse(localStorage.getItem('kantine_flags') || '[]'));
|
||||
let pollIntervalId = null;
|
||||
@@ -2007,7 +2007,7 @@ body {
|
||||
const favicon = document.createElement('link');
|
||||
favicon.rel = 'icon';
|
||||
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+JogiXOObOnskNt9zBou2buWvtanrm8ikTAC/RMxezePQYTunZC+eFNQYh4k6QIpsBJUOpsUgpLhLnqckXeO4P8zPlObx36daCsNYyafJU6q++miuHncGeY8eYuGolPeI8BkgU6JWPcfIZLV2GCYutOmQnglAGJEhpF0cxxz47zAOTJhPnYiJrsTbCGosxhnxNDW0HPuHhKV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nmX5J77N5NA1WjeLAAAAAElFTkSuQmCC';
|
||||
document.head.appendChild(favicon);
|
||||
|
||||
// Inject Google Fonts if not already present
|
||||
@@ -2031,7 +2031,7 @@ body {
|
||||
<div class="brand">
|
||||
<span class="material-icons-round logo-icon">restaurant_menu</span>
|
||||
<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.31</small></h1>
|
||||
<div id="last-updated-subtitle" class="subtitle"></div>
|
||||
</div>
|
||||
<div class="nav-group" style="margin-left: 1rem;">
|
||||
@@ -2173,7 +2173,7 @@ body {
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<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.31</span>
|
||||
</div>
|
||||
<div class="dev-toggle">
|
||||
<label style="display:flex;align-items:center;gap:8px;cursor:pointer;">
|
||||
@@ -2294,8 +2294,12 @@ body {
|
||||
if (btnClearCache) {
|
||||
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.')) {
|
||||
localStorage.clear();
|
||||
sessionStorage.clear();
|
||||
// Only clear our own keys so we don't destroy the host app's (Bessa's) session
|
||||
Object.keys(localStorage).forEach(key => {
|
||||
if (key.startsWith('kantine_')) {
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
});
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
@@ -2409,8 +2413,8 @@ body {
|
||||
if (response.ok) {
|
||||
authToken = data.key;
|
||||
currentUser = employeeId;
|
||||
sessionStorage.setItem('kantine_authToken', data.key);
|
||||
sessionStorage.setItem('kantine_currentUser', employeeId);
|
||||
localStorage.setItem('kantine_authToken', data.key);
|
||||
localStorage.setItem('kantine_currentUser', employeeId);
|
||||
|
||||
// Fetch user name
|
||||
try {
|
||||
@@ -2419,8 +2423,8 @@ body {
|
||||
});
|
||||
if (userResp.ok) {
|
||||
const userData = await userResp.json();
|
||||
if (userData.first_name) sessionStorage.setItem('kantine_firstName', userData.first_name);
|
||||
if (userData.last_name) sessionStorage.setItem('kantine_lastName', userData.last_name);
|
||||
if (userData.first_name) localStorage.setItem('kantine_firstName', userData.first_name);
|
||||
if (userData.last_name) localStorage.setItem('kantine_lastName', userData.last_name);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch user info:', err);
|
||||
@@ -2450,10 +2454,10 @@ body {
|
||||
|
||||
// Logout
|
||||
btnLogout.addEventListener('click', () => {
|
||||
sessionStorage.removeItem('kantine_authToken');
|
||||
sessionStorage.removeItem('kantine_currentUser');
|
||||
sessionStorage.removeItem('kantine_firstName');
|
||||
sessionStorage.removeItem('kantine_lastName');
|
||||
localStorage.removeItem('kantine_authToken');
|
||||
localStorage.removeItem('kantine_currentUser');
|
||||
localStorage.removeItem('kantine_firstName');
|
||||
localStorage.removeItem('kantine_lastName');
|
||||
authToken = null;
|
||||
currentUser = null;
|
||||
orderMap = new Map();
|
||||
@@ -2474,13 +2478,13 @@ body {
|
||||
if (parsed.auth && parsed.auth.token) {
|
||||
console.log('Found existing Bessa session!');
|
||||
authToken = parsed.auth.token;
|
||||
sessionStorage.setItem('kantine_authToken', authToken);
|
||||
localStorage.setItem('kantine_authToken', authToken);
|
||||
|
||||
if (parsed.auth.user) {
|
||||
currentUser = parsed.auth.user.id || 'unknown';
|
||||
sessionStorage.setItem('kantine_currentUser', currentUser);
|
||||
if (parsed.auth.user.firstName) sessionStorage.setItem('kantine_firstName', parsed.auth.user.firstName);
|
||||
if (parsed.auth.user.lastName) sessionStorage.setItem('kantine_lastName', parsed.auth.user.lastName);
|
||||
localStorage.setItem('kantine_currentUser', currentUser);
|
||||
if (parsed.auth.user.firstName) localStorage.setItem('kantine_firstName', parsed.auth.user.firstName);
|
||||
if (parsed.auth.user.lastName) localStorage.setItem('kantine_lastName', parsed.auth.user.lastName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2489,9 +2493,9 @@ body {
|
||||
}
|
||||
}
|
||||
|
||||
authToken = sessionStorage.getItem('kantine_authToken');
|
||||
currentUser = sessionStorage.getItem('kantine_currentUser');
|
||||
const firstName = sessionStorage.getItem('kantine_firstName');
|
||||
authToken = localStorage.getItem('kantine_authToken');
|
||||
currentUser = localStorage.getItem('kantine_currentUser');
|
||||
const firstName = localStorage.getItem('kantine_firstName');
|
||||
const btnLoginOpen = document.getElementById('btn-login-open');
|
||||
const userInfo = document.getElementById('user-info');
|
||||
const userIdDisplay = document.getElementById('user-id-display');
|
||||
@@ -4026,7 +4030,7 @@ body {
|
||||
|
||||
// Periodic update check (runs on init + every hour)
|
||||
async function checkForUpdates() {
|
||||
const currentVersion = 'v1.4.26';
|
||||
const currentVersion = 'v1.4.31';
|
||||
const devMode = localStorage.getItem('kantine_dev_mode') === 'true';
|
||||
|
||||
try {
|
||||
@@ -4067,7 +4071,7 @@ body {
|
||||
const modal = document.getElementById('version-modal');
|
||||
const container = document.getElementById('version-list-container');
|
||||
const devToggle = document.getElementById('dev-mode-toggle');
|
||||
const currentVersion = 'v1.4.26';
|
||||
const currentVersion = 'v1.4.31';
|
||||
|
||||
if (!modal) return;
|
||||
modal.classList.remove('hidden');
|
||||
@@ -4164,6 +4168,12 @@ body {
|
||||
|
||||
// === Order Countdown ===
|
||||
function updateCountdown() {
|
||||
// Only show order alarms for logged-in users
|
||||
if (!authToken || !currentUser) {
|
||||
removeCountdown();
|
||||
return;
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
const currentDay = now.getDay();
|
||||
// Skip weekends (0=Sun, 6=Sat)
|
||||
@@ -4228,7 +4238,7 @@ body {
|
||||
|
||||
// Notification logic (One time)
|
||||
const notifiedKey = `kantine_notified_${todayStr}`;
|
||||
if (!sessionStorage.getItem(notifiedKey)) {
|
||||
if (!localStorage.getItem(notifiedKey)) {
|
||||
if (Notification.permission === 'granted') {
|
||||
new Notification('Kantine: Bestellschluss naht!', {
|
||||
body: 'Du hast heute noch nichts bestellt. Nur noch 1 Stunde!',
|
||||
@@ -4237,7 +4247,7 @@ body {
|
||||
} else if (Notification.permission === 'default') {
|
||||
Notification.requestPermission();
|
||||
}
|
||||
sessionStorage.setItem(notifiedKey, 'true');
|
||||
localStorage.setItem(notifiedKey, 'true');
|
||||
}
|
||||
} else {
|
||||
countdownEl.classList.remove('urgent');
|
||||
|
||||
BIN
favicon.png
BIN
favicon.png
Binary file not shown.
|
Before Width: | Height: | Size: 832 B After Width: | Height: | Size: 2.2 KiB |
BIN
favicon_base.png
Executable file
BIN
favicon_base.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 5.5 MiB |
54
kantine.js
54
kantine.js
@@ -29,8 +29,8 @@
|
||||
let currentWeekNumber = getISOWeek(new Date());
|
||||
let currentYear = new Date().getFullYear();
|
||||
let displayMode = 'this-week';
|
||||
let authToken = sessionStorage.getItem('kantine_authToken');
|
||||
let currentUser = sessionStorage.getItem('kantine_currentUser');
|
||||
let authToken = localStorage.getItem('kantine_authToken');
|
||||
let currentUser = localStorage.getItem('kantine_currentUser');
|
||||
let orderMap = new Map();
|
||||
let userFlags = new Set(JSON.parse(localStorage.getItem('kantine_flags') || '[]'));
|
||||
let pollIntervalId = null;
|
||||
@@ -57,7 +57,7 @@
|
||||
const favicon = document.createElement('link');
|
||||
favicon.rel = 'icon';
|
||||
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);
|
||||
|
||||
// Inject Google Fonts if not already present
|
||||
@@ -344,8 +344,12 @@
|
||||
if (btnClearCache) {
|
||||
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.')) {
|
||||
localStorage.clear();
|
||||
sessionStorage.clear();
|
||||
// Only clear our own keys so we don't destroy the host app's (Bessa's) session
|
||||
Object.keys(localStorage).forEach(key => {
|
||||
if (key.startsWith('kantine_')) {
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
});
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
@@ -459,8 +463,8 @@
|
||||
if (response.ok) {
|
||||
authToken = data.key;
|
||||
currentUser = employeeId;
|
||||
sessionStorage.setItem('kantine_authToken', data.key);
|
||||
sessionStorage.setItem('kantine_currentUser', employeeId);
|
||||
localStorage.setItem('kantine_authToken', data.key);
|
||||
localStorage.setItem('kantine_currentUser', employeeId);
|
||||
|
||||
// Fetch user name
|
||||
try {
|
||||
@@ -469,8 +473,8 @@
|
||||
});
|
||||
if (userResp.ok) {
|
||||
const userData = await userResp.json();
|
||||
if (userData.first_name) sessionStorage.setItem('kantine_firstName', userData.first_name);
|
||||
if (userData.last_name) sessionStorage.setItem('kantine_lastName', userData.last_name);
|
||||
if (userData.first_name) localStorage.setItem('kantine_firstName', userData.first_name);
|
||||
if (userData.last_name) localStorage.setItem('kantine_lastName', userData.last_name);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch user info:', err);
|
||||
@@ -500,10 +504,10 @@
|
||||
|
||||
// Logout
|
||||
btnLogout.addEventListener('click', () => {
|
||||
sessionStorage.removeItem('kantine_authToken');
|
||||
sessionStorage.removeItem('kantine_currentUser');
|
||||
sessionStorage.removeItem('kantine_firstName');
|
||||
sessionStorage.removeItem('kantine_lastName');
|
||||
localStorage.removeItem('kantine_authToken');
|
||||
localStorage.removeItem('kantine_currentUser');
|
||||
localStorage.removeItem('kantine_firstName');
|
||||
localStorage.removeItem('kantine_lastName');
|
||||
authToken = null;
|
||||
currentUser = null;
|
||||
orderMap = new Map();
|
||||
@@ -524,13 +528,13 @@
|
||||
if (parsed.auth && parsed.auth.token) {
|
||||
console.log('Found existing Bessa session!');
|
||||
authToken = parsed.auth.token;
|
||||
sessionStorage.setItem('kantine_authToken', authToken);
|
||||
localStorage.setItem('kantine_authToken', authToken);
|
||||
|
||||
if (parsed.auth.user) {
|
||||
currentUser = parsed.auth.user.id || 'unknown';
|
||||
sessionStorage.setItem('kantine_currentUser', currentUser);
|
||||
if (parsed.auth.user.firstName) sessionStorage.setItem('kantine_firstName', parsed.auth.user.firstName);
|
||||
if (parsed.auth.user.lastName) sessionStorage.setItem('kantine_lastName', parsed.auth.user.lastName);
|
||||
localStorage.setItem('kantine_currentUser', currentUser);
|
||||
if (parsed.auth.user.firstName) localStorage.setItem('kantine_firstName', parsed.auth.user.firstName);
|
||||
if (parsed.auth.user.lastName) localStorage.setItem('kantine_lastName', parsed.auth.user.lastName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -539,9 +543,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
authToken = sessionStorage.getItem('kantine_authToken');
|
||||
currentUser = sessionStorage.getItem('kantine_currentUser');
|
||||
const firstName = sessionStorage.getItem('kantine_firstName');
|
||||
authToken = localStorage.getItem('kantine_authToken');
|
||||
currentUser = localStorage.getItem('kantine_currentUser');
|
||||
const firstName = localStorage.getItem('kantine_firstName');
|
||||
const btnLoginOpen = document.getElementById('btn-login-open');
|
||||
const userInfo = document.getElementById('user-info');
|
||||
const userIdDisplay = document.getElementById('user-id-display');
|
||||
@@ -2214,6 +2218,12 @@
|
||||
|
||||
// === Order Countdown ===
|
||||
function updateCountdown() {
|
||||
// Only show order alarms for logged-in users
|
||||
if (!authToken || !currentUser) {
|
||||
removeCountdown();
|
||||
return;
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
const currentDay = now.getDay();
|
||||
// Skip weekends (0=Sun, 6=Sat)
|
||||
@@ -2278,7 +2288,7 @@
|
||||
|
||||
// Notification logic (One time)
|
||||
const notifiedKey = `kantine_notified_${todayStr}`;
|
||||
if (!sessionStorage.getItem(notifiedKey)) {
|
||||
if (!localStorage.getItem(notifiedKey)) {
|
||||
if (Notification.permission === 'granted') {
|
||||
new Notification('Kantine: Bestellschluss naht!', {
|
||||
body: 'Du hast heute noch nichts bestellt. Nur noch 1 Stunde!',
|
||||
@@ -2287,7 +2297,7 @@
|
||||
} else if (Notification.permission === 'default') {
|
||||
Notification.requestPermission();
|
||||
}
|
||||
sessionStorage.setItem(notifiedKey, 'true');
|
||||
localStorage.setItem(notifiedKey, 'true');
|
||||
}
|
||||
} else {
|
||||
countdownEl.classList.remove('urgent');
|
||||
|
||||
@@ -1 +1 @@
|
||||
v1.4.26
|
||||
v1.4.31
|
||||
|
||||
Reference in New Issue
Block a user