wip
This commit is contained in:
parent
b804078f3c
commit
90d094a93f
1 changed files with 18 additions and 9 deletions
27
test.html
27
test.html
|
@ -54,19 +54,28 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
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) {
|
||||||
|
const tb = tab.split('/').slice(1).join('/')
|
||||||
|
window.history.pushState(null, null, `?tab=${tb}`)
|
||||||
|
}
|
||||||
function update(id) {
|
function update(id) {
|
||||||
let tabs = id.split('/').slice(1)
|
push(id)
|
||||||
window.history.pushState(null, null, `?tab=${tabs.join('/')}`)
|
|
||||||
}
|
}
|
||||||
function main() {
|
function main() {
|
||||||
let tab = (new URL(document.location)).searchParams.get('tab')
|
const tab = (new URL(document.location)).searchParams.get('tab')
|
||||||
if (tab) {
|
if (tab) {
|
||||||
let path = 'tab'
|
check(tab)
|
||||||
let tabs = tab.split('/')
|
} else {
|
||||||
for (tab of tabs) {
|
check('1/1')
|
||||||
path = `${path}/${tab}`
|
push('tab/1/1')
|
||||||
document.getElementById(path).checked = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue