feat: release v1.1.0 (countdown, highlight tags, changelog)

This commit is contained in:
2026-02-16 18:52:07 +01:00
parent 71cb2e8475
commit d6a2236a5b
9 changed files with 1984 additions and 1248 deletions

View File

@@ -108,14 +108,23 @@ cat > "$DIST_DIR/install.html" << INSTALLEOF
</head> </head>
<body> <body>
<h1>🍽️ Kantine Wrapper <span style="font-size:0.5em; opacity:0.6; font-weight:400; vertical-align:middle; margin-left:10px;">$VERSION</span></h1> <h1>🍽️ Kantine Wrapper <span style="font-size:0.5em; opacity:0.6; font-weight:400; vertical-align:middle; margin-left:10px;">$VERSION</span></h1>
<div class="instructions"> <div class="card">
<h2>Installation</h2> <h2>Changelog</h2>
<div class="changelog-container">
<!-- CHANGELOG_PLACEHOLDER -->
</div>
</div>
<div class="card">
<h2>So funktioniert's</h2>
<ol> <ol>
<li>Ziehe den Button unten in deine <strong>Lesezeichen-Leiste</strong> (Drag & Drop)</li> <li>Ziehe den Button unten in deine <strong>Lesezeichen-Leiste</strong> (Drag & Drop)</li>
<li>Navigiere zu <a href="https://web.bessa.app/knapp-kantine" style="color:#029AA8">web.bessa.app/knapp-kantine</a></li> <li>Navigiere zu <a href="https://web.bessa.app/knapp-kantine" style="color:#029AA8">web.bessa.app/knapp-kantine</a></li>
<li>Klicke auf das Lesezeichen <code>Kantine $VERSION</code></li> <li>Klicke auf das Lesezeichen <code>Kantine $VERSION</code></li>
</ol> </ol>
</div>
<div class="card">
<h2>✨ Features</h2> <h2>✨ Features</h2>
<ul> <ul>
<li>📅 <strong>Wochenübersicht:</strong> Die ganze Woche auf einen Blick.</li> <li>📅 <strong>Wochenübersicht:</strong> Die ganze Woche auf einen Blick.</li>
@@ -135,15 +144,47 @@ cat > "$DIST_DIR/install.html" << INSTALLEOF
<script> <script>
INSTALLEOF INSTALLEOF
# Embed the bookmarklet URL inline # Generate Changlog HTML from Markdown
CHANGELOG_HTML=""
if [ -f "$SCRIPT_DIR/changelog.md" ]; then
CHANGELOG_HTML=$(cat "$SCRIPT_DIR/changelog.md" | python3 -c "
import sys, re
md = sys.stdin.read()
# Convert headers to h3/h4
html = re.sub(r'^## (.*)', r'<h3>\1</h3>', md, flags=re.MULTILINE)
# Convert bullets to list items
html = re.sub(r'^- (.*)', r'<li>\1</li>', html, flags=re.MULTILINE)
# Wrap lists (simple heuristic)
html = html.replace('</h3>\n<li>', '</h3>\n<ul>\n<li>').replace('</li>\n<h', '</li>\n</ul>\n<h').replace('</li>\n\n', '</li>\n</ul>\n')
if '<li>' in html and '<ul>' not in html: html = '<ul>' + html + '</ul>'
print(html)
")
fi
echo "document.getElementById('bookmarklet-link').href = " >> "$DIST_DIR/install.html" echo "document.getElementById('bookmarklet-link').href = " >> "$DIST_DIR/install.html"
echo "$JS_CONTENT" | python3 -c " echo "$JS_CONTENT" | python3 -c "
import sys, json import sys, json
js = sys.stdin.read() js = sys.stdin.read()
css = open('$CSS_FILE').read().replace('\\n', ' ').replace(' ', ' ') css = open('$CSS_FILE').read().replace('\\n', ' ').replace(' ', ' ')
bmk = '''javascript:(function(){if(window.__KANTINE_LOADED){alert(\"Already loaded\");return;}var s=document.createElement(\"style\");s.textContent=''' + json.dumps(css) + ''';document.head.appendChild(s);var sc=document.createElement(\"script\");sc.textContent=''' + json.dumps(js) + ''';document.head.appendChild(sc);})();''' escaped_css = css.replace('\\\\', '\\\\\\\\').replace(\"'\", \"\\\\'\").replace('\"', '\\\\\"')
print(json.dumps(bmk) + ';')
" 2>/dev/null >> "$DIST_DIR/install.html" || echo "'javascript:alert(\"Build error\")'" >> "$DIST_DIR/install.html" # Inject Update URL with htmlpreview
update_url = 'https://htmlpreview.github.io/?https://github.com/TauNeutrino/kantine-overview/blob/main/dist/install.html'
js = js.replace('https://github.com/TauNeutrino/kantine-overview/raw/main/dist/install.html', update_url)
print(json.dumps('javascript:(function(){' + js.replace('{{CSS_ESCAPED}}', escaped_css) + '})();'))
" >> "$DIST_DIR/install.html"
# Inject Changelog into Installer HTML (Safe Python replace)
python3 -c "
import sys
html = open('$DIST_DIR/install.html').read()
changelog = sys.stdin.read()
html = html.replace('<!-- CHANGELOG_PLACEHOLDER -->', changelog)
open('$DIST_DIR/install.html', 'w').write(html)
" << EOF
$CHANGELOG_HTML
EOF
cat >> "$DIST_DIR/install.html" << INSTALLEOF cat >> "$DIST_DIR/install.html" << INSTALLEOF
document.getElementById('bookmarklet-link').textContent = 'Kantine $VERSION'; document.getElementById('bookmarklet-link').textContent = 'Kantine $VERSION';

15
changelog.md Executable file
View File

@@ -0,0 +1,15 @@
## v1.1.0 (2026-02-16)
- **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: Changelog**: Diese Übersicht der Änderungen. 📜
- **Verbesserung**: Live-Check der Version beim Update.
## v1.0.3 (2026-02-13)
- **Fix**: Update-Link öffnet nun den Installer direkt als Webseite (via htmlpreview).
## v1.0.2 (2026-02-13)
- **Sync**: Version mit GitHub synchronisiert.
## v1.0.1 (2026-02-12)
- **UI**: Besseres Design für "Nächste Woche" (Badges).
- **Core**: Grundlegende Funktionen (Bestellen, Guthaben, Token-Store).

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

42
dist/install.html vendored

File diff suppressed because one or more lines are too long

View File

@@ -1206,6 +1206,145 @@ body {
70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); } 70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
} }
/* Order Countdown */
#order-countdown {
background: rgba(255, 255, 255, 0.1);
padding: 0.25rem 0.75rem;
border-radius: 99px;
font-size: 0.85rem;
display: flex;
align-items: center;
gap: 0.5rem;
white-space: nowrap;
border: 1px solid var(--border-color);
}
#order-countdown span {
opacity: 0.7;
font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.5px;
}
#order-countdown.urgent {
background: rgba(239, 68, 68, 0.2);
border-color: rgba(239, 68, 68, 0.5);
color: #ef4444;
animation: pulse-red 2s infinite;
}
@keyframes pulse-red {
0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
/* Smart Highlights */
.highlight-glow {
box-shadow: 0 0 15px rgba(59, 130, 246, 0.5); /* Blue glow */
border: 1px solid rgba(59, 130, 246, 0.8);
background: rgba(59, 130, 246, 0.05);
position: relative;
z-index: 1;
}
/* Nav Badge with Count */
.nav-badge.has-highlights {
background-color: var(--card-bg); /* Neutral background */
color: var(--text-primary);
border: 1px solid var(--border-color);
padding: 2px 6px;
}
.nav-badge .highlight-count {
color: #3b82f6; /* Blue 500 */
font-weight: 700;
margin-left: 4px;
}
/* Tag Management Modal */
#tags-list {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-top: 1rem;
min-height: 50px;
}
.tag-badge {
display: inline-flex;
align-items: center;
background: rgba(59, 130, 246, 0.15);
color: #3b82f6;
padding: 4px 10px;
border-radius: 99px;
font-size: 0.85rem;
font-weight: 500;
}
.tag-remove {
margin-left: 6px;
cursor: pointer;
opacity: 0.7;
font-size: 1.1em;
line-height: 1;
}
.tag-remove:hover {
opacity: 1;
color: #ef4444;
}
.input-group {
display: flex;
gap: 0.5rem;
}
.input-group input {
flex: 1;
padding: 0.75rem;
background: var(--bg-color);
border: 1px solid var(--border-color);
color: var(--text-primary);
border-radius: 8px;
}
/* Update Banner Enhanced */
.change-summary {
font-size: 0.8rem;
background: rgba(0,0,0,0.1);
padding: 0.5rem;
border-radius: 4px;
margin: 0.5rem 0;
white-space: pre-wrap;
font-family: inherit;
line-height: 1.4;
max-height: 100px;
overflow-y: auto;
}
.update-content {
display: flex;
flex-direction: column;
gap: 4px;
flex: 1;
}
/* Installer Changelog */
.changelog-container ul {
padding-left: 1.5rem;
margin: 0.5rem 0;
}
.changelog-container li {
margin-bottom: 0.4rem;
line-height: 1.5;
}
.changelog-container h3 {
margin-top: 1.5rem;
margin-bottom: 0.5rem;
font-size: 1.1em;
color: var(--accent-color);
}
</style> </style>
</head> </head>
<body> <body>
@@ -1278,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.0.3</small></h1> <h1>Kantinen Übersicht <small style="font-size: 0.6em; opacity: 0.7; font-weight: 400;">v1.1.0</small></h1>
<div id="last-updated-subtitle" class="subtitle"></div> <div id="last-updated-subtitle" class="subtitle"></div>
</div> </div>
</div> </div>
@@ -1290,6 +1429,9 @@ body {
<button id="btn-refresh" class="icon-btn" aria-label="Menüdaten aktualisieren" title="Menüdaten neu laden"> <button id="btn-refresh" class="icon-btn" aria-label="Menüdaten aktualisieren" title="Menüdaten neu laden">
<span class="material-icons-round">refresh</span> <span class="material-icons-round">refresh</span>
</button> </button>
<button id="btn-highlights" class="icon-btn" aria-label="Persönliche Highlights verwalten" title="Persönliche Highlights verwalten">
<span class="material-icons-round">label</span>
</button>
<div class="nav-group"> <div class="nav-group">
<button id="btn-this-week" class="nav-btn active">Diese Woche</button> <button id="btn-this-week" class="nav-btn active">Diese Woche</button>
<button id="btn-next-week" class="nav-btn">Nächste Woche</button> <button id="btn-next-week" class="nav-btn">Nächste Woche</button>
@@ -1356,6 +1498,27 @@ body {
</div> </div>
</div> </div>
<div id="highlights-modal" class="modal hidden">
<div class="modal-content">
<div class="modal-header">
<h2>Meine Highlights</h2>
<button id="btn-highlights-close" class="icon-btn" aria-label="Close">
<span class="material-icons-round">close</span>
</button>
</div>
<div class="modal-body">
<p style="margin-bottom: 1rem; color: var(--text-secondary);">
Markiere Menüs automatisch, wenn sie diese Schlagwörter enthalten.
</p>
<div class="input-group">
<input type="text" id="tag-input" placeholder="z.B. Schnitzel, Vegetarisch...">
<button id="btn-add-tag" class="btn-primary">Hinzufügen</button>
</div>
<div id="tags-list"></div>
</div>
</div>
</div>
<main class="container"> <main class="container">
<div id="last-updated-banner" class="banner hidden"> <div id="last-updated-banner" class="banner hidden">
<span class="material-icons-round">update</span> <span class="material-icons-round">update</span>
@@ -1386,6 +1549,41 @@ body {
const loginForm = document.getElementById('login-form'); const loginForm = document.getElementById('login-form');
const loginModal = document.getElementById('login-modal'); const loginModal = document.getElementById('login-modal');
// Highlights Modal
const btnHighlights = document.getElementById('btn-highlights');
const highlightsModal = document.getElementById('highlights-modal');
const btnHighlightsClose = document.getElementById('btn-highlights-close');
const btnAddTag = document.getElementById('btn-add-tag');
const tagInput = document.getElementById('tag-input');
btnHighlights.addEventListener('click', () => {
highlightsModal.classList.remove('hidden');
renderTagsList();
tagInput.focus();
});
btnHighlightsClose.addEventListener('click', () => {
highlightsModal.classList.add('hidden');
});
window.addEventListener('click', (e) => {
if (e.target === highlightsModal) highlightsModal.classList.add('hidden');
});
btnAddTag.addEventListener('click', () => {
const tag = tagInput.value;
if (addHighlightTag(tag)) {
tagInput.value = '';
renderTagsList();
}
});
tagInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
btnAddTag.click();
}
});
// Theme // Theme
const savedTheme = localStorage.getItem('theme'); const savedTheme = localStorage.getItem('theme');
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches; const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
@@ -1809,13 +2007,60 @@ body {
} }
} catch (err) { } catch (err) {
console.error(`Poll error for ${flagId}:`, err); console.error(`Poll error for ${flagId}:`, err);
}
// Small delay between checks // Small delay between checks
await new Promise(r => setTimeout(r, 200)); await new Promise(r => setTimeout(r, 200));
} }
} }
// === Highlight Management ===
let highlightTags = JSON.parse(localStorage.getItem('kantine_highlightTags') || '[]');
function saveHighlightTags() {
localStorage.setItem('kantine_highlightTags', JSON.stringify(highlightTags));
renderVisibleWeeks(); // Refresh UI to apply changes
updateNextWeekBadge();
}
function addHighlightTag(tag) {
tag = tag.trim().toLowerCase();
if (tag && !highlightTags.includes(tag)) {
highlightTags.push(tag);
saveHighlightTags();
return true;
}
return false;
}
function removeHighlightTag(tag) {
highlightTags = highlightTags.filter(t => t !== tag);
saveHighlightTags();
}
function renderTagsList() {
const list = document.getElementById('tags-list');
list.innerHTML = '';
highlightTags.forEach(tag => {
const badge = document.createElement('span');
badge.className = 'tag-badge';
badge.innerHTML = `${tag} <span class="tag-remove" data-tag="${tag}">&times;</span>`;
list.appendChild(badge);
});
// Bind remove events
list.querySelectorAll('.tag-remove').forEach(btn => {
btn.addEventListener('click', (e) => {
removeHighlightTag(e.target.dataset.tag);
renderTagsList();
});
});
}
function checkHighlight(text) {
if (!text) return false;
text = text.toLowerCase();
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';
@@ -2140,6 +2385,25 @@ body {
badge.classList.add('badge-blue'); // Default / partial state badge.classList.add('badge-blue'); // Default / partial state
} }
// Advanced Feature: Highlight Count
let highlightCount = 0;
if (nextWeekData && nextWeekData.days) {
nextWeekData.days.forEach(day => {
day.items.forEach(item => {
if (checkHighlight(item.name) || checkHighlight(item.description)) {
highlightCount++;
}
});
});
}
if (highlightCount > 0) {
// Append blue count
badge.innerHTML += `<span class="highlight-count" title="${highlightCount} Highlight Menüs">(${highlightCount})</span>`;
badge.title += `${highlightCount} Highlights gefunden`;
badge.classList.add('has-highlights');
}
} else if (badge) { } else if (badge) {
badge.remove(); badge.remove();
} }
@@ -2486,38 +2750,6 @@ body {
// === Version Check === // === Version Check ===
async function checkForUpdates() { async function checkForUpdates() {
const CurrentVersion = 'v1.0.3'; // Injected by build script
const VersionUrl = 'https://raw.githubusercontent.com/TauNeutrino/kantine-overview/main/version.txt';
// Use htmlpreview.github.io to render the HTML directly in browser
const InstallerUrl = 'https://htmlpreview.github.io/?https://github.com/TauNeutrino/kantine-overview/blob/main/dist/install.html';
console.log(`[Kantine] Checking for updates... (Current: ${CurrentVersion})`);
try {
const response = await fetch(VersionUrl, { cache: 'no-cache' });
if (!response.ok) return;
const remoteVersion = (await response.text()).trim();
console.log(`[Kantine] Remote version: ${remoteVersion}`);
if (remoteVersion && remoteVersion !== CurrentVersion) {
// Simple semantic version check or string inequality
// Assuming format v1.0.0
showUpdateIcon(remoteVersion, InstallerUrl);
}
} catch (error) {
console.warn('[Kantine] Version check failed:', error);
}
}
function showUpdateIcon(newVersion, url) {
const headerTitle = document.querySelector('.header-left h1');
if (!headerTitle) return;
// Check if already added
if (headerTitle.querySelector('.update-icon')) return;
const icon = document.createElement('a');
icon.className = 'update-icon'; icon.className = 'update-icon';
icon.href = url; icon.href = url;
icon.target = '_blank'; icon.target = '_blank';
@@ -2528,6 +2760,98 @@ body {
showToast(`Update verfügbar: ${newVersion}`, 'info'); showToast(`Update verfügbar: ${newVersion}`, 'info');
} }
// === Order Countdown ===
function updateCountdown() {
const now = new Date();
const currentDay = now.getDay();
// Skip weekends (0=Sun, 6=Sat)
if (currentDay === 0 || currentDay === 6) {
removeCountdown();
return;
}
const todayStr = now.toISOString().split('T')[0];
// 1. Check if we already ordered for today
let hasOrder = false;
// Optimization: Check orderMap for today's date
// Keys are "YYYY-MM-DD_ArticleID"
for (const key of orderMap.keys()) {
if (key.startsWith(todayStr)) {
hasOrder = true;
break;
}
}
if (hasOrder) {
removeCountdown();
return;
}
// 2. Calculate time to cutoff (10:00 AM)
const cutoff = new Date();
cutoff.setHours(10, 0, 0, 0);
const diff = cutoff - now;
// If passed cutoff or more than 3 hours away (e.g. 07:00), maybe don't show?
// User req: "heute noch keine bestellung... countdown erscheinen"
// Let's show it if within valid order window (e.g. 00:00 - 10:00)
if (diff <= 0) {
removeCountdown();
return;
}
// 3. Render Countdown
const diffHrs = Math.floor(diff / 3600000);
const diffMins = Math.floor((diff % 3600000) / 60000);
const headerCenter = document.querySelector('.header-center-wrapper');
if (!headerCenter) return;
let countdownEl = document.getElementById('order-countdown');
if (!countdownEl) {
countdownEl = document.createElement('div');
countdownEl.id = 'order-countdown';
// Insert before cost display or append
headerCenter.insertBefore(countdownEl, headerCenter.firstChild);
}
countdownEl.innerHTML = `<span>Bestellschluss:</span> <strong>${diffHrs}h ${diffMins}m</strong>`;
// Red Alert if < 1 hour
if (diff < 3600000) { // 1 hour
countdownEl.classList.add('urgent');
// Notification logic (One time)
const notifiedKey = `kantine_notified_${todayStr}`;
if (!sessionStorage.getItem(notifiedKey)) {
if (Notification.permission === 'granted') {
new Notification('Kantine: Bestellschluss naht!', {
body: 'Du hast heute noch nichts bestellt. Nur noch 1 Stunde!',
icon: '⏳'
});
} else if (Notification.permission === 'default') {
Notification.requestPermission();
}
sessionStorage.setItem(notifiedKey, 'true');
}
} else {
countdownEl.classList.remove('urgent');
}
}
function removeCountdown() {
const el = document.getElementById('order-countdown');
if (el) el.remove();
}
// Update countdown every minute
setInterval(updateCountdown, 60000);
// Also update on load
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()));
@@ -2543,6 +2867,8 @@ body {
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;

View File

@@ -78,6 +78,9 @@
<button id="btn-refresh" class="icon-btn" aria-label="Menüdaten aktualisieren" title="Menüdaten neu laden"> <button id="btn-refresh" class="icon-btn" aria-label="Menüdaten aktualisieren" title="Menüdaten neu laden">
<span class="material-icons-round">refresh</span> <span class="material-icons-round">refresh</span>
</button> </button>
<button id="btn-highlights" class="icon-btn" aria-label="Persönliche Highlights verwalten" title="Persönliche Highlights verwalten">
<span class="material-icons-round">label</span>
</button>
<div class="nav-group"> <div class="nav-group">
<button id="btn-this-week" class="nav-btn active">Diese Woche</button> <button id="btn-this-week" class="nav-btn active">Diese Woche</button>
<button id="btn-next-week" class="nav-btn">Nächste Woche</button> <button id="btn-next-week" class="nav-btn">Nächste Woche</button>
@@ -144,6 +147,27 @@
</div> </div>
</div> </div>
<div id="highlights-modal" class="modal hidden">
<div class="modal-content">
<div class="modal-header">
<h2>Meine Highlights</h2>
<button id="btn-highlights-close" class="icon-btn" aria-label="Close">
<span class="material-icons-round">close</span>
</button>
</div>
<div class="modal-body">
<p style="margin-bottom: 1rem; color: var(--text-secondary);">
Markiere Menüs automatisch, wenn sie diese Schlagwörter enthalten.
</p>
<div class="input-group">
<input type="text" id="tag-input" placeholder="z.B. Schnitzel, Vegetarisch...">
<button id="btn-add-tag" class="btn-primary">Hinzufügen</button>
</div>
<div id="tags-list"></div>
</div>
</div>
</div>
<main class="container"> <main class="container">
<div id="last-updated-banner" class="banner hidden"> <div id="last-updated-banner" class="banner hidden">
<span class="material-icons-round">update</span> <span class="material-icons-round">update</span>
@@ -174,6 +198,41 @@
const loginForm = document.getElementById('login-form'); const loginForm = document.getElementById('login-form');
const loginModal = document.getElementById('login-modal'); const loginModal = document.getElementById('login-modal');
// Highlights Modal
const btnHighlights = document.getElementById('btn-highlights');
const highlightsModal = document.getElementById('highlights-modal');
const btnHighlightsClose = document.getElementById('btn-highlights-close');
const btnAddTag = document.getElementById('btn-add-tag');
const tagInput = document.getElementById('tag-input');
btnHighlights.addEventListener('click', () => {
highlightsModal.classList.remove('hidden');
renderTagsList();
tagInput.focus();
});
btnHighlightsClose.addEventListener('click', () => {
highlightsModal.classList.add('hidden');
});
window.addEventListener('click', (e) => {
if (e.target === highlightsModal) highlightsModal.classList.add('hidden');
});
btnAddTag.addEventListener('click', () => {
const tag = tagInput.value;
if (addHighlightTag(tag)) {
tagInput.value = '';
renderTagsList();
}
});
tagInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
btnAddTag.click();
}
});
// Theme // Theme
const savedTheme = localStorage.getItem('theme'); const savedTheme = localStorage.getItem('theme');
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches; const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
@@ -597,13 +656,60 @@
} }
} catch (err) { } catch (err) {
console.error(`Poll error for ${flagId}:`, err); console.error(`Poll error for ${flagId}:`, err);
}
// Small delay between checks // Small delay between checks
await new Promise(r => setTimeout(r, 200)); await new Promise(r => setTimeout(r, 200));
} }
} }
// === Highlight Management ===
let highlightTags = JSON.parse(localStorage.getItem('kantine_highlightTags') || '[]');
function saveHighlightTags() {
localStorage.setItem('kantine_highlightTags', JSON.stringify(highlightTags));
renderVisibleWeeks(); // Refresh UI to apply changes
updateNextWeekBadge();
}
function addHighlightTag(tag) {
tag = tag.trim().toLowerCase();
if (tag && !highlightTags.includes(tag)) {
highlightTags.push(tag);
saveHighlightTags();
return true;
}
return false;
}
function removeHighlightTag(tag) {
highlightTags = highlightTags.filter(t => t !== tag);
saveHighlightTags();
}
function renderTagsList() {
const list = document.getElementById('tags-list');
list.innerHTML = '';
highlightTags.forEach(tag => {
const badge = document.createElement('span');
badge.className = 'tag-badge';
badge.innerHTML = `${tag} <span class="tag-remove" data-tag="${tag}">&times;</span>`;
list.appendChild(badge);
});
// Bind remove events
list.querySelectorAll('.tag-remove').forEach(btn => {
btn.addEventListener('click', (e) => {
removeHighlightTag(e.target.dataset.tag);
renderTagsList();
});
});
}
function checkHighlight(text) {
if (!text) return false;
text = text.toLowerCase();
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';
@@ -928,6 +1034,25 @@
badge.classList.add('badge-blue'); // Default / partial state badge.classList.add('badge-blue'); // Default / partial state
} }
// Advanced Feature: Highlight Count
let highlightCount = 0;
if (nextWeekData && nextWeekData.days) {
nextWeekData.days.forEach(day => {
day.items.forEach(item => {
if (checkHighlight(item.name) || checkHighlight(item.description)) {
highlightCount++;
}
});
});
}
if (highlightCount > 0) {
// Append blue count
badge.innerHTML += `<span class="highlight-count" title="${highlightCount} Highlight Menüs">(${highlightCount})</span>`;
badge.title += `${highlightCount} Highlights gefunden`;
badge.classList.add('has-highlights');
}
} else if (badge) { } else if (badge) {
badge.remove(); badge.remove();
} }
@@ -1274,38 +1399,6 @@
// === Version Check === // === Version Check ===
async function checkForUpdates() { async function checkForUpdates() {
const CurrentVersion = '{{VERSION}}'; // Injected by build script
const VersionUrl = 'https://raw.githubusercontent.com/TauNeutrino/kantine-overview/main/version.txt';
// Use htmlpreview.github.io to render the HTML directly in browser
const InstallerUrl = 'https://htmlpreview.github.io/?https://github.com/TauNeutrino/kantine-overview/blob/main/dist/install.html';
console.log(`[Kantine] Checking for updates... (Current: ${CurrentVersion})`);
try {
const response = await fetch(VersionUrl, { cache: 'no-cache' });
if (!response.ok) return;
const remoteVersion = (await response.text()).trim();
console.log(`[Kantine] Remote version: ${remoteVersion}`);
if (remoteVersion && remoteVersion !== CurrentVersion) {
// Simple semantic version check or string inequality
// Assuming format v1.0.0
showUpdateIcon(remoteVersion, InstallerUrl);
}
} catch (error) {
console.warn('[Kantine] Version check failed:', error);
}
}
function showUpdateIcon(newVersion, url) {
const headerTitle = document.querySelector('.header-left h1');
if (!headerTitle) return;
// Check if already added
if (headerTitle.querySelector('.update-icon')) return;
const icon = document.createElement('a');
icon.className = 'update-icon'; icon.className = 'update-icon';
icon.href = url; icon.href = url;
icon.target = '_blank'; icon.target = '_blank';
@@ -1316,6 +1409,98 @@
showToast(`Update verfügbar: ${newVersion}`, 'info'); showToast(`Update verfügbar: ${newVersion}`, 'info');
} }
// === Order Countdown ===
function updateCountdown() {
const now = new Date();
const currentDay = now.getDay();
// Skip weekends (0=Sun, 6=Sat)
if (currentDay === 0 || currentDay === 6) {
removeCountdown();
return;
}
const todayStr = now.toISOString().split('T')[0];
// 1. Check if we already ordered for today
let hasOrder = false;
// Optimization: Check orderMap for today's date
// Keys are "YYYY-MM-DD_ArticleID"
for (const key of orderMap.keys()) {
if (key.startsWith(todayStr)) {
hasOrder = true;
break;
}
}
if (hasOrder) {
removeCountdown();
return;
}
// 2. Calculate time to cutoff (10:00 AM)
const cutoff = new Date();
cutoff.setHours(10, 0, 0, 0);
const diff = cutoff - now;
// If passed cutoff or more than 3 hours away (e.g. 07:00), maybe don't show?
// User req: "heute noch keine bestellung... countdown erscheinen"
// Let's show it if within valid order window (e.g. 00:00 - 10:00)
if (diff <= 0) {
removeCountdown();
return;
}
// 3. Render Countdown
const diffHrs = Math.floor(diff / 3600000);
const diffMins = Math.floor((diff % 3600000) / 60000);
const headerCenter = document.querySelector('.header-center-wrapper');
if (!headerCenter) return;
let countdownEl = document.getElementById('order-countdown');
if (!countdownEl) {
countdownEl = document.createElement('div');
countdownEl.id = 'order-countdown';
// Insert before cost display or append
headerCenter.insertBefore(countdownEl, headerCenter.firstChild);
}
countdownEl.innerHTML = `<span>Bestellschluss:</span> <strong>${diffHrs}h ${diffMins}m</strong>`;
// Red Alert if < 1 hour
if (diff < 3600000) { // 1 hour
countdownEl.classList.add('urgent');
// Notification logic (One time)
const notifiedKey = `kantine_notified_${todayStr}`;
if (!sessionStorage.getItem(notifiedKey)) {
if (Notification.permission === 'granted') {
new Notification('Kantine: Bestellschluss naht!', {
body: 'Du hast heute noch nichts bestellt. Nur noch 1 Stunde!',
icon: '⏳'
});
} else if (Notification.permission === 'default') {
Notification.requestPermission();
}
sessionStorage.setItem(notifiedKey, 'true');
}
} else {
countdownEl.classList.remove('urgent');
}
}
function removeCountdown() {
const el = document.getElementById('order-countdown');
if (el) el.remove();
}
// Update countdown every minute
setInterval(updateCountdown, 60000);
// Also update on load
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()));
@@ -1331,6 +1516,8 @@
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;

