ext/js
This commit is contained in:
parent
683d799c04
commit
aa632bfd84
2 changed files with 29 additions and 28 deletions
29
test.html
29
test.html
|
@ -4,6 +4,7 @@
|
|||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="initial-scale=1,width=device-width" />
|
||||
<link rel="stylesheet" href="test.css" />
|
||||
<script type="text/javascript" src="test.js" />
|
||||
|
||||
<!----------------------------------------------------------------------------->
|
||||
</head>
|
||||
|
@ -53,33 +54,5 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<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) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!----------------------------------------------------------------------------->
|
||||
</main></body></html>
|
||||
|
|
28
test.js
Normal file
28
test.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
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)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue