aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2024-09-19 00:00:00 +0000
committertdro <tdro@noreply.example.com>2024-09-19 00:00:00 +0000
commit60151f1f2f5f4a81122bccc4d833144caffb3df6 (patch)
tree59ce3d403a5cba594d0a9c1ce8049e18f7f6614c
parent8281b1f7abf47caaa3304de248ed964e0eeefbf6 (diff)
downloadcanory-60151f1f2f5f4a81122bccc4d833144caffb3df6.tar.gz
canory-60151f1f2f5f4a81122bccc4d833144caffb3df6.tar.bz2
canory-60151f1f2f5f4a81122bccc4d833144caffb3df6.zip
static/js: Fix strict mode violations
-rw-r--r--assets/js/index.js67
-rw-r--r--static/js/autoplay.ts4
-rw-r--r--static/js/hoverfix.ts2
-rw-r--r--static/js/index.ts1
-rw-r--r--static/js/strict.ts1
5 files changed, 39 insertions, 36 deletions
diff --git a/assets/js/index.js b/assets/js/index.js
index ff7e33a..8fdab5a 100644
--- a/assets/js/index.js
+++ b/assets/js/index.js
@@ -1,3 +1,4 @@
+"use strict";
(function() {
const cookiesDisabled = !navigator.cookieEnabled;
if (cookiesDisabled) return console.warn("WARNING: Pager disabled due to cookie restrictions");
@@ -29,10 +30,10 @@
if (pager[url] > 0) {
clearInterval(seek);
self.scrollTo(0, pager[url]);
- let i1 = 0;
+ let i = 0;
return seek = setInterval(function(position) {
- i1++;
- if (i1 > 100) clearInterval(seek);
+ i++;
+ if (i > 100) clearInterval(seek);
if (document.documentElement.scrollHeight >= position + document.documentElement.clientHeight) {
clearInterval(seek);
self.scrollTo(0, position);
@@ -262,14 +263,14 @@
})();
(function() {
const hide = function(triggers) {
- for(let i1 = 0; i1 < triggers.length; i1++){
- triggers[i1].checked = false;
+ for(let i = 0; i < triggers.length; i++){
+ triggers[i].checked = false;
}
};
const hideIfClickedOutside = function(menus, triggers, event) {
- for(let i1 = 0; i1 < menus.length; i1++){
- const active = triggers[i1].checked === true;
- const outside = !menus[i1].contains(event.target);
+ for(let i = 0; i < menus.length; i++){
+ const active = triggers[i].checked === true;
+ const outside = !menus[i].contains(event.target);
if (outside && active) hide(triggers);
}
};
@@ -550,8 +551,8 @@
].forEach(function(event) {
self.addEventListener(event, function() {
let first = true;
- let videos = document.querySelectorAll("video");
- for(i = 0; i < videos.length; i++){
+ const videos = document.querySelectorAll("video");
+ for(let i = 0; i < videos.length; i++){
videos[i].autoplay = true;
videos[i].controls = true;
videos[i].loop = true;
@@ -591,14 +592,14 @@
}
const disabled = "0s";
function walk(children, callback) {
- for(let i1 = 0; i1 < children.length; i1++){
- callback(children[i1]);
- walk(children[i1].children, callback);
+ for(let i = 0; i < children.length; i++){
+ callback(children[i]);
+ walk(children[i].children, callback);
}
}
self.addEventListener("mousemove", function(event) {
if (typeof event.target.closest !== "function") return;
- tree = event.target.closest("figure") || event.target.closest("article");
+ const tree = event.target.closest("figure") || event.target.closest("article");
if (tree !== null) {
walk(tree.children, function(element) {
const delay = self.getComputedStyle(element).getPropertyValue("transition-delay");
@@ -632,8 +633,8 @@
const textarea = Array.prototype.slice.call(document.querySelectorAll("form textarea"));
const summary = Array.prototype.slice.call(document.querySelectorAll("details summary"));
const states = input.concat(select).concat(textarea);
- for(var i1 = 0; i1 < states.length; i1++){
- const state = states[i1];
+ for(var i = 0; i < states.length; i++){
+ const state = states[i];
if (localStorage[state.id]) {
if (state.type === "radio" || state.type === "checkbox") {
if (localStorage[state.id] === "on") state.checked = true;
@@ -681,8 +682,8 @@
stylesheet = document.querySelector('link[href$="default-fast.css"]');
if (localStorage["config.navigation.fast"] === "on") stylesheet.rel = "stylesheet";
if (localStorage["config.navigation.slow"] === "on") stylesheet.rel = "alternate stylesheet";
- for(var i1 = 0; i1 < document.styleSheets.length; i1++){
- let stylesheet = document.styleSheets[i1];
+ for(var i = 0; i < document.styleSheets.length; i++){
+ let stylesheet = document.styleSheets[i];
if (!stylesheet.href || !stylesheet.href.startsWith(self.origin)) continue;
for(var k = 0; k < stylesheet.rules.length; k++){
let media = stylesheet.rules[k].media;
@@ -796,20 +797,20 @@
self.addEventListener("click", function(event) {
if (localStorage[key] !== state) return;
const links = document.querySelectorAll("a");
- for(let i1 = 0; i1 < links.length; i1++){
- const active = links[i1].contains(event.target);
- const change = self.location.href !== links[i1].href;
- const view = links[i1].attributes.hasOwnProperty("download") === false;
- const local = self.location.origin === links[i1].origin && links[i1].target !== "_self";
- const hashed = self.location.pathname === links[i1].pathname && links[i1].href.includes("#");
+ for(let i = 0; i < links.length; i++){
+ const active = links[i].contains(event.target);
+ const change = self.location.href !== links[i].href;
+ const view = links[i].attributes.hasOwnProperty("download") === false;
+ const local = self.location.origin === links[i].origin && links[i].target !== "_self";
+ const hashed = self.location.pathname === links[i].pathname && links[i].href.includes("#");
if (active && local && change && view && hashed === false) {
event.preventDefault();
- const url = links[i1].href;
- links[i1].style.cursor = "wait";
+ const url = links[i].href;
+ links[i].style.cursor = "wait";
fetch(url, "GET", function(http) {
- links[i1].removeAttribute("style");
+ links[i].removeAttribute("style");
if (filter(url, http) === false) return self.location.href = url;
- history.pushState({}, "", links[i1].href);
+ history.pushState({}, "", links[i].href);
persist();
self.document.dispatchEvent(new CustomEvent("URLChangedCustomEvent", {
bubbles: true
@@ -863,7 +864,7 @@
const page = new DOMParser().parseFromString(http.responseText, "text/html");
const items = Array.prototype.slice.call(page.querySelector("main").children);
const paginate = page.querySelector('[data-type="pagination"]');
- for(var i1 = 0; i1 < items.length; i1++)main.appendChild(items[i1]);
+ for(var i = 0; i < items.length; i++)main.appendChild(items[i]);
self.document.dispatchEvent(new CustomEvent("FormsCustomEvent", {
bubbles: true
}));
@@ -892,9 +893,9 @@
}
const date = function(update) {
const elements = document.querySelectorAll("time");
- for(let i1 = 0; i1 < elements.length; ++i1){
- const offscreen = !viewport(elements[i1]);
- const hidden = elements[i1].offsetParent === null;
+ for(let i = 0; i < elements.length; ++i){
+ const offscreen = !viewport(elements[i]);
+ const hidden = elements[i].offsetParent === null;
if (update === "viewport" && (offscreen || hidden)) continue;
(function(element) {
try {
@@ -959,7 +960,7 @@
} catch (error) {
console.error("ERROR: Relative time resolution failed", error);
}
- })(elements[i1]);
+ })(elements[i]);
}
};
const substitution = setInterval(date, 4);
diff --git a/static/js/autoplay.ts b/static/js/autoplay.ts
index ce11215..d212e76 100644
--- a/static/js/autoplay.ts
+++ b/static/js/autoplay.ts
@@ -24,9 +24,9 @@
self.addEventListener(event, function () {
let first = true;
- let videos = document.querySelectorAll("video");
+ const videos = document.querySelectorAll("video");
- for (i = 0; i < videos.length; i++) {
+ for (let i = 0; i < videos.length; i++) {
videos[i].autoplay = true;
videos[i].controls = true;
videos[i].loop = true;
diff --git a/static/js/hoverfix.ts b/static/js/hoverfix.ts
index b6d1a5b..6cd7be9 100644
--- a/static/js/hoverfix.ts
+++ b/static/js/hoverfix.ts
@@ -39,7 +39,7 @@
self.addEventListener("mousemove", function (event) {
if (typeof event.target.closest !== "function") return;
- tree = event.target.closest("figure") || event.target.closest("article");
+ const tree = event.target.closest("figure") || event.target.closest("article");
if (tree !== null) {
walk(tree.children, function (element) {
diff --git a/static/js/index.ts b/static/js/index.ts
index a280ca4..4cc34a9 100644
--- a/static/js/index.ts
+++ b/static/js/index.ts
@@ -1,3 +1,4 @@
+import "./strict.ts";
import "./pager.ts";
import "./update.ts";
import "./plumber.ts";
diff --git a/static/js/strict.ts b/static/js/strict.ts
new file mode 100644
index 0000000..3918c74
--- /dev/null
+++ b/static/js/strict.ts
@@ -0,0 +1 @@
+"use strict";