Skip to content

Commit

Permalink
Code optimization and commenting
Browse files Browse the repository at this point in the history
  • Loading branch information
00Fjongl committed Jul 23, 2024
1 parent 1299d43 commit 6a2adf9
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 52 deletions.
14 changes: 7 additions & 7 deletions views/assets/css/styles-1644738239.css
Original file line number Diff line number Diff line change
Expand Up @@ -1483,17 +1483,17 @@ iner
}
}

#pr-form {
.pr-form {
margin-bottom: 16px;
}

#pr-form > input {
.pr-form > input {
background-color: var(--nord0);
border: 1px solid var(--nord0);
}

#pr-form > input,
#pr-form > a {
.pr-form > input,
.pr-form > a {
vertical-align: baseline;
outline: none;
border-radius: 5px;
Expand All @@ -1504,16 +1504,16 @@ iner
margin: 3px;
}

#pr-url {
.pr-form > input[type=text] {
max-width: 700px;
width: calc(100% - 44px);
}

#pr-url:focus {
.pr-form > input[type=text]:focus {
animation: glowshadow 2s linear infinite;
}

#pr-url::placeholder {
.pr-form > input[type=text]::placeholder {
color: var(--gray);
}

Expand Down
39 changes: 39 additions & 0 deletions views/assets/js/common-16451543478.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const urlHandler = parser => typeof parser === "function"
// Return different functions based on whether a URL has already been set.
// Should help avoid confusion when using or adding to the goProx object.
? (url, mode) => {
if (!url) return;
url = parser(url);
mode = `${mode}`.toLowerCase();
if (mode === "stealth" || mode == 1) goFrame(url);
Expand All @@ -37,6 +38,7 @@ const urlHandler = parser => typeof parser === "function"

// An asynchronous version of the function above, just in case.
const asyncUrlHandler = parser => async (url, mode) => {
if (!url) return;
if (typeof parser === "function") url = await parser(url);
mode = `${mode}`.toLowerCase();
if (mode === "stealth" || mode == 1) goFrame(url);
Expand Down Expand Up @@ -397,8 +399,41 @@ addEventListener("DOMContentLoaded", () => {

heli: urlHandler(uvUrl("https://benjames171.itch.io/helo-storm"))
});


// Attach event listeners using goProx to specific app menus that need it.
const prSet = (id, type) => {
const formElement = document.getElementById(id);
if (!formElement) return;

let prUrl = formElement.querySelector("input[type=text]"),
prGo1 = formElement.getElementsByClassName("pr-go1")[0],
prGo2 = formElement.getElementsByClassName("pr-go2")[0];

// Handle the other menu buttons differently if there is no omnibox. Menus
// which lack an omnibox likely use buttons as mere links.
const goProxMethod = prUrl !== undefined
? mode => () => {goProx[type](prUrl.value, mode)}
: mode => () => {goProx[type](mode)},

// Ultraviolet is currently incompatible with window mode.
searchMode = type === "ultraviolet" ? "stealth" : "window";

if (prUrl) prUrl.addEventListener("keydown", e => {
if (e.code === "Enter") goProxMethod(searchMode)();
});

if (prGo1) prGo1.addEventListener("click", goProxMethod("window"));
if (prGo2) prGo2.addEventListener("click", goProxMethod("stealth"));
};


prSet("pr-uv", "ultraviolet");
prSet("pr-rh", "rammerhead");
});



