diff options
author | tdro <tdro@noreply.example.com> | 2023-06-08 18:29:14 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2023-06-08 18:29:14 -0400 |
commit | e4b5feb737231d004381f041039c2967ab4dc5cc (patch) | |
tree | 708909aaa1bdb7a62579e1f1985824f4a3aaa0fa /static | |
parent | 50ff76ccb3e6d39adf745357e8f7bc6c97cdc6ea (diff) | |
download | canory-e4b5feb737231d004381f041039c2967ab4dc5cc.tar.gz canory-e4b5feb737231d004381f041039c2967ab4dc5cc.tar.bz2 canory-e4b5feb737231d004381f041039c2967ab4dc5cc.zip |
static/js/pager: Define key
Diffstat (limited to 'static')
-rw-r--r-- | static/js/pager.ts | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/static/js/pager.ts b/static/js/pager.ts index 8b89897..c685cb1 100644 --- a/static/js/pager.ts +++ b/static/js/pager.ts @@ -9,18 +9,19 @@ let settings = { pager: {} }; + const key = "settings"; const url = self.location.href.split("#")[0].split("?")[0]; const scrollRestore = function (url) { if (history.scrollRestoration) history.scrollRestoration = "manual"; - if (localStorage["settings"]) { - settings = JSON.parse(localStorage["settings"]); + if (localStorage[key]) { + settings = JSON.parse(localStorage[key]); } const fragment = document.getElementById(location.hash.slice(1)); const fragmentInURL = self.location.hash.length > 0; if (fragmentInURL && document.body.contains(fragment)) { settings["pager"][url] = self.pageYOffset; - localStorage["settings"] = JSON.stringify(settings); + localStorage[key] = JSON.stringify(settings); fragment.scrollIntoView(); self.addEventListener("load", function () { fragment.scrollIntoView(); @@ -32,13 +33,13 @@ return; } settings["pager"][url] = self.pageYOffset; - localStorage["settings"] = JSON.stringify(settings); + localStorage[key] = JSON.stringify(settings); }; const scrollTrack = function (url) { const currentPosition = self.pageYOffset; settings["pager"][url] = currentPosition; - localStorage["settings"] = JSON.stringify(settings); + localStorage[key] = JSON.stringify(settings); }; const backTrack = function (back, up, event) { |