Skip to content

Commit

Permalink
Deleted 5 JS scripts and moved lots of data into JSON files. Big reor…
Browse files Browse the repository at this point in the history
…ganization.
  • Loading branch information
00Fjongl committed Jul 17, 2024
1 parent 1742116 commit 4982ae6
Show file tree
Hide file tree
Showing 23 changed files with 1,047 additions and 295 deletions.
2 changes: 0 additions & 2 deletions src/routes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ charRandom = insert.chars,
splashRandom = insert.splash,
cacheBustList = {
"styles.css": "styles-1644738239.css",
"h5-nav.js": "h5-nav-1644738239.js",
"common.js": "common-16451543478.js",
"links.js": "links-1644738239.js",
};

export default {
Expand Down
18 changes: 9 additions & 9 deletions views/assets/css/styles-1644738239.css
Original file line number Diff line number Diff line change
Expand Up @@ -1396,14 +1396,14 @@ iner
padding: 10px 50px;
}

#glist {
.glist {
font-family: "Lato", sans-serif;
display: flex;
flex-wrap: wrap;
justify-content: center;
}

#glist > a {
.glist > a {
display: block;
text-decoration: none;
width: 200px;
Expand All @@ -1416,11 +1416,11 @@ iner
flex-shrink: 0;
}

#glist > a:hover {
.glist > a:hover {
border: 2px solid var(--nord11);
}

#glist > a img {
.glist > a img {
pointer-events: none;
border-radius: 30%;
width: 200px;
Expand All @@ -1430,11 +1430,11 @@ iner
box-shadow: 3px 4px 5px 0px rgba(0, 0, 0, 0.38);
}

#glist > a h3 {
.glist > a h3 {
margin: 16px 0px;
}

#glist > a p {
.glist > a p {
margin-bottom: 0px;
}

Expand All @@ -1454,7 +1454,7 @@ iner
color: var(--gray);
}

#flist {
.flist {
font-family: "Lato", sans-serif;
background-color: var(--nord0);
width: 400px;
Expand All @@ -1466,7 +1466,7 @@ iner
padding-bottom: 2px;
}

#flist > a {
.flist > a {
display: block;
text-decoration: none;
text-transform: capitalize;
Expand All @@ -1476,7 +1476,7 @@ iner
border-bottom: none;
}

#flist > a:hover {
.flist > a:hover {
background-color: var(--nord2);
}

Expand Down
99 changes: 95 additions & 4 deletions views/assets/js/common-16451543478.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
/* MAIN Holy Unblocker LTS Common Script
/* ----------------------------------------------- */

// Used in scripts outside this file.
const tryGetElement = id => document.getElementById(id) || {};

// Get the preferred apex domain name. Not exactly apex, as any
// subdomain other than those listed will be ignored.
const getDomain = () => location.host.replace(/^(?:www|edu|cooking|beta)\./, "");
Expand Down Expand Up @@ -402,4 +399,98 @@ addEventListener("DOMContentLoaded", () => {

// Prevent goProx from being edited.
Object.freeze(goProx);
});
});

// Load in relevant JSON files used to organize large sets of data.
// This first one is for links, whereas the rest are for navigation menus.
(async () => {
const huLinks = await fetch("/assets/json/links.json", {mode: "same-origin"}).then(response => response.json());

for (let item of Object.entries(huLinks))
(document.getElementById(item[0]) || {}).href = item[1];

const navLists = {
"emu-nav": "emu-nav",
"emulib-nav": "emulib-nav",
"flash-nav": "flash-nav",
"h5-nav": "h5-nav"
};

for (let [listId, filename] of Object.entries(navLists)) {

let navList = document.getElementById(listId);

if(navList) {

const data = await fetch(`/assets/json/${filename}.json`, {mode: "same-origin"}).then(response => response.json());

switch (filename) {
case "emu-nav":
case "emulib-nav":
case "h5-nav": {
const dirnames = {
"emu-nav": "emu",
"emulib-nav": "emulib",
"h5-nav": "h5g"
},
dir = dirnames[filename],
clickHandler = parser => e => {
if (e.target == a || e.target.tagName != "A") {
e.preventDefault();
parser();
}
};

for (let item of data) {
let a = document.createElement("a");
a.href = "#";

let img = document.createElement("img");
img.src = `/assets/img/${dir}/` + item.img;
let title = document.createElement("h3");
title.textContent = item.name;
let desc = document.createElement("p");
desc.textContent = item.description;

if (filename === "h5-nav") {
if (item.credits === "itch") desc.innerHTML += '<br>Credits: Game can be found <a target="_blank" href="https://itch.io">here</a>.';
if (item.credits === "nowgg") desc.innerHTML += '<br>Credits: Game can be found <a target="_blank" href="https://now.gg">here</a>.';
}

a.appendChild(img);
a.appendChild(title);
a.appendChild(desc);

let functionsList = [
() => goFrame(item.path),
() => goFrame("/?eg&core=" + item.core + "&rom=" + item.rom),
() => item.custom ? goProx[item.custom](true) : goFrame("/archive/g/" + item.path, item.nolag)
];

a.addEventListener("click", clickHandler(functionsList[Object.values(dirnames).indexOf(dir)]));

navList.appendChild(a);
}
break;
}

case "flash-nav":
for (let item of data) {
let a = document.createElement("a");
a.href = "#";
a.textContent = item.slice(0, -4);

a.addEventListener("click", e => {
e.preventDefault();
goFrame("/?fg&swf=" + item);
});

navList.appendChild(a);
}
break;

// No default case.
}
}
}
})();
39 changes: 0 additions & 39 deletions views/assets/js/gnav/emu-nav.js

This file was deleted.

73 changes: 0 additions & 73 deletions views/assets/js/gnav/emulib-nav.js

This file was deleted.

22 changes: 0 additions & 22 deletions views/assets/js/gnav/flash-nav.js

This file was deleted.

Loading

0 comments on commit 4982ae6

Please sign in to comment.