Photo-based book cataloger with AI identification. Room → Cabinet → Shelf → Book hierarchy; FastAPI + SQLite backend; vanilla JS SPA; OpenAI-compatible plugin system for boundary detection, text recognition, and archive search.
22 lines
804 B
JavaScript
22 lines
804 B
JavaScript
/*
|
|
* helpers.js
|
|
* Pure utility functions with no dependencies on other application modules.
|
|
* Safe to call from any JS file.
|
|
*
|
|
* Provides: esc(), toast(), isDesktop()
|
|
*/
|
|
|
|
// ── Helpers ─────────────────────────────────────────────────────────────────
|
|
function esc(s) {
|
|
return String(s ?? '').replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
|
|
}
|
|
|
|
function toast(msg, dur = 2800) {
|
|
const el = document.getElementById('toast');
|
|
el.textContent = msg; el.classList.add('on');
|
|
clearTimeout(toast._t);
|
|
toast._t = setTimeout(() => el.classList.remove('on'), dur);
|
|
}
|
|
|
|
function isDesktop() { return window.innerWidth >= 768; }
|