You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
894 B
34 lines
894 B
/* =======================================================================
|
|
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;
|
|
}
|