139
style.css
View File

@@ -1195,3 +1195,142 @@ body {
70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); } 70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
} }
/* Order Countdown */
#order-countdown {
background: rgba(255, 255, 255, 0.1);
padding: 0.25rem 0.75rem;
border-radius: 99px;
font-size: 0.85rem;
display: flex;
align-items: center;
gap: 0.5rem;
white-space: nowrap;
border: 1px solid var(--border-color);
}
#order-countdown span {
opacity: 0.7;
font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.5px;
}
#order-countdown.urgent {
background: rgba(239, 68, 68, 0.2);
border-color: rgba(239, 68, 68, 0.5);
color: #ef4444;
animation: pulse-red 2s infinite;
}
@keyframes pulse-red {
0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
/* Smart Highlights */
.highlight-glow {
box-shadow: 0 0 15px rgba(59, 130, 246, 0.5); /* Blue glow */
border: 1px solid rgba(59, 130, 246, 0.8);
background: rgba(59, 130, 246, 0.05);
position: relative;
z-index: 1;
}
/* Nav Badge with Count */
.nav-badge.has-highlights {
background-color: var(--card-bg); /* Neutral background */
color: var(--text-primary);
border: 1px solid var(--border-color);
padding: 2px 6px;
}
.nav-badge .highlight-count {
color: #3b82f6; /* Blue 500 */
font-weight: 700;
margin-left: 4px;
}
/* Tag Management Modal */
#tags-list {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-top: 1rem;
min-height: 50px;
}
.tag-badge {
display: inline-flex;
align-items: center;
background: rgba(59, 130, 246, 0.15);
color: #3b82f6;
padding: 4px 10px;
border-radius: 99px;
font-size: 0.85rem;
font-weight: 500;
}
.tag-remove {
margin-left: 6px;
cursor: pointer;
opacity: 0.7;
font-size: 1.1em;
line-height: 1;
}
.tag-remove:hover {
opacity: 1;
color: #ef4444;
}
.input-group {
display: flex;
gap: 0.5rem;
}
.input-group input {
flex: 1;
padding: 0.75rem;
background: var(--bg-color);
border: 1px solid var(--border-color);
color: var(--text-primary);
border-radius: 8px;
}
/* Update Banner Enhanced */
.change-summary {
font-size: 0.8rem;
background: rgba(0,0,0,0.1);
padding: 0.5rem;
border-radius: 4px;
margin: 0.5rem 0;
white-space: pre-wrap;
font-family: inherit;
line-height: 1.4;
max-height: 100px;
overflow-y: auto;
}
.update-content {
display: flex;
flex-direction: column;
gap: 4px;
flex: 1;
}
/* Installer Changelog */
.changelog-container ul {
padding-left: 1.5rem;
margin: 0.5rem 0;
}
.changelog-container li {
margin-bottom: 0.4rem;
line-height: 1.5;
}
.changelog-container h3 {
margin-top: 1.5rem;
margin-bottom: 0.5rem;
font-size: 1.1em;
color: var(--accent-color);
}

View File

@@ -1 +1 @@
v1.0.3 v1.1.0