Initial commit
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.
This commit is contained in:
21
static/js/helpers.js
Normal file
21
static/js/helpers.js
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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; }
|
||||
Reference in New Issue
Block a user