blob: 409fa5b5f9ba0d42d9df9fc1c48ef8995b2d1b8c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
for (const a of document.getElementById("links").getElementsByTagName("a")) {
a.addEventListener("click", e => {
const path = a.getAttribute("href").replace("#", "")
loadPage(path)
e.preventDefault()
})
}
function loadPage(path) {
for (const section of document.getElementById("pages").getElementsByTagName("section")) section.style.display = "none"
document.getElementById(`${path}_page`).style.display = "block"
for (const a of document.getElementById("links").getElementsByTagName("a"))
if (a.getAttribute("href") == `#${path}`) a.classList.add("selected")
else a.classList.remove("selected")
let stateObj = { id: "100" }
window.history.pushState(stateObj, "Page 2", `/pages/options/index.html#${path}`)
}
const r = window.location.href.match(/#(.*)/)
if (r) loadPage(r[1])
else loadPage("general")
|