summaryrefslogtreecommitdiff
path: root/src/index.js
blob: cac7bf439c840800c7829869909fc1a8e06dac4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import "./style.css"
import ImmichConnector from "./immich.js"
import Page from "./pages.js"
import "./icons.js"
import initSlides from "./slides.js"

const immichConnector = new ImmichConnector("http://192.168.1.13", "m5nqOoBc4uhAba21gZdCP3z8D3JT4GPxDXL2psd52EA")
document.immichConnector = immichConnector // FIXME TEMP

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")

window.addEventListener("popstate", Page.pathnameCallback)
Page.pathnameCallback() /* run after all pages are registered */

/* 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
	Page.softRedirect(a.href)
}

document.querySelector("#menu").addEventListener("click", softRedirect)