summaryrefslogtreecommitdiff
path: root/static/src/index.js
blob: 7d7c9db498d356b7998109cf8d09d0f1d3583591 (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
29
import "@fontsource/overpass"
import "@fontsource/overpass/700.css"
import "@fontsource/overpass/500.css"
import "./style.css"
import Page from "./pages.js"
import "./icons.js"
import initSlides from "./slides.js"
import initAlbums from "./albums.js"
import initSettings from "./settings.js"

const slideshow = new Page(document.querySelector("#slideshow"), ["", "/slideshow"], initSlides)
const albums    = new Page(document.querySelector("#albums"),    ["/albums"],        initAlbums)
const settings  = new Page(document.querySelector("#settings"),  ["/settings"],      initSettings)

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 !== null && a.tagName !== "A")
		a = a.parentElement
	if (a === null) return
	Page.softRedirect(a.href)
}

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