From aa632bfd84173aadc297bf33a1f6816c68932afd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 30 Jun 2023 19:58:43 +0200 Subject: [PATCH] ext/js --- test.html | 29 +---------------------------- test.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 28 deletions(-) create mode 100644 test.js 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) + } +}