(async () => {
// 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.
Expand All @@ -409,6 +444,7 @@ addEventListener("DOMContentLoaded", () => {
(document.getElementById(item[0]) || {}).href = item[1];

const navLists = {
// Pair an element ID with a JSON file name. They are identical for now.
"emu-nav": "emu-nav",
"emulib-nav": "emulib-nav",
"flash-nav": "flash-nav",
Expand All @@ -430,6 +466,8 @@ addEventListener("DOMContentLoaded", () => {
case "emulib-nav":
case "h5-nav": {
const dirnames = {
// Set the directory of where each item of the corresponding JSON
// list will be retrieved from.
"emu-nav": "emu",
"emulib-nav": "emulib",
"h5-nav": "h5g"
Expand Down Expand Up @@ -500,6 +538,7 @@ addEventListener("DOMContentLoaded", () => {
break;

// No default case.

}
}
}
Expand Down
23 changes: 0 additions & 23 deletions views/assets/js/prset.js

This file was deleted.

4 changes: 0 additions & 4 deletions views/pages/misc/deobf/docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,7 @@ <h4 id="details-of-views-">Details of <code>/views/</code></h4>
<h4 id="scripts-located-in-views-assets-js-">Scripts located in <code>/views/assets/js/</code></h4>
<ul>
<li><code>common.js</code> is used on all of the pages for common useful functions.</li>
<li><code>prset.js</code> is used on the proxy pages for proxy form functionality.</li>
<li><code>header.js</code> inserts the header into every page using javascript.</li>
<li><code>csel.js</code> manages the settings menu on the header.</li>
<li><code>footer.js</code> inserts the footer into every page using javascript.</li>
<li><code>gnav/*.js</code> are used for navigation on the games pages.</li>
</ul>
<h2 id="future-additions">Future Additions</h2>
<ul>
Expand Down
4 changes: 2 additions & 2 deletions views/pages/misc/deobf/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
</div>
<p class=cseltitle>Browser Tab Config</p>
<p>Change the universal tab title:</p>
<form class=cselform id=titleform>
<form id=titleform>
<input type=text placeholder="Tab Title" spellcheck=false><input type=submit value=Apply>
</form>
<p>Change the universal tab <a href=/?i>icon</a>:</p>
<form class=cselform id=iconform>
<form id=iconform>
<input type=text placeholder="Icon URL" spellcheck=false><input type=submit value=Apply>
</form>
<input id=cselreset type=button value=Reset>
Expand Down
11 changes: 3 additions & 8 deletions views/pages/proxnav/rammerhead.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,15 @@ <h1 class="bigtitle">Rammerhead</h1>
Its session-based proxying concept enables much support for webites
like Discord, YouTube, and more!
</p>
<div id="pr-form">
<div id=pr-rh class="pr-form">
<input
type="text"
id="pr-url"
spellcheck="false"
autocomplete="off"
placeholder="Search or enter in a target site!"
/>
<a href="#" id="pr-go1" class="pr-button glowbutton">Cl&#173;assic</a>
<a href="#" id="pr-go2" class="pr-button glowbutton">Stea&#173;lth</a>
<a href="#" class="pr-button glowbutton pr-go1">Cl&#173;assic</a>
<a href="#" class="pr-button glowbutton pr-go2">Stea&#173;lth</a>
</div>
<p>
Important: Make sure you treat this as a PRIVATE session. Do NOT share
Expand Down Expand Up @@ -92,10 +91,6 @@ <h3>More Information:</h3>
<!-- IMPORTANT-HUCOOKINGINSERT-DONOTDELETE -->
<script src="assets/js/common.js"></script>
<script src="assets/js/csel.js"></script>
<script src="assets/js/prset.js"></script>
<script>
prSet("rammerhead");
</script>
<script defer="defer" src="assets/js/particlesjs/particles.js"></script>
</body>
</html>
11 changes: 3 additions & 8 deletions views/pages/proxnav/ultraviolet.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,15 @@ <h1 class="bigtitle">Ultraviolet (Beta)</h1>
such as service workers and sophisticated rewriting techniques with
CAPTCHA support.
</p>
<div id="pr-form">
<div id=pr-uv class="pr-form">
<input
type="text"
id="pr-url"
spellcheck="false"
autocomplete="off"
placeholder="Search or enter in a target site!"
/>
<a href="#" id="pr-go1" style="display:none;" class="pr-button glowbutton">Stea&#173;lth</a>
<a href="#" id="pr-go2" class="pr-button glowbutton">Stea&#173;lth</a>
<a href="#" style="display:none;" class="pr-button glowbutton pr-go1">Stea&#173;lth</a>
<a href="#"" class="pr-button glowbutton pr-go2">Stea&#173;lth</a>
</div>
<h3>More Information:</h3>
<div class="font3">
Expand Down Expand Up @@ -100,10 +99,6 @@ <h3>More Information:</h3>
<!-- IMPORTANT-HUCOOKINGINSERT-DONOTDELETE -->
<script src="assets/js/common.js"></script>
<script src="assets/js/csel.js"></script>
<script src="assets/js/prset.js"></script>
<script defer="defer" src="assets/js/particlesjs/particles.js"></script>
<script>
prSet("ultraviolet");
</script>
</body>
</html>

0 comments on commit 6a2adf9

Please sign in to comment.