Files
bookshelf/static/js/helpers.js
night 5d5f26c8ae 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.
2026-03-09 14:16:23 +03:00

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,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;');
}
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; }