aboutsummaryrefslogtreecommitdiff
path: root/assets/js/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js/index.js')
-rw-r--r--assets/js/index.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/assets/js/index.js b/assets/js/index.js
index 7be41db..89bc1c8 100644
--- a/assets/js/index.js
+++ b/assets/js/index.js
@@ -8,17 +8,18 @@
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();
@@ -30,12 +31,12 @@
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) {
if (document.body.contains(up) && up.contains(event.target)) {