From e943375d74ce8d48b8ad40b1a5d05437ca4f5c7f Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Mon, 5 May 2025 20:38:42 -0500 Subject: add immich api class and page class --- src/index.js | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) (limited to 'src/index.js') diff --git a/src/index.js b/src/index.js index 6e35fa3..e6a4dc3 100644 --- a/src/index.js +++ b/src/index.js @@ -1,43 +1,29 @@ import "./style.css" +import ImmichConnector from "./immich.js" +import Page from "./pages.js" import "./icons.js" import initSlides from "./slides.js" -initSlides() +const immichConnector = new ImmichConnector("http://192.168.1.13", "m5nqOoBc4uhAba21gZdCP3z8D3JT4GPxDXL2psd52EA") +document.immichConnector = immichConnector // FIXME TEMP -const apiKey = "m5nqOoBc4uhAba21gZdCP3z8D3JT4GPxDXL2psd52EA" -console.log(apiKey) -const testDiv = document.querySelector("main div") +const slideshow = new Page(document.querySelector("#slideshow"), "/slideshow", initSlides) +const albums = new Page(document.querySelector("#albums"), "/albums") +const settings = new Page(document.querySelector("#settings"), "/settings") -function showAlbums() { - testDiv.innerHTML -} - -function pathnameCallback(e) { - console.log(e) - //testDiv.innerHTML = "" - //switch (window.location.pathname) { - // case "/": - // testDiv.innerHTML = "

Hello first page

" - // break ;; - // case "/albums": - // testDiv.innerHTML = "

Hello albums page

" - // break ;; - // case "/settings": - // testDiv.innerHTML = "

Hello settings page

" - // break ;; - //} -} -window.addEventListener("popstate", pathnameCallback) -pathnameCallback() +window.addEventListener("popstate", Page.pathnameCallback) +Page.pathnameCallback() /* add event listeners for anchor elements in footer */ function softRedirect(e) { e.preventDefault() let a = e.target + if (a === null) return while (a.tagName !== "A" && a !== null) a = a.parentElement + if (a === null) return window.history.pushState({}, "", a.href); - pathnameCallback() + Page.pathnameCallback() } document.querySelector("#menu").addEventListener("click", softRedirect) -- cgit v1.2.3