aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2024-10-19 00:00:00 +0000
committertdro <tdro@noreply.example.com>2024-10-19 00:00:00 +0000
commit3e556a06cde9ba1844fb67e153d2dccf5df65458 (patch)
treedf5663d42b46b92dda2f40fe347437c50ef0bbb9
parent89141509513c69ade16163f635858d9d7151b735 (diff)
downloadcanory-3e556a06cde9ba1844fb67e153d2dccf5df65458.tar.gz
canory-3e556a06cde9ba1844fb67e153d2dccf5df65458.tar.bz2
canory-3e556a06cde9ba1844fb67e153d2dccf5df65458.zip
static/js/domfilter: Default to off
-rw-r--r--assets/js/index.js7
-rw-r--r--static/js/domfilter.ts8
2 files changed, 9 insertions, 6 deletions
diff --git a/assets/js/index.js b/assets/js/index.js
index 5c08da2..b415a23 100644
--- a/assets/js/index.js
+++ b/assets/js/index.js
@@ -730,8 +730,9 @@
const cookiesDisabled = !navigator.cookieEnabled;
if (cookiesDisabled) return console.warn("WARNING: DOM filter disabled due to cookie restrictions");
const timeout = 300;
- const state = "on";
+ const state = "off";
const key = "config.navigation.fast";
+ if (!localStorage[key]) localStorage[key] = state;
function fetch(url, method, callback) {
const http = new XMLHttpRequest();
http.onreadystatechange = function() {
@@ -791,7 +792,7 @@
persist();
});
self.addEventListener("popstate", function(event) {
- if (localStorage[key] !== state || !document.querySelector('link[rel="location"]')) return;
+ if (!localStorage[key] || localStorage[key] === state || !document.querySelector('link[rel="location"]')) return;
const link = JSON.parse(document.querySelector('link[rel="location"]').target);
const url = event.target.location;
const hashed = link.pathname === url.pathname;
@@ -805,7 +806,7 @@
});
});
self.addEventListener("click", function(event) {
- if (localStorage[key] !== state) return;
+ if (!localStorage[key] || localStorage[key] === state) return;
const links = document.querySelectorAll("a");
for(let i = 0; i < links.length; i++){
const active = links[i].contains(event.target);
diff --git a/static/js/domfilter.ts b/static/js/domfilter.ts
index 2be690d..e0b6cdc 100644
--- a/static/js/domfilter.ts
+++ b/static/js/domfilter.ts
@@ -12,9 +12,11 @@
type millisecond = number;
const timeout: millisecond = 300;
- const state = "on";
+ const state = "off";
const key = "config.navigation.fast";
+ if (!localStorage[key]) localStorage[key] = state;
+
function fetch(url, method, callback) {
const http = new XMLHttpRequest();
http.onreadystatechange = function () {
@@ -95,7 +97,7 @@
});
self.addEventListener("popstate", function (event) {
- if (localStorage[key] !== state || !document.querySelector('link[rel="location"]')) return;
+ if (!localStorage[key] || localStorage[key] === state || !document.querySelector('link[rel="location"]')) return;
const link = JSON.parse(document.querySelector('link[rel="location"]').target);
const url = event.target.location;
const hashed = link.pathname === url.pathname;
@@ -108,7 +110,7 @@
});
self.addEventListener("click", function (event) {
- if (localStorage[key] !== state) return;
+ if (!localStorage[key] || localStorage[key] === state) return;
const links = document.querySelectorAll("a");
for (let i = 0; i < links.length; i++) {
const active = links[i].contains(event.target);