Skip to content

Commit d5de07d

Browse files
committed
build(javascript): fix scopes using let and const
1 parent 89c2b42 commit d5de07d

26 files changed

+64
-58
lines changed

.biome.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
2+
"$schema": "https://biomejs.dev/schemas/2.2.4/schema.json",
23
"formatter": {
34
"indentStyle": "space",
45
"indentWidth": 2
6+
},
7+
"vcs": {
8+
"enabled": true,
9+
"clientKind": "git",
10+
"useIgnoreFile": true
511
}
612
}

docs/javascripts/fill.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ async function init(path) {
3636
document.getElementById("plaintext").value,
3737
);
3838
};
39-
var content = [];
39+
const content = [];
4040
console.debug("Fetching index");
41-
var index = await fetch(
41+
const index = await fetch(
4242
"https://raw.githubusercontent.com/" +
4343
path +
4444
"/main/javascripts/index.json",
@@ -49,17 +49,17 @@ async function init(path) {
4949
.catch(console.error);
5050
console.debug("Fetched index");
5151
content.push(document.createElement("hr"));
52-
var toc = document.createElement("section");
52+
const toc = document.createElement("section");
5353
content.push(toc);
5454
toc.id = "toc";
55-
var ttoc = document.createElement("h3");
55+
const ttoc = document.createElement("h3");
5656
toc.appendChild(ttoc);
5757
ttoc.textContent = "Examples (" + index.length + ")";
58-
var ul = document.createElement("ul");
58+
const ul = document.createElement("ul");
5959
toc.appendChild(ul);
60-
var i;
60+
let i;
6161
for (i = 0; i < index.length; i++) {
62-
var li = document.createElement("li");
62+
const li = document.createElement("li");
6363
ul.appendChild(li);
6464
li.innerHTML =
6565
'<a href="#' +
@@ -68,30 +68,30 @@ async function init(path) {
6868
index[i].name +
6969
"</a>";
7070
}
71-
var loading = document.getElementById("loading");
72-
var j;
71+
const loading = document.getElementById("loading");
72+
let j;
7373
for (j = 0; j < index.length; j++) {
7474
loading.textContent += ".";
7575
content.push(document.createElement("hr"));
7676
console.debug("Adding " + index[j].name);
77-
var bookmarklet = document.createElement("section");
77+
const bookmarklet = document.createElement("section");
7878
content.push(bookmarklet);
7979
bookmarklet.className = "bookmarklet";
80-
var title = document.createElement("h3");
80+
const title = document.createElement("h3");
8181
bookmarklet.appendChild(title);
82-
var tlink = document.createElement("a");
82+
const tlink = document.createElement("a");
8383
title.appendChild(tlink);
8484
tlink.className = "name";
8585
tlink.id = normalize(index[j].name);
8686
tlink.textContent = index[j].name;
87-
var desc = document.createElement("h4");
87+
const desc = document.createElement("h4");
8888
bookmarklet.appendChild(desc);
8989
desc.textContent = "Description";
90-
var description = document.createElement("p");
90+
const description = document.createElement("p");
9191
bookmarklet.appendChild(description);
9292
description.textContent = index[j].description;
9393
console.debug("Fetching source code for " + index[j].name);
94-
var js = await fetch(
94+
const js = await fetch(
9595
"https://raw.githubusercontent.com/" +
9696
path +
9797
"/main/javascripts/" +
@@ -103,36 +103,36 @@ async function init(path) {
103103
})
104104
.catch(console.error);
105105
console.debug("Fetched source code for " + index[j].name);
106-
var book = document.createElement("h4");
106+
const book = document.createElement("h4");
107107
bookmarklet.appendChild(book);
108108
book.textContent = "Bookmarklet";
109-
var instructions = document.createElement("p");
109+
const instructions = document.createElement("p");
110110
bookmarklet.appendChild(instructions);
111111
instructions.innerHTML =
112112
'Drag and drop or bookmark this link: <a href="' +
113113
minify(js) +
114114
'">' +
115115
index[j].name +
116116
"</a>";
117-
var code = document.createElement("h4");
117+
const code = document.createElement("h4");
118118
bookmarklet.appendChild(code);
119119
code.textContent = "Source code";
120-
var pre = document.createElement("pre");
120+
const pre = document.createElement("pre");
121121
bookmarklet.appendChild(pre);
122122
pre.className = "highlight";
123-
var source = document.createElement("code");
123+
const source = document.createElement("code");
124124
pre.appendChild(source);
125125
source.textContent = js.trim();
126-
var edit = document.createElement("a");
126+
const edit = document.createElement("a");
127127
bookmarklet.appendChild(edit);
128128
edit.textContent = "Edit it!";
129129
edit.href = "#editor";
130130
edit.onclick = (function (a1, a2) {
131131
return function () {
132-
var e1 = document.getElementById("plaintext");
132+
const e1 = document.getElementById("plaintext");
133133
e1.value = a1;
134134
e1.dispatchEvent(new Event("input"));
135-
var e2 = document.getElementById("mininame");
135+
const e2 = document.getElementById("mininame");
136136
e2.value = a2;
137137
e2.dispatchEvent(new Event("input"));
138138
};

javascripts/Amazon - Search selection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use strict";
2-
var selection;
2+
let selection;
33
if (window.getSelection) {
44
selection = window.getSelection().toString();
55
} else if (document.selection && document.selection.type !== "Control") {

javascripts/Amazon - Sort by number of reviews.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
2-
var url = new URL(location.href);
3-
var params = new URLSearchParams(url.search);
2+
const url = new URL(location.href);
3+
const params = new URLSearchParams(url.search);
44
if (!params.get("rh") && !params.get("i")) {
55
window.alert(
66
"Please narrow down your search to a specific department for the sort to take effect.",

javascripts/Bing - Search selection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use strict";
2-
var selection;
2+
let selection;
33
if (window.getSelection) {
44
selection = window.getSelection().toString();
55
} else if (document.selection && document.selection.type !== "Control") {

javascripts/DOM - Allow copy paste.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
2-
var e = document.getElementsByTagName("*");
3-
var i;
2+
const e = document.getElementsByTagName("*");
3+
let i;
44
for (i = 0; i < e.length; i += 1) {
55
if (e[i].onCopy) {
66
e[i].onCopy = null;

javascripts/DOM - Allow save password.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
2-
var e = document.getElementsByTagName("*");
3-
var i;
2+
const e = document.getElementsByTagName("*");
3+
let i;
44
for (i = 0; i < e.length; i += 1) {
55
if (e[i].autocomplete) {
66
e[i].autocomplete = "on";

javascripts/DOM - Enable all.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
2-
var e = document.getElementsByTagName("*");
3-
var i;
2+
const e = document.getElementsByTagName("*");
3+
let i;
44
for (i = 0; i < e.length; i += 1) {
55
if (e[i].disabled) {
66
e[i].disabled = "false";

javascripts/DOM - NATO spell selection.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
2-
var selection;
3-
var h = {
2+
let selection;
3+
const h = {
44
0: "Zero",
55
1: "One",
66
2: "Two",

javascripts/DOM - Show anchors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
2-
var i, anchor, id;
3-
var anchors = document.getElementsByTagName("a");
2+
let i, anchor, id;
3+
const anchors = document.getElementsByTagName("a");
44
for (i = 0; i < anchors.length; i += 1) {
55
anchor = anchors[i];
66
id = anchor.id;

0 commit comments

Comments
 (0)