diff --git a/app.js b/app.js new file mode 100644 index 0000000..cdffdec --- /dev/null +++ b/app.js @@ -0,0 +1,37 @@ +// Kitchen display: poll open orders and render them oldest-first so the +// pass works the tickets in the order they landed. Kiosk mode, no input. +const POLL_MS = 2000; +const root = document.getElementById("orders"); + +function ageClass(placedAt) { + const mins = (Date.now() - new Date(placedAt).getTime()) / 60000; + if (mins > 8) return "ticket late"; + if (mins > 4) return "ticket warn"; + return "ticket"; +} + +function render(orders) { + orders.sort((a, b) => new Date(a.placed_at) - new Date(b.placed_at)); + root.innerHTML = ""; + for (const o of orders) { + const el = document.createElement("div"); + el.className = ageClass(o.placed_at); + el.innerHTML = + `