worktree-citti-arkiver-tur #8
@@ -117,14 +117,27 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
</div>
|
</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>
|
<script>
|
||||||
let pickCount = {{ picked_count }};
|
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) {
|
async function togglePick(cb, id) {
|
||||||
const picked = cb.checked;
|
const picked = cb.checked;
|
||||||
cb.closest('.offer').classList.toggle('picked', picked);
|
cb.closest('.offer').classList.toggle('picked', picked);
|
||||||
pickCount += picked ? 1 : -1;
|
pickCount += picked ? 1 : -1;
|
||||||
document.getElementById('pick-count').textContent = pickCount + ' på seddel';
|
updatePick();
|
||||||
try {
|
try {
|
||||||
await (window.cittiFetch || fetch)('/api/offers/pick', {
|
await (window.cittiFetch || fetch)('/api/offers/pick', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -135,7 +148,7 @@ async function togglePick(cb, id) {
|
|||||||
cb.checked = !picked;
|
cb.checked = !picked;
|
||||||
cb.closest('.offer').classList.toggle('picked', !picked);
|
cb.closest('.offer').classList.toggle('picked', !picked);
|
||||||
pickCount += picked ? -1 : 1;
|
pickCount += picked ? -1 : 1;
|
||||||
document.getElementById('pick-count').textContent = pickCount + ' på seddel';
|
updatePick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,6 +179,8 @@ async function refreshOffers() {
|
|||||||
btn.textContent = '⟳ Opdater'; btn.disabled = false;
|
btn.textContent = '⟳ Opdater'; btn.disabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updatePick();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user