diff --git a/test.html b/test.html index c8951fc..bcf1c9f 100644 --- a/test.html +++ b/test.html @@ -4,6 +4,7 @@ + - diff --git a/test.js b/test.js new file mode 100644 index 0000000..ca31308 --- /dev/null +++ b/test.js @@ -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) + } +}