Skip to content

Commit

Permalink
More commenting and reformatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
00Fjongl committed Aug 8, 2024
1 parent 1411d69 commit 46b93c3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
3 changes: 2 additions & 1 deletion run-command.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const config = Object.freeze(
JSON.parse(await readFile(new URL("./src/config.json", import.meta.url)))
),
ecosystemConfig = Object.freeze(
ecosystem.apps.find(app => app.name === "HolyUB") || apps[0]
ecosystem.apps.find(app => app.name === "HolyUB") || ecosystem.apps[0]
);

const serverUrl = (base => {
Expand Down Expand Up @@ -80,6 +80,7 @@ for (let i = 2; i < process.argv.length; i++)
if (response === "Error") throw new Error("Server is unresponsive.");
} catch (e) {
// Check if this is the error thrown by the fetch request for an unused port.
// Don't print the unused port error, since nothing has actually broken.
if (e instanceof TypeError) clearTimeout(timeoutId);
else console.error(e);
await unlink(shutdown);
Expand Down
8 changes: 3 additions & 5 deletions src/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const config = Object.freeze(
JSON.parse(await readFile(new URL("./config.json", import.meta.url)))
),
ecosystemConfig = Object.freeze(
ecosystem.apps.find(app => app.name === "HolyUB") || apps[0]
ecosystem.apps.find(app => app.name === "HolyUB") || ecosystem.apps[0]
),
{ pages, text404 } = pkg,
__dirname = path.resolve();
Expand Down Expand Up @@ -201,7 +201,7 @@ app.get("/:file", (req, reply) => {

// Testing for future features that need cookies to deliver alternate source files.
if (req.raw.rawHeaders.includes("Cookie"))
console.log(req.raw.rawHeaders[req.raw.rawHeaders.indexOf("Cookie") + 1]);
console.log(req.raw.rawHeaders[ req.raw.rawHeaders.indexOf("Cookie") + 1 ]);

reply.type("text/html").send(
paintSource(
Expand Down Expand Up @@ -243,7 +243,5 @@ app.setNotFoundHandler((req, reply) => {
reply.code(404).type("text/html").send(paintSource(loadTemplates(tryReadFile(path.join(__dirname, "views/error.html")))));
});

// Configure host to your liking, but remember to tweak the Rammerhead IP
// as well above for any changes.
app.listen({ port: serverUrl.port, host: serverUrl.hostname });
console.log("Holy Unblocker is listening on port " + serverUrl.port + ".");
console.log(`Holy Unblocker is listening on port ${serverUrl.port}.`);
13 changes: 7 additions & 6 deletions views/assets/js/common-16451543478.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,9 @@ addEventListener("DOMContentLoaded", async () => {
// This first one is for links, whereas the rest are for navigation menus.
const huLinks = await fetch("/assets/json/links.json", {mode: "same-origin"}).then(response => response.json());

for (let item of Object.entries(huLinks))
for (let items = Object.entries(huLinks), i = 0; i < items.length; i++)
// Replace all placeholder links with the corresponding entry in huLinks.
(document.getElementById(item[0]) || {}).href = item[1];
(document.getElementById(items[i][0]) || {}).href = items[i][1];

const navLists = {
// Pair an element ID with a JSON file name. They are identical for now.
Expand Down Expand Up @@ -507,10 +507,11 @@ addEventListener("DOMContentLoaded", async () => {
}
};

for (let item of data) {
for (let i = 0; i < data.length; i++) {
// Load each item as an anchor tag with an image, heading,
// description, and click event listener.
let a = document.createElement("a"),
let item = data[i],
a = document.createElement("a"),
img = document.createElement("img"),
title = document.createElement("h3"),
desc = document.createElement("p");
Expand Down Expand Up @@ -545,10 +546,10 @@ addEventListener("DOMContentLoaded", async () => {
}

case "flash-nav":
for (let item of data) {
for (let i = 0; i < data.length; i++) {
// Load each item as an anchor tag with a short title and click
// event listener.
let a = document.createElement("a");
const item = data[i], a = document.createElement("a");
a.href = "#";
a.textContent = item.slice(0, -4);

Expand Down

0 comments on commit 46b93c3

Please sign in to comment.