summaryrefslogtreecommitdiff
path: root/src/index.js
blob: 6e35fa3048e963ff0c72d4d7144f46c54146606e (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import "./style.css"
import "./icons.js"
import initSlides from "./slides.js"

initSlides()

const apiKey = "m5nqOoBc4uhAba21gZdCP3z8D3JT4GPxDXL2psd52EA"
console.log(apiKey)
const testDiv = document.querySelector("main div")

function showAlbums() {
	testDiv.innerHTML
}

function pathnameCallback(e) {
	console.log(e)
	//testDiv.innerHTML = ""
	//switch (window.location.pathname) {
	//	case "/":
	//		testDiv.innerHTML = "<p>Hello first page</p>"
	//	break ;;
	//	case "/albums":
	//		testDiv.innerHTML = "<p>Hello albums page</p>"
	//	break ;;
	//	case "/settings":
	//		testDiv.innerHTML = "<p>Hello settings page</p>"
	//	break ;;
	//}
}
window.addEventListener("popstate", pathnameCallback)
pathnameCallback()

/* add event listeners for anchor elements in footer */
function softRedirect(e) {
	e.preventDefault()
	let a = e.target
	while (a.tagName !== "A" && a !== null)
		a = a.parentElement
	window.history.pushState({}, "", a.href);
	pathnameCallback()
}

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