More commenting and reformatting changes

This commit is contained in:
00Fjongl 2024-08-07 23:29:16 -05:00
parent 1411d697b2
commit 46b93c3607
3 changed files with 12 additions and 12 deletions

View file

@ -10,7 +10,7 @@ const config = Object.freeze(
JSON.parse(await readFile(new URL("./src/config.json", import.meta.url))) JSON.parse(await readFile(new URL("./src/config.json", import.meta.url)))
), ),
ecosystemConfig = Object.freeze( 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 => { const serverUrl = (base => {
@ -80,6 +80,7 @@ for (let i = 2; i < process.argv.length; i++)
if (response === "Error") throw new Error("Server is unresponsive."); if (response === "Error") throw new Error("Server is unresponsive.");
} catch (e) { } catch (e) {
// Check if this is the error thrown by the fetch request for an unused port. // 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); if (e instanceof TypeError) clearTimeout(timeoutId);
else console.error(e); else console.error(e);
await unlink(shutdown); await unlink(shutdown);

View file

@ -22,7 +22,7 @@ const config = Object.freeze(
JSON.parse(await readFile(new URL("./config.json", import.meta.url))) JSON.parse(await readFile(new URL("./config.json", import.meta.url)))
), ),
ecosystemConfig = Object.freeze( 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, { pages, text404 } = pkg,
__dirname = path.resolve(); __dirname = path.resolve();
@ -201,7 +201,7 @@ app.get("/:file", (req, reply) => {
// Testing for future features that need cookies to deliver alternate source files. // Testing for future features that need cookies to deliver alternate source files.
if (req.raw.rawHeaders.includes("Cookie")) 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( reply.type("text/html").send(
paintSource( paintSource(
@ -243,7 +243,5 @@ app.setNotFoundHandler((req, reply) => {
reply.code(404).type("text/html").send(paintSource(loadTemplates(tryReadFile(path.join(__dirname, "views/error.html"))))); 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 }); 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}.`);

View file

@ -463,9 +463,9 @@ addEventListener("DOMContentLoaded", async () => {
// This first one is for links, whereas the rest are for navigation menus. // 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()); 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. // 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 = { const navLists = {
// Pair an element ID with a JSON file name. They are identical for now. // Pair an element ID with a JSON file name. They are identical for now.
@ -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, // Load each item as an anchor tag with an image, heading,
// description, and click event listener. // description, and click event listener.
let a = document.createElement("a"), let item = data[i],
a = document.createElement("a"),
img = document.createElement("img"), img = document.createElement("img"),
title = document.createElement("h3"), title = document.createElement("h3"),
desc = document.createElement("p"); desc = document.createElement("p");
@ -545,10 +546,10 @@ addEventListener("DOMContentLoaded", async () => {
} }
case "flash-nav": 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 // Load each item as an anchor tag with a short title and click
// event listener. // event listener.
let a = document.createElement("a"); const item = data[i], a = document.createElement("a");
a.href = "#"; a.href = "#";
a.textContent = item.slice(0, -4); a.textContent = item.slice(0, -4);