21 lines
537 B
JavaScript
21 lines
537 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 !== "c" && e.key !== "C") return;
|
|
await fetch("/capture");
|
|
refreshGallery();
|
|
});
|
|
|
|
refreshGallery();
|
|
setInterval(refreshGallery, 10000);
|