marc/test.js

30 lines
619 B
JavaScript
Raw Normal View History

2023-06-30 17:58:43 +00:00
function check(tab) {
const tabs = tab.split('/')
let path = 'tab'
for (tab of tabs) {
path = `${path}/${tab}`
document.getElementById(path).checked = true
}
}
function push(tab) {
window.history.pushState(null, null, `?tab=${tab}`)
}
function update(id) {
const tab = id.split('/').slice(1).join('/')
push(tab)
}
function main() {
let tab = (new URL(document.location)).searchParams.get('tab')
if (tab) {
check(tab)
} else {
tab = '1/1'
check(tab)
push(tab)
}
}
2023-06-30 20:07:10 +00:00
function swap() {
document.body.classList.toggle('dark')
}