Ticking an offer already adds it to the shopping list instantly (it shows in the Lübeck-tilbud section), but that wasn't visible. Add a fixed 'N valgt · Gå til seddel' button that appears once anything is selected, so the link between the checklist and the list is obvious and you can jump straight to it.
187 lines
8.7 KiB
HTML
187 lines
8.7 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="da">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<meta name="theme-color" content="#c84b2f">
|
||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||
<meta name="apple-mobile-web-app-title" content="Citti">
|
||
<link rel="manifest" href="/manifest.webmanifest">
|
||
<link rel="apple-touch-icon" href="/icon.svg">
|
||
<link rel="icon" href="/icon.svg">
|
||
<script src="/offline.js" defer></script>
|
||
<title>Citti Tilbud — Lübeck</title>
|
||
<link href="https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@300;400;500;600&display=swap" rel="stylesheet">
|
||
<style>
|
||
:root {
|
||
--bg: #f5f2ed; --card: #ffffff; --border: #e2ddd6; --text: #1a1814;
|
||
--muted: #8a857c; --accent: #c84b2f; --green: #2d6a4f; --green-light: #e8f4ee;
|
||
--mono: 'DM Mono', monospace; --sans: 'DM Sans', sans-serif;
|
||
}
|
||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||
body { font-family: var(--sans); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; padding: 1.5rem 1rem 4rem; }
|
||
.page { max-width: 860px; margin: 0 auto; }
|
||
header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; padding-bottom: 1.25rem; border-bottom: 2px solid var(--text); }
|
||
h1 { font-size: 1.75rem; font-weight: 600; letter-spacing: -0.03em; }
|
||
h1 span { color: var(--accent); }
|
||
.sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
|
||
.btn { background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; font-size: 13px; font-family: var(--sans); cursor: pointer; text-decoration: none; display: inline-block; font-weight: 500; }
|
||
.btn-back { background: var(--text); color: white; border: none; }
|
||
.btn-refresh { background: var(--green); color: white; border: none; }
|
||
.btn:active { opacity: 0.85; }
|
||
|
||
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 1.25rem; }
|
||
.search { flex: 1; min-width: 180px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-family: var(--sans); font-size: 14px; background: var(--card); }
|
||
.pick-count { font-size: 13px; color: var(--green); font-weight: 600; white-space: nowrap; }
|
||
|
||
.cat { margin-bottom: 1.5rem; }
|
||
.cat-title { background: var(--text); color: white; padding: 0.5rem 1rem; font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; border-radius: 8px 8px 0 0; }
|
||
.cat-body { background: var(--card); border: 1px solid var(--border); border-top: none; border-radius: 0 0 8px 8px; overflow: hidden; }
|
||
.offer { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 0.55rem 1rem; border-bottom: 1px solid var(--border); }
|
||
.offer:last-child { border-bottom: none; }
|
||
.offer.picked { background: var(--green-light); }
|
||
.offer input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--green); cursor: pointer; }
|
||
.o-name { font-size: 14px; }
|
||
.o-de { font-size: 10px; color: #b0aba3; font-style: italic; margin-top: 1px; }
|
||
.o-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
|
||
.o-price { text-align: right; white-space: nowrap; }
|
||
.o-eur { font-family: var(--mono); font-weight: 600; font-size: 15px; }
|
||
.o-pre { font-family: var(--mono); font-size: 12px; color: var(--muted); text-decoration: line-through; margin-right: 4px; }
|
||
.o-dkk { font-family: var(--mono); font-size: 11px; color: var(--muted); }
|
||
.empty-state { padding: 2.5rem 2rem; text-align: center; color: var(--muted); font-size: 14px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
|
||
.err { background: #fde8e3; color: var(--accent); font-size: 12px; padding: 8px 12px; border-radius: 8px; margin-bottom: 1rem; }
|
||
.cat.hidden, .offer.hidden { display: none; }
|
||
|
||
@media (max-width: 600px) {
|
||
.offer { grid-template-columns: 30px 1fr auto; }
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="page">
|
||
|
||
<header>
|
||
<div>
|
||
<h1>Citti <span>Tilbud</span></h1>
|
||
<div class="sub">
|
||
CITTI Lübeck · Herrenholz 14 · priser i EUR (≈ ×{{ "{:.2f}".format(eur_dkk).replace(".",",") }} kr.)<br>
|
||
{% if last_refresh %}Opdateret {{ last_refresh[:16].replace("T"," ") }} · {% endif %}{{ total }} tilbud
|
||
</div>
|
||
</div>
|
||
<div style="display:flex;flex-direction:column;gap:8px;align-items:flex-end">
|
||
<a href="/" class="btn btn-back">← Indkøbsseddel</a>
|
||
<button class="btn btn-refresh" id="refresh-btn" onclick="refreshOffers()">⟳ Opdater</button>
|
||
</div>
|
||
</header>
|
||
|
||
{% if last_error %}<div class="err">Sidste opdatering fejlede: {{ last_error }}</div>{% endif %}
|
||
|
||
<div class="toolbar">
|
||
<input class="search" id="search" type="search" placeholder="Søg i tilbud (tysk navn)…" oninput="filterOffers()">
|
||
<span class="pick-count" id="pick-count">{{ picked_count }} på seddel</span>
|
||
</div>
|
||
|
||
{% if total == 0 %}
|
||
<div class="empty-state">
|
||
Ingen tilbud hentet endnu. Tryk <strong>⟳ Opdater</strong> for at hente ugens tilbud fra CITTI Lübeck.
|
||
</div>
|
||
{% endif %}
|
||
|
||
{% for cat, offers in by_cat.items() %}
|
||
<div class="cat" data-cat>
|
||
<div class="cat-title">{{ cat }} ({{ offers|length }})</div>
|
||
<div class="cat-body">
|
||
{% for o in offers %}
|
||
<label class="offer{% if o.picked %} picked{% endif %}" data-name="{{ o.heading|lower }}">
|
||
<input type="checkbox" {% if o.picked %}checked{% endif %} onchange="togglePick(this, '{{ o.id }}')">
|
||
<div>
|
||
<div class="o-name">{{ o.heading_da or o.heading }}</div>
|
||
{% if o.heading_da and o.heading_da != o.heading %}<div class="o-de">🇩🇪 {{ o.heading }}</div>{% endif %}
|
||
<div class="o-meta">
|
||
{% if o.page %}s. {{ o.page }}{% endif %}
|
||
{% if o.unit and o.size_from %} · {{ o.size_from|int }}{% if o.size_to and o.size_to != o.size_from %}–{{ o.size_to|int }}{% endif %} {{ o.unit }}{% endif %}
|
||
{% if o.run_till %} · t.o.m. {{ o.run_till[:10] }}{% endif %}
|
||
</div>
|
||
</div>
|
||
<div class="o-price">
|
||
<div>
|
||
{% if o.pre_price_eur %}<span class="o-pre">{{ "{:.2f}".format(o.pre_price_eur).replace(".",",") }}</span>{% endif %}
|
||
<span class="o-eur">{{ "{:.2f}".format(o.price_eur).replace(".",",") }} €</span>
|
||
</div>
|
||
<div class="o-dkk">≈ {{ "{:.0f}".format(o.price_eur * eur_dkk) }} kr.</div>
|
||
</div>
|
||
</label>
|
||
{% endfor %}
|
||
</div>
|
||
</div>
|
||
{% endfor %}
|
||
|
||
</div>
|
||
|
||
<a class="golist" id="golist" href="/"
|
||
style="display:none;position:fixed;right:14px;bottom:14px;z-index:9999;padding:11px 18px;border-radius:24px;background:#2d6a4f;color:#fff;text-decoration:none;font:600 14px/1 var(--sans);box-shadow:0 3px 12px rgba(0,0,0,.28)">🛒 <b id="golist-n">0</b> valgt · Gå til seddel →</a>
|
||
|
||
<script>
|
||
let pickCount = {{ picked_count }};
|
||
|
||
// Picking is instant — a tick adds the offer to the shopping list right away
|
||
// (it shows in the "Lübeck-tilbud" section there). This just mirrors the count
|
||
// and the "go to list" button.
|
||
function updatePick() {
|
||
document.getElementById('pick-count').textContent = pickCount + ' på seddel';
|
||
document.getElementById('golist-n').textContent = pickCount;
|
||
document.getElementById('golist').style.display = pickCount > 0 ? 'block' : 'none';
|
||
}
|
||
|
||
async function togglePick(cb, id) {
|
||
const picked = cb.checked;
|
||
cb.closest('.offer').classList.toggle('picked', picked);
|
||
pickCount += picked ? 1 : -1;
|
||
updatePick();
|
||
try {
|
||
await (window.cittiFetch || fetch)('/api/offers/pick', {
|
||
method: 'POST',
|
||
headers: {'Content-Type':'application/json'},
|
||
body: JSON.stringify({id, picked})
|
||
});
|
||
} catch (e) {
|
||
cb.checked = !picked;
|
||
cb.closest('.offer').classList.toggle('picked', !picked);
|
||
pickCount += picked ? -1 : 1;
|
||
updatePick();
|
||
}
|
||
}
|
||
|
||
function filterOffers() {
|
||
const q = document.getElementById('search').value.trim().toLowerCase();
|
||
document.querySelectorAll('[data-cat]').forEach(cat => {
|
||
let any = false;
|
||
cat.querySelectorAll('.offer').forEach(o => {
|
||
const match = !q || o.dataset.name.includes(q);
|
||
o.classList.toggle('hidden', !match);
|
||
if (match) any = true;
|
||
});
|
||
cat.classList.toggle('hidden', !any);
|
||
});
|
||
}
|
||
|
||
async function refreshOffers() {
|
||
const btn = document.getElementById('refresh-btn');
|
||
btn.textContent = '⟳ Henter…'; btn.disabled = true;
|
||
try {
|
||
// The refresh runs in the background (translation can be slow under rate
|
||
// limits), so we just kick it off and reload a little later to show
|
||
// progress — the page fills in as batches complete.
|
||
await fetch('/api/offers/refresh', {method: 'POST'});
|
||
btn.textContent = '⟳ Opdaterer i baggrunden…';
|
||
setTimeout(function () { window.location.reload(); }, 12000);
|
||
} catch (e) {
|
||
btn.textContent = '⟳ Opdater'; btn.disabled = false;
|
||
}
|
||
}
|
||
|
||
updatePick();
|
||
</script>
|
||
</body>
|
||
</html>
|