/* ======================================================================= File: static/js/app.js Purpose: Global utility functions shared across all scripts. No page-specific logic here. ======================================================================= */ // Shortcuts const $ = (sel, parent = document) => parent.querySelector(sel); const $$ = (sel, parent = document) => parent.querySelectorAll(sel); // Safe log function dbg(...args) { console.log("[APP]", ...args); } // AJAX helper async function apiGet(url) { try { const res = await fetch(url, { cache: "no-store" }); if (!res.ok) throw new Error(`HTTP ${res.status}`); return await res.json(); } catch (err) { console.error("API GET Error:", url, err); return null; } } // Auto-scroll utility function autoScroll(el) { if (!el) return; el.scrollTop = el.scrollHeight; }