Skip to content

Instantly share code, notes, and snippets.

@pksbogastro
Created March 13, 2026 17:24
Show Gist options
  • Select an option

  • Save pksbogastro/ddb59f2e0db7d4240009f50ca17ebc6c to your computer and use it in GitHub Desktop.

Select an option

Save pksbogastro/ddb59f2e0db7d4240009f50ca17ebc6c to your computer and use it in GitHub Desktop.
Einkaufen
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Einkaufsliste Foodtruck</title>
<style>
body { font-family: sans-serif; background: #f4f7f6; margin: 0; padding: 10px; text-align: center; }
.card { background: white; padding: 15px; border-radius: 16px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); margin-bottom: 12px; }
select { width: 100%; padding: 14px; font-size: 18px; border: 2px solid #2196F3; border-radius: 12px; margin-bottom: 12px; background: white; }
.btn { width: 100%; padding: 16px; border: none; border-radius: 12px; font-weight: bold; font-size: 16px; margin: 6px 0; cursor: pointer; color: white; display: flex; align-items: center; justify-content: center; }
.btn-row { display: flex; justify-content: space-between; gap: 10px; }
.btn-small { width: 48%; }
.btn-gray { background: #e0e0e0; color: #333; }
.btn-red { background: #ff5252; }
.btn-green { background: #4CAF50; }
.btn-blue { background: #2196F3; }
.btn-orange { background: #FF9800; }
#admin-area { display: none; padding: 15px; border: 2px dashed #ddd; border-radius: 12px; margin-top: 10px; background: #fafafa; }
input { width: 100%; padding: 12px; margin-bottom: 10px; border-radius: 8px; border: 1px solid #ccc; box-sizing: border-box; font-size: 16px; }
.item { background: white; padding: 12px; border-radius: 12px; margin-bottom: 8px; display: flex; align-items: center; text-align: left; border: 1px solid #e0e0e0; position: relative; min-height: 90px; }
.item img { width: 100px; height: 75px; object-fit: cover; border-radius: 8px; margin-right: 15px; background: #eee; flex-shrink: 0; }
.item-info { flex-grow: 1; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.edit-name { font-size: 1.2em; font-weight: bold; border: none; background: transparent; color: #333; flex-grow: 1; outline: none; }
.edit-qty { width: 60px; height: 45px; border: 1px solid #ccc; border-radius: 10px; text-align: center; font-size: 1.1em; background: white; color: #333; }
.shop-checked { opacity: 0.25; filter: grayscale(100%); text-decoration: line-through; }
#img-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 1000; justify-content: center; align-items: center; }
#img-overlay img { max-width: 95%; max-height: 95%; border-radius: 10px; }
.del-btn { position: absolute; top: -5px; right: -5px; background: #ff5252; color: white; width: 28px; height: 28px; border-radius: 50%; font-size: 20px; line-height: 26px; text-align: center; cursor: pointer; border: 2px solid white; z-index: 5; }
</style>
</head>
<body>
<div id="img-overlay" onclick="this.style.display='none'"><img id="full-img" src=""></div>
<div class="card">
<select id="listSelect" onchange="updateList()"></select>
<div class="btn-row">
<button class="btn btn-gray btn-small" onclick="addList()">+ Neue Liste</button>
<button class="btn btn-red btn-small" onclick="removeList()">Liste löschen</button>
</div>
</div>
<div class="card">
<button class="btn btn-green" onclick="toggleAdd()">➕ Artikel hinzufügen</button>
<div id="admin-area">
<input type="text" id="nameInp" placeholder="Name">
<input type="file" id="imgInp" accept="image/*">
<button class="btn btn-green" onclick="saveNew()">SPEICHERN</button>
</div>
<button id="modeBtn" class="btn btn-blue" onclick="switchMode()">➡️ Einkaufsmodus</button>
<button class="btn btn-orange" onclick="resetMarkers()">🔄 Alle auf Null</button>
</div>
<div id="listCont"></div>
<script>
var K = 'foodTruckData';
var d = JSON.parse(localStorage.getItem(K)) || { active: "Foodtruck", lists: { "Foodtruck": [] }, shop: false };
function render() {
var sel = document.getElementById('listSelect');
sel.innerHTML = '';
for (var n in d.lists) {
var o = document.createElement('option'); o.value = n; o.innerText = n;
if(n === d.active) o.selected = true;
sel.appendChild(o);
}
document.getElementById('modeBtn').innerText = d.shop ? "🛒 Planungsmodus" : "➡️ Einkaufsmodus";
var cont = document.getElementById('listCont');
cont.innerHTML = '';
var items = d.lists[d.active] || [];
for (var i = 0; i < items.length; i++) {
(function(idx) {
var it = items[idx];
var div = document.createElement('div');
div.className = 'item' + (it.done ? ' shop-checked' : '');
if(d.shop) div.onclick = function() { it.done = !it.done; save(); };
div.innerHTML = (it.img ? '<img src="'+it.img+'" onclick="event.stopPropagation(); showBig(this.src)">' : '<div style="width:100px;height:75px;margin-right:15px;background:#eee;border-radius:8px;flex-shrink:0;"></div>') +
'<div class="item-info">' +
'<input type="text" class="edit-name" value="'+it.name+'" '+(d.shop ? 'disabled' : '')+' oninput="d.lists[d.active]['+idx+'].name=this.value; sync()">' +
'<input type="text" class="edit-qty" value="'+(it.qty||'0')+'" '+(d.shop ? 'disabled' : '')+' onclick="event.stopPropagation()" oninput="d.lists[d.active]['+idx+'].qty=this.value; sync()">' +
'</div>' +
'<span class="del-btn" onclick="event.stopPropagation(); delItem('+idx+')">×</span>';
cont.appendChild(div);
})(i);
}
}
window.showBig = function(src) { document.getElementById('
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment