Files
photo_booth/camera/static/script.js
T
2026-06-02 22:54:55 +02:00

31 lines
768 B
JavaScript

async function refreshGallery() {
const res = await fetch("/photos");
const files = await res.json();
const gallery = document.getElementById("gallery");
if (files.length === 0) return;
gallery.innerHTML = files
.map((f) => `<img src="/photo/${f}" alt="${f}" title="${f}">`)
.join("");
}
document.addEventListener("keydown", async (e) => {
if (e.key !== ">") return;
const flash = document.getElementById("flash");
flash.classList.remove("fade");
flash.classList.add("active");
await new Promise((r) => setTimeout(r, 300));
await fetch("/capture");
flash.classList.remove("active");
flash.classList.add("fade");
refreshGallery();
});
refreshGallery();
setInterval(refreshGallery, 10000);