aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/js/index.js11
-rw-r--r--static/js/pager.ts11
2 files changed, 12 insertions, 10 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)) {
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) {