fix(core): resolve syntax errors in v1.1.0 preventing load (v1.1.1)
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
## v1.1.1 (2026-02-16)
|
||||||
|
- **Fix**: Kritischer Fehler behoben, der das Laden des Wrappers verhinderte. 🐛
|
||||||
|
|
||||||
## v1.1.0 (2026-02-16)
|
## v1.1.0 (2026-02-16)
|
||||||
- **Feature: Bestell-Countdown**: Zeigt 1 Stunde vor Bestellschluss einen roten Countdown an. ⏳
|
- **Feature: Bestell-Countdown**: Zeigt 1 Stunde vor Bestellschluss einen roten Countdown an. ⏳
|
||||||
- **Feature: Smart Highlights**: Markiere deine Lieblingsspeisen (z.B. "Schnitzel", "Vegetarisch"), damit sie leuchten. 🌟
|
- **Feature: Smart Highlights**: Markiere deine Lieblingsspeisen (z.B. "Schnitzel", "Vegetarisch"), damit sie leuchten. 🌟
|
||||||
|
|||||||
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
16
dist/install.html
vendored
16
dist/install.html
vendored
File diff suppressed because one or more lines are too long
163
dist/kantine-standalone.html
vendored
163
dist/kantine-standalone.html
vendored
@@ -1417,7 +1417,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 style="font-size: 0.6em; opacity: 0.7; font-weight: 400;">v1.1.0</small></h1>
|
<h1>Kantinen Übersicht <small style="font-size: 0.6em; opacity: 0.7; font-weight: 400;">v1.1.1</small></h1>
|
||||||
<div id="last-updated-subtitle" class="subtitle"></div>
|
<div id="last-updated-subtitle" class="subtitle"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -2002,7 +2002,6 @@ body {
|
|||||||
}
|
}
|
||||||
// Refresh menu data to update UI
|
// Refresh menu data to update UI
|
||||||
loadMenuDataFromAPI();
|
loadMenuDataFromAPI();
|
||||||
break; // One refresh is enough
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -2011,17 +2010,18 @@ body {
|
|||||||
await new Promise(r => setTimeout(r, 200));
|
await new Promise(r => setTimeout(r, 200));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// === Highlight Management ===
|
// === Highlight Management ===
|
||||||
let highlightTags = JSON.parse(localStorage.getItem('kantine_highlightTags') || '[]');
|
let highlightTags = JSON.parse(localStorage.getItem('kantine_highlightTags') || '[]');
|
||||||
|
|
||||||
function saveHighlightTags() {
|
function saveHighlightTags() {
|
||||||
localStorage.setItem('kantine_highlightTags', JSON.stringify(highlightTags));
|
localStorage.setItem('kantine_highlightTags', JSON.stringify(highlightTags));
|
||||||
renderVisibleWeeks(); // Refresh UI to apply changes
|
renderVisibleWeeks(); // Refresh UI to apply changes
|
||||||
updateNextWeekBadge();
|
updateNextWeekBadge();
|
||||||
}
|
}
|
||||||
|
|
||||||
function addHighlightTag(tag) {
|
function addHighlightTag(tag) {
|
||||||
tag = tag.trim().toLowerCase();
|
tag = tag.trim().toLowerCase();
|
||||||
if (tag && !highlightTags.includes(tag)) {
|
if (tag && !highlightTags.includes(tag)) {
|
||||||
highlightTags.push(tag);
|
highlightTags.push(tag);
|
||||||
@@ -2029,14 +2029,14 @@ body {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeHighlightTag(tag) {
|
function removeHighlightTag(tag) {
|
||||||
highlightTags = highlightTags.filter(t => t !== tag);
|
highlightTags = highlightTags.filter(t => t !== tag);
|
||||||
saveHighlightTags();
|
saveHighlightTags();
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderTagsList() {
|
function renderTagsList() {
|
||||||
const list = document.getElementById('tags-list');
|
const list = document.getElementById('tags-list');
|
||||||
list.innerHTML = '';
|
list.innerHTML = '';
|
||||||
highlightTags.forEach(tag => {
|
highlightTags.forEach(tag => {
|
||||||
@@ -2053,28 +2053,28 @@ body {
|
|||||||
renderTagsList();
|
renderTagsList();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkHighlight(text) {
|
function checkHighlight(text) {
|
||||||
if (!text) return false;
|
if (!text) return false;
|
||||||
text = text.toLowerCase();
|
text = text.toLowerCase();
|
||||||
return highlightTags.some(tag => text.includes(tag));
|
return highlightTags.some(tag => text.includes(tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Local Menu Cache (localStorage) ===
|
// === Local Menu Cache (localStorage) ===
|
||||||
const CACHE_KEY = 'kantine_menuCache';
|
const CACHE_KEY = 'kantine_menuCache';
|
||||||
const CACHE_TS_KEY = 'kantine_menuCacheTs';
|
const CACHE_TS_KEY = 'kantine_menuCacheTs';
|
||||||
|
|
||||||
function saveMenuCache() {
|
function saveMenuCache() {
|
||||||
try {
|
try {
|
||||||
localStorage.setItem(CACHE_KEY, JSON.stringify(allWeeks));
|
localStorage.setItem(CACHE_KEY, JSON.stringify(allWeeks));
|
||||||
localStorage.setItem(CACHE_TS_KEY, new Date().toISOString());
|
localStorage.setItem(CACHE_TS_KEY, new Date().toISOString());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('Failed to cache menu data:', e);
|
console.warn('Failed to cache menu data:', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadMenuCache() {
|
function loadMenuCache() {
|
||||||
try {
|
try {
|
||||||
const cached = localStorage.getItem(CACHE_KEY);
|
const cached = localStorage.getItem(CACHE_KEY);
|
||||||
const cachedTs = localStorage.getItem(CACHE_TS_KEY);
|
const cachedTs = localStorage.getItem(CACHE_TS_KEY);
|
||||||
@@ -2092,10 +2092,10 @@ body {
|
|||||||
console.warn('Failed to load cached menu:', e);
|
console.warn('Failed to load cached menu:', e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Menu Data Fetching (Direct from Bessa API) ===
|
// === Menu Data Fetching (Direct from Bessa API) ===
|
||||||
async function loadMenuDataFromAPI() {
|
async function loadMenuDataFromAPI() {
|
||||||
const loading = document.getElementById('loading');
|
const loading = document.getElementById('loading');
|
||||||
const progressModal = document.getElementById('progress-modal');
|
const progressModal = document.getElementById('progress-modal');
|
||||||
const progressFill = document.getElementById('progress-fill');
|
const progressFill = document.getElementById('progress-fill');
|
||||||
@@ -2288,10 +2288,10 @@ body {
|
|||||||
} finally {
|
} finally {
|
||||||
loading.classList.add('hidden');
|
loading.classList.add('hidden');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Last Updated Display ===
|
// === Last Updated Display ===
|
||||||
function updateLastUpdatedTime(isoTimestamp) {
|
function updateLastUpdatedTime(isoTimestamp) {
|
||||||
const subtitle = document.getElementById('last-updated-subtitle');
|
const subtitle = document.getElementById('last-updated-subtitle');
|
||||||
if (!isoTimestamp) return;
|
if (!isoTimestamp) return;
|
||||||
try {
|
try {
|
||||||
@@ -2302,10 +2302,10 @@ body {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
subtitle.textContent = '';
|
subtitle.textContent = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Toast Notification ===
|
// === Toast Notification ===
|
||||||
function showToast(message, type = 'info') {
|
function showToast(message, type = 'info') {
|
||||||
let container = document.getElementById('toast-container');
|
let container = document.getElementById('toast-container');
|
||||||
if (!container) {
|
if (!container) {
|
||||||
container = document.createElement('div');
|
container = document.createElement('div');
|
||||||
@@ -2322,10 +2322,10 @@ body {
|
|||||||
toast.classList.remove('show');
|
toast.classList.remove('show');
|
||||||
setTimeout(() => toast.remove(), 300);
|
setTimeout(() => toast.remove(), 300);
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Next Week Badge ===
|
// === Next Week Badge ===
|
||||||
function updateNextWeekBadge() {
|
function updateNextWeekBadge() {
|
||||||
const btnNextWeek = document.getElementById('btn-next-week');
|
const btnNextWeek = document.getElementById('btn-next-week');
|
||||||
let nextWeek = currentWeekNumber + 1;
|
let nextWeek = currentWeekNumber + 1;
|
||||||
let nextYear = currentYear;
|
let nextYear = currentYear;
|
||||||
@@ -2407,10 +2407,10 @@ body {
|
|||||||
} else if (badge) {
|
} else if (badge) {
|
||||||
badge.remove();
|
badge.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Weekly Cost ===
|
// === Weekly Cost ===
|
||||||
function updateWeeklyCost(days) {
|
function updateWeeklyCost(days) {
|
||||||
let totalCost = 0;
|
let totalCost = 0;
|
||||||
if (days && days.length > 0) {
|
if (days && days.length > 0) {
|
||||||
days.forEach(day => {
|
days.forEach(day => {
|
||||||
@@ -2432,10 +2432,10 @@ body {
|
|||||||
} else {
|
} else {
|
||||||
costDisplay.classList.add('hidden');
|
costDisplay.classList.add('hidden');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Render Weeks ===
|
// === Render Weeks ===
|
||||||
function renderVisibleWeeks() {
|
function renderVisibleWeeks() {
|
||||||
const menuContainer = document.getElementById('menu-container');
|
const menuContainer = document.getElementById('menu-container');
|
||||||
if (!menuContainer) return;
|
if (!menuContainer) return;
|
||||||
menuContainer.innerHTML = '';
|
menuContainer.innerHTML = '';
|
||||||
@@ -2493,10 +2493,10 @@ body {
|
|||||||
|
|
||||||
menuContainer.appendChild(grid);
|
menuContainer.appendChild(grid);
|
||||||
setTimeout(() => syncMenuItemHeights(grid), 0);
|
setTimeout(() => syncMenuItemHeights(grid), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Sync Item Heights ===
|
// === Sync Item Heights ===
|
||||||
function syncMenuItemHeights(grid) {
|
function syncMenuItemHeights(grid) {
|
||||||
const cards = grid.querySelectorAll('.menu-card');
|
const cards = grid.querySelectorAll('.menu-card');
|
||||||
if (cards.length === 0) return;
|
if (cards.length === 0) return;
|
||||||
let maxItems = 0;
|
let maxItems = 0;
|
||||||
@@ -2516,10 +2516,10 @@ body {
|
|||||||
});
|
});
|
||||||
itemsAtPos.forEach(item => { item.style.height = `${maxHeight}px`; });
|
itemsAtPos.forEach(item => { item.style.height = `${maxHeight}px`; });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Create Day Card ===
|
// === Create Day Card ===
|
||||||
function createDayCard(day) {
|
function createDayCard(day) {
|
||||||
if (!day.items || day.items.length === 0) return null;
|
if (!day.items || day.items.length === 0) return null;
|
||||||
|
|
||||||
const card = document.createElement('div');
|
const card = document.createElement('div');
|
||||||
@@ -2746,10 +2746,10 @@ body {
|
|||||||
|
|
||||||
card.appendChild(body);
|
card.appendChild(body);
|
||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Version Check ===
|
// === Version Check ===
|
||||||
async function checkForUpdates() {
|
async function checkForUpdates() {
|
||||||
icon.className = 'update-icon';
|
icon.className = 'update-icon';
|
||||||
icon.href = url;
|
icon.href = url;
|
||||||
icon.target = '_blank';
|
icon.target = '_blank';
|
||||||
@@ -2758,10 +2758,10 @@ body {
|
|||||||
|
|
||||||
headerTitle.appendChild(icon);
|
headerTitle.appendChild(icon);
|
||||||
showToast(`Update verfügbar: ${newVersion}`, 'info');
|
showToast(`Update verfügbar: ${newVersion}`, 'info');
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Order Countdown ===
|
// === Order Countdown ===
|
||||||
function updateCountdown() {
|
function updateCountdown() {
|
||||||
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)
|
||||||
@@ -2840,70 +2840,69 @@ body {
|
|||||||
} else {
|
} else {
|
||||||
countdownEl.classList.remove('urgent');
|
countdownEl.classList.remove('urgent');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeCountdown() {
|
function removeCountdown() {
|
||||||
const el = document.getElementById('order-countdown');
|
const el = document.getElementById('order-countdown');
|
||||||
if (el) el.remove();
|
if (el) el.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update countdown every minute
|
// Update countdown every minute
|
||||||
setInterval(updateCountdown, 60000);
|
setInterval(updateCountdown, 60000);
|
||||||
// Also update on load
|
// Also update on load
|
||||||
setTimeout(updateCountdown, 1000);
|
setTimeout(updateCountdown, 1000);
|
||||||
|
|
||||||
// === Helpers ===
|
// === Helpers ===
|
||||||
function getISOWeek(date) {
|
function getISOWeek(date) {
|
||||||
const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
||||||
const dayNum = d.getUTCDay() || 7;
|
const dayNum = d.getUTCDay() || 7;
|
||||||
d.setUTCDate(d.getUTCDate() + 4 - dayNum);
|
d.setUTCDate(d.getUTCDate() + 4 - dayNum);
|
||||||
const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
|
const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
|
||||||
return Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
|
return Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWeekYear(d) {
|
function getWeekYear(d) {
|
||||||
const date = new Date(d.getTime());
|
const date = new Date(d.getTime());
|
||||||
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
|
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
|
||||||
return date.getFullYear();
|
return date.getFullYear();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function translateDay(englishDay) {
|
function translateDay(englishDay) {
|
||||||
const map = { Monday: 'Montag', Tuesday: 'Dienstag', Wednesday: 'Mittwoch', Thursday: 'Donnerstag', Friday: 'Freitag', Saturday: 'Samstag', Sunday: 'Sonntag' };
|
const map = { Monday: 'Montag', Tuesday: 'Dienstag', Wednesday: 'Mittwoch', Thursday: 'Donnerstag', Friday: 'Freitag', Saturday: 'Samstag', Sunday: 'Sonntag' };
|
||||||
return map[englishDay] || englishDay;
|
return map[englishDay] || englishDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
function escapeHtml(text) {
|
function escapeHtml(text) {
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
div.textContent = text || '';
|
div.textContent = text || '';
|
||||||
return div.innerHTML;
|
return div.innerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Bootstrap ===
|
// === Bootstrap ===
|
||||||
injectUI();
|
injectUI();
|
||||||
bindEvents();
|
bindEvents();
|
||||||
updateAuthUI();
|
updateAuthUI();
|
||||||
cleanupExpiredFlags();
|
cleanupExpiredFlags();
|
||||||
|
|
||||||
// Load cached data first for instant UI, then refresh from API
|
// Load cached data first for instant UI, then refresh from API
|
||||||
const hadCache = loadMenuCache();
|
const hadCache = loadMenuCache();
|
||||||
if (hadCache) {
|
if (hadCache) {
|
||||||
// Hide loading spinner since cache is shown
|
// Hide loading spinner since cache is shown
|
||||||
document.getElementById('loading').classList.add('hidden');
|
document.getElementById('loading').classList.add('hidden');
|
||||||
}
|
}
|
||||||
loadMenuDataFromAPI();
|
loadMenuDataFromAPI();
|
||||||
|
|
||||||
// Auto-start polling if already logged in
|
// Auto-start polling if already logged in
|
||||||
if (authToken) {
|
if (authToken) {
|
||||||
startPolling();
|
startPolling();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for updates
|
// Check for updates
|
||||||
checkForUpdates();
|
checkForUpdates();
|
||||||
|
|
||||||
console.log('Kantine Wrapper loaded ✅');
|
console.log('Kantine Wrapper loaded ✅');
|
||||||
})();
|
}) ();
|
||||||
|
|
||||||
// === Error Modal ===
|
// === Error Modal ===
|
||||||
function showErrorModal(title, htmlContent, btnText, url) {
|
function showErrorModal(title, htmlContent, btnText, url) {
|
||||||
|
|||||||
161
kantine.js
161
kantine.js
@@ -651,7 +651,6 @@
|
|||||||
}
|
}
|
||||||
// Refresh menu data to update UI
|
// Refresh menu data to update UI
|
||||||
loadMenuDataFromAPI();
|
loadMenuDataFromAPI();
|
||||||
break; // One refresh is enough
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -660,17 +659,18 @@
|
|||||||
await new Promise(r => setTimeout(r, 200));
|
await new Promise(r => setTimeout(r, 200));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// === Highlight Management ===
|
// === Highlight Management ===
|
||||||
let highlightTags = JSON.parse(localStorage.getItem('kantine_highlightTags') || '[]');
|
let highlightTags = JSON.parse(localStorage.getItem('kantine_highlightTags') || '[]');
|
||||||
|
|
||||||
function saveHighlightTags() {
|
function saveHighlightTags() {
|
||||||
localStorage.setItem('kantine_highlightTags', JSON.stringify(highlightTags));
|
localStorage.setItem('kantine_highlightTags', JSON.stringify(highlightTags));
|
||||||
renderVisibleWeeks(); // Refresh UI to apply changes
|
renderVisibleWeeks(); // Refresh UI to apply changes
|
||||||
updateNextWeekBadge();
|
updateNextWeekBadge();
|
||||||
}
|
}
|
||||||
|
|
||||||
function addHighlightTag(tag) {
|
function addHighlightTag(tag) {
|
||||||
tag = tag.trim().toLowerCase();
|
tag = tag.trim().toLowerCase();
|
||||||
if (tag && !highlightTags.includes(tag)) {
|
if (tag && !highlightTags.includes(tag)) {
|
||||||
highlightTags.push(tag);
|
highlightTags.push(tag);
|
||||||
@@ -678,14 +678,14 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeHighlightTag(tag) {
|
function removeHighlightTag(tag) {
|
||||||
highlightTags = highlightTags.filter(t => t !== tag);
|
highlightTags = highlightTags.filter(t => t !== tag);
|
||||||
saveHighlightTags();
|
saveHighlightTags();
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderTagsList() {
|
function renderTagsList() {
|
||||||
const list = document.getElementById('tags-list');
|
const list = document.getElementById('tags-list');
|
||||||
list.innerHTML = '';
|
list.innerHTML = '';
|
||||||
highlightTags.forEach(tag => {
|
highlightTags.forEach(tag => {
|
||||||
@@ -702,28 +702,28 @@
|
|||||||
renderTagsList();
|
renderTagsList();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkHighlight(text) {
|
function checkHighlight(text) {
|
||||||
if (!text) return false;
|
if (!text) return false;
|
||||||
text = text.toLowerCase();
|
text = text.toLowerCase();
|
||||||
return highlightTags.some(tag => text.includes(tag));
|
return highlightTags.some(tag => text.includes(tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Local Menu Cache (localStorage) ===
|
// === Local Menu Cache (localStorage) ===
|
||||||
const CACHE_KEY = 'kantine_menuCache';
|
const CACHE_KEY = 'kantine_menuCache';
|
||||||
const CACHE_TS_KEY = 'kantine_menuCacheTs';
|
const CACHE_TS_KEY = 'kantine_menuCacheTs';
|
||||||
|
|
||||||
function saveMenuCache() {
|
function saveMenuCache() {
|
||||||
try {
|
try {
|
||||||
localStorage.setItem(CACHE_KEY, JSON.stringify(allWeeks));
|
localStorage.setItem(CACHE_KEY, JSON.stringify(allWeeks));
|
||||||
localStorage.setItem(CACHE_TS_KEY, new Date().toISOString());
|
localStorage.setItem(CACHE_TS_KEY, new Date().toISOString());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('Failed to cache menu data:', e);
|
console.warn('Failed to cache menu data:', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadMenuCache() {
|
function loadMenuCache() {
|
||||||
try {
|
try {
|
||||||
const cached = localStorage.getItem(CACHE_KEY);
|
const cached = localStorage.getItem(CACHE_KEY);
|
||||||
const cachedTs = localStorage.getItem(CACHE_TS_KEY);
|
const cachedTs = localStorage.getItem(CACHE_TS_KEY);
|
||||||
@@ -741,10 +741,10 @@
|
|||||||
console.warn('Failed to load cached menu:', e);
|
console.warn('Failed to load cached menu:', e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Menu Data Fetching (Direct from Bessa API) ===
|
// === Menu Data Fetching (Direct from Bessa API) ===
|
||||||
async function loadMenuDataFromAPI() {
|
async function loadMenuDataFromAPI() {
|
||||||
const loading = document.getElementById('loading');
|
const loading = document.getElementById('loading');
|
||||||
const progressModal = document.getElementById('progress-modal');
|
const progressModal = document.getElementById('progress-modal');
|
||||||
const progressFill = document.getElementById('progress-fill');
|
const progressFill = document.getElementById('progress-fill');
|
||||||
@@ -937,10 +937,10 @@
|
|||||||
} finally {
|
} finally {
|
||||||
loading.classList.add('hidden');
|
loading.classList.add('hidden');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Last Updated Display ===
|
// === Last Updated Display ===
|
||||||
function updateLastUpdatedTime(isoTimestamp) {
|
function updateLastUpdatedTime(isoTimestamp) {
|
||||||
const subtitle = document.getElementById('last-updated-subtitle');
|
const subtitle = document.getElementById('last-updated-subtitle');
|
||||||
if (!isoTimestamp) return;
|
if (!isoTimestamp) return;
|
||||||
try {
|
try {
|
||||||
@@ -951,10 +951,10 @@
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
subtitle.textContent = '';
|
subtitle.textContent = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Toast Notification ===
|
// === Toast Notification ===
|
||||||
function showToast(message, type = 'info') {
|
function showToast(message, type = 'info') {
|
||||||
let container = document.getElementById('toast-container');
|
let container = document.getElementById('toast-container');
|
||||||
if (!container) {
|
if (!container) {
|
||||||
container = document.createElement('div');
|
container = document.createElement('div');
|
||||||
@@ -971,10 +971,10 @@
|
|||||||
toast.classList.remove('show');
|
toast.classList.remove('show');
|
||||||
setTimeout(() => toast.remove(), 300);
|
setTimeout(() => toast.remove(), 300);
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Next Week Badge ===
|
// === Next Week Badge ===
|
||||||
function updateNextWeekBadge() {
|
function updateNextWeekBadge() {
|
||||||
const btnNextWeek = document.getElementById('btn-next-week');
|
const btnNextWeek = document.getElementById('btn-next-week');
|
||||||
let nextWeek = currentWeekNumber + 1;
|
let nextWeek = currentWeekNumber + 1;
|
||||||
let nextYear = currentYear;
|
let nextYear = currentYear;
|
||||||
@@ -1056,10 +1056,10 @@
|
|||||||
} else if (badge) {
|
} else if (badge) {
|
||||||
badge.remove();
|
badge.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Weekly Cost ===
|
// === Weekly Cost ===
|
||||||
function updateWeeklyCost(days) {
|
function updateWeeklyCost(days) {
|
||||||
let totalCost = 0;
|
let totalCost = 0;
|
||||||
if (days && days.length > 0) {
|
if (days && days.length > 0) {
|
||||||
days.forEach(day => {
|
days.forEach(day => {
|
||||||
@@ -1081,10 +1081,10 @@
|
|||||||
} else {
|
} else {
|
||||||
costDisplay.classList.add('hidden');
|
costDisplay.classList.add('hidden');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Render Weeks ===
|
// === Render Weeks ===
|
||||||
function renderVisibleWeeks() {
|
function renderVisibleWeeks() {
|
||||||
const menuContainer = document.getElementById('menu-container');
|
const menuContainer = document.getElementById('menu-container');
|
||||||
if (!menuContainer) return;
|
if (!menuContainer) return;
|
||||||
menuContainer.innerHTML = '';
|
menuContainer.innerHTML = '';
|
||||||
@@ -1142,10 +1142,10 @@
|
|||||||
|
|
||||||
menuContainer.appendChild(grid);
|
menuContainer.appendChild(grid);
|
||||||
setTimeout(() => syncMenuItemHeights(grid), 0);
|
setTimeout(() => syncMenuItemHeights(grid), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Sync Item Heights ===
|
// === Sync Item Heights ===
|
||||||
function syncMenuItemHeights(grid) {
|
function syncMenuItemHeights(grid) {
|
||||||
const cards = grid.querySelectorAll('.menu-card');
|
const cards = grid.querySelectorAll('.menu-card');
|
||||||
if (cards.length === 0) return;
|
if (cards.length === 0) return;
|
||||||
let maxItems = 0;
|
let maxItems = 0;
|
||||||
@@ -1165,10 +1165,10 @@
|
|||||||
});
|
});
|
||||||
itemsAtPos.forEach(item => { item.style.height = `${maxHeight}px`; });
|
itemsAtPos.forEach(item => { item.style.height = `${maxHeight}px`; });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Create Day Card ===
|
// === Create Day Card ===
|
||||||
function createDayCard(day) {
|
function createDayCard(day) {
|
||||||
if (!day.items || day.items.length === 0) return null;
|
if (!day.items || day.items.length === 0) return null;
|
||||||
|
|
||||||
const card = document.createElement('div');
|
const card = document.createElement('div');
|
||||||
@@ -1395,10 +1395,10 @@
|
|||||||
|
|
||||||
card.appendChild(body);
|
card.appendChild(body);
|
||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Version Check ===
|
// === Version Check ===
|
||||||
async function checkForUpdates() {
|
async function checkForUpdates() {
|
||||||
icon.className = 'update-icon';
|
icon.className = 'update-icon';
|
||||||
icon.href = url;
|
icon.href = url;
|
||||||
icon.target = '_blank';
|
icon.target = '_blank';
|
||||||
@@ -1407,10 +1407,10 @@
|
|||||||
|
|
||||||
headerTitle.appendChild(icon);
|
headerTitle.appendChild(icon);
|
||||||
showToast(`Update verfügbar: ${newVersion}`, 'info');
|
showToast(`Update verfügbar: ${newVersion}`, 'info');
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Order Countdown ===
|
// === Order Countdown ===
|
||||||
function updateCountdown() {
|
function updateCountdown() {
|
||||||
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)
|
||||||
@@ -1489,70 +1489,69 @@
|
|||||||
} else {
|
} else {
|
||||||
countdownEl.classList.remove('urgent');
|
countdownEl.classList.remove('urgent');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeCountdown() {
|
function removeCountdown() {
|
||||||
const el = document.getElementById('order-countdown');
|
const el = document.getElementById('order-countdown');
|
||||||
if (el) el.remove();
|
if (el) el.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update countdown every minute
|
// Update countdown every minute
|
||||||
setInterval(updateCountdown, 60000);
|
setInterval(updateCountdown, 60000);
|
||||||
// Also update on load
|
// Also update on load
|
||||||
setTimeout(updateCountdown, 1000);
|
setTimeout(updateCountdown, 1000);
|
||||||
|
|
||||||
// === Helpers ===
|
// === Helpers ===
|
||||||
function getISOWeek(date) {
|
function getISOWeek(date) {
|
||||||
const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
||||||
const dayNum = d.getUTCDay() || 7;
|
const dayNum = d.getUTCDay() || 7;
|
||||||
d.setUTCDate(d.getUTCDate() + 4 - dayNum);
|
d.setUTCDate(d.getUTCDate() + 4 - dayNum);
|
||||||
const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
|
const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
|
||||||
return Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
|
return Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWeekYear(d) {
|
function getWeekYear(d) {
|
||||||
const date = new Date(d.getTime());
|
const date = new Date(d.getTime());
|
||||||
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
|
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
|
||||||
return date.getFullYear();
|
return date.getFullYear();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function translateDay(englishDay) {
|
function translateDay(englishDay) {
|
||||||
const map = { Monday: 'Montag', Tuesday: 'Dienstag', Wednesday: 'Mittwoch', Thursday: 'Donnerstag', Friday: 'Freitag', Saturday: 'Samstag', Sunday: 'Sonntag' };
|
const map = { Monday: 'Montag', Tuesday: 'Dienstag', Wednesday: 'Mittwoch', Thursday: 'Donnerstag', Friday: 'Freitag', Saturday: 'Samstag', Sunday: 'Sonntag' };
|
||||||
return map[englishDay] || englishDay;
|
return map[englishDay] || englishDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
function escapeHtml(text) {
|
function escapeHtml(text) {
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
div.textContent = text || '';
|
div.textContent = text || '';
|
||||||
return div.innerHTML;
|
return div.innerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Bootstrap ===
|
// === Bootstrap ===
|
||||||
injectUI();
|
injectUI();
|
||||||
bindEvents();
|
bindEvents();
|
||||||
updateAuthUI();
|
updateAuthUI();
|
||||||
cleanupExpiredFlags();
|
cleanupExpiredFlags();
|
||||||
|
|
||||||
// Load cached data first for instant UI, then refresh from API
|
// Load cached data first for instant UI, then refresh from API
|
||||||
const hadCache = loadMenuCache();
|
const hadCache = loadMenuCache();
|
||||||
if (hadCache) {
|
if (hadCache) {
|
||||||
// Hide loading spinner since cache is shown
|
// Hide loading spinner since cache is shown
|
||||||
document.getElementById('loading').classList.add('hidden');
|
document.getElementById('loading').classList.add('hidden');
|
||||||
}
|
}
|
||||||
loadMenuDataFromAPI();
|
loadMenuDataFromAPI();
|
||||||
|
|
||||||
// Auto-start polling if already logged in
|
// Auto-start polling if already logged in
|
||||||
if (authToken) {
|
if (authToken) {
|
||||||
startPolling();
|
startPolling();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for updates
|
// Check for updates
|
||||||
checkForUpdates();
|
checkForUpdates();
|
||||||
|
|
||||||
console.log('Kantine Wrapper loaded ✅');
|
console.log('Kantine Wrapper loaded ✅');
|
||||||
})();
|
}) ();
|
||||||
|
|
||||||
// === Error Modal ===
|
// === Error Modal ===
|
||||||
function showErrorModal(title, htmlContent, btnText, url) {
|
function showErrorModal(title, htmlContent, btnText, url) {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
v1.1.0
|
v1.1.1
|
||||||
|
|||||||
Reference in New Issue
Block a user