undid an automatic reindent

This commit is contained in:
2026-06-30 20:17:33 +02:00
parent 9d768185b6
commit 6adefe7210
+148 -149
View File
@@ -1,17 +1,17 @@
const PAGES = { const PAGES = {
_404: -1, _404: -1,
null: 0, null: 0,
SYNTHWAVE: 1, SYNTHWAVE: 1,
TOYS: 2, TOYS: 2,
LICENSE: 3, LICENSE: 3,
LOADING: 4, LOADING: 4,
LIBS: 5 LIBS: 5
} }
const CONSOLE_COLORS = { const CONSOLE_COLORS = {
red: "color: #FF0000;", red: "color: #FF0000;",
green: "color: #00FF00", green: "color: #00FF00",
white: "color: #FFFFFF;", white: "color: #FFFFFF;",
debugTitle: "color: #00FF00;", debugTitle: "color: #00FF00;",
} }
let CURRENT_PAGE = PAGES.null let CURRENT_PAGE = PAGES.null
@@ -21,132 +21,131 @@ let gridVisible = false
let navBarPresent = false let navBarPresent = false
function randomFloat(min, max) { function randomFloat(min, max) {
return Math.random() * (max - min) + min return Math.random() * (max - min) + min
} }
function randomIntFrom0(max) { function randomIntFrom0(max) {
return Math.floor(Math.random() * max) return Math.floor(Math.random() * max)
} }
function randomInt(min, max) { function randomInt(min, max) {
return Math.floor(Math.random() * (max - min) + min) return Math.floor(Math.random() * (max - min) + min)
} }
function randomBool(probability) { function randomBool(probability) {
return Math.random() <= probability return Math.random() <= probability
} }
function clampNearest(n, mul) { function clampNearest(n, mul) {
if (n > 0) if(n > 0)
return Math.ceil(n / mul) * mul return Math.ceil(n / mul) * mul
else if (n < 0) else if( n < 0)
return Math.floor(n / mul) * mul return Math.floor(n / mul) * mul
else else
return 0 return 0
} }
function lerp(x, y, t) { function lerp(x, y, t) {
return x + t * (y - x) return x + t * (y - x)
} }
function debugPrint(title, value) { function debugPrint(title, value) {
if (!title) { if (!title) {
console.error( console.error(
`error[A0000]: this function takes 1 argument but 0 arguments were supplied `error[A0000]: this function takes 1 argument but 0 arguments were supplied
--> unknown:0:0 --> unknown:0:0
| |
0 | debugPrint() 0 | debugPrint()
| ^^^^^^^^^^-- argument #1 of type \`Any\` is missing` | ^^^^^^^^^^-- argument #1 of type \`Any\` is missing`
) )
return return
} }
if (value) { if (value) {
console.log(`%c${title}:\n%c${value}`, CONSOLE_COLORS.debugTitle, CONSOLE_COLORS.white) console.log(`%c${title}:\n%c${value}`, CONSOLE_COLORS.debugTitle, CONSOLE_COLORS.white)
} }
else { else {
console.log(`%c${title}`, CONSOLE_COLORS.debugTitle) console.log(`%c${title}`, CONSOLE_COLORS.debugTitle)
} }
} }
function toggleGrid(offX = 0, offY = 0) { function toggleGrid(offX = 0, offY = 0) {
if (gridVisible) { if (gridVisible) {
document.getElementById("gridCanvas").remove() document.getElementById("gridCanvas").remove()
gridVisible = false gridVisible = false
return return
} }
let canvasEl = document.createElement("canvas") let canvasEl = document.createElement("canvas")
canvasEl.id = "gridCanvas" canvasEl.id = "gridCanvas"
canvasEl.width = window.innerWidth canvasEl.width = window.innerWidth
canvasEl.height = window.innerHeight canvasEl.height = window.innerHeight
canvasEl.style.position = "absolute" canvasEl.style.position = "absolute"
canvasEl.style.top = `${offY * pxDensity}px` canvasEl.style.top = `${offY * pxDensity}px`
canvasEl.style.left = `${offX * pxDensity}px` canvasEl.style.left = `${offX * pxDensity}px`
canvasEl.style.pointerEvents = "none" canvasEl.style.pointerEvents = "none"
let ctx = canvasEl.getContext("2d") let ctx = canvasEl.getContext("2d")
document.body.appendChild(canvasEl) document.body.appendChild(canvasEl)
let repeatCountX = window.innerWidth / pxDensity let repeatCountX = window.innerWidth / pxDensity
let repeatCountY = window.innerHeight / pxDensity let repeatCountY = window.innerHeight / pxDensity
ctx.strokeStyle = "#ff0000" ctx.strokeStyle = "#ff0000"
ctx.strokeSize = 1 ctx.strokeSize = 1
ctx.beginPath() ctx.beginPath()
for (x = 0; x < repeatCountX; x++) { for (x = 0; x < repeatCountX; x++) {
ctx.moveTo(x * pxDensity, 0) ctx.moveTo(x * pxDensity, 0)
ctx.lineTo(x * pxDensity, window.innerHeight) ctx.lineTo(x * pxDensity, window.innerHeight)
} }
for (y = 0; y < repeatCountY; y++) { for (y = 0; y < repeatCountY; y++) {
ctx.moveTo(0, y * pxDensity) ctx.moveTo(0, y * pxDensity)
ctx.lineTo(window.innerWidth, y * pxDensity) ctx.lineTo(window.innerWidth, y * pxDensity)
} }
ctx.stroke() ctx.stroke()
gridVisible = true gridVisible = true
} }
function pauseAnimBtn(state) { function pauseAnimBtn(state) {
if (state == "auto") { if (state == "auto") {
if (localStorage["isAnimating"] == "true") { localStorage["isAnimating"] = "false" } if (localStorage["isAnimating"] == "true") { localStorage["isAnimating"] = "false" }
else { localStorage["isAnimating"] = "true" } else { localStorage["isAnimating"] = "true" }
state = localStorage["isAnimating"] state = localStorage["isAnimating"]
} }
let pauseBtn = document.getElementById("animationToggle") let pauseBtn = document.getElementById("animationToggle")
if (pauseBtn == undefined) { return; } if (pauseBtn == undefined) { return; }
if (state == "true") { if (state == "true") {
isAnimating = true isAnimating = true
pauseBtn.src = "/assets/icons/pauseAnimation_8x8.png" pauseBtn.src = "/assets/icons/pauseAnimation_8x8.png"
} }
else { else {
isAnimating = false isAnimating = false
pauseBtn.src = "/assets/icons/playAnimation_8x8.png" pauseBtn.src = "/assets/icons/playAnimation_8x8.png"
} }
localStorage["isAnimating"] = isAnimating localStorage["isAnimating"] = isAnimating
} }
function setVh() { function setVh() {
document.documentElement.style.setProperty("--vh", window.innerHeight * 0.01 + "px") document.documentElement.style.setProperty("--vh", window.innerHeight * 0.01 + "px")
} }
function getEngine() { function getEngine() {
if ("MozAppearance" in document.documentElement.style) if ("MozAppearance" in document.documentElement.style)
{ return "gecko" } { return "gecko" }
@@ -173,86 +172,86 @@ document.addEventListener("DOMContentLoaded", async function () {
let engine = getEngine() let engine = getEngine()
if (!["gecko", "blink"].includes(engine)) if (!["gecko", "blink"].includes(engine))
{ alert("Your web browser is not supported, expect major issues.\nRendering engine: " + engine) } { alert("Your web browser is not supported, expect major issues.\nRendering engine: " + engine) }
setLoadingProgress("Fetching tips...") setLoadingProgress("Fetching tips...")
await loadTips() await loadTips()
newTip() newTip()
setLoadingProgress("Calculating pixel density...") setLoadingProgress("Calculating pixel density...")
calcPixelDensity() calcPixelDensity()
if (densityWidth > densityHeight) { debugPrint("pxDensity", `Width, ${pxDensity}`) } if (densityWidth > densityHeight) { debugPrint("pxDensity", `Width, ${pxDensity}`) }
else { debugPrint("pxDensity", `Height, ${pxDensity}`) } else { debugPrint("pxDensity", `Height, ${pxDensity}`) }
if (navBarPresent) { if (navBarPresent) {
setLoadingProgress("adding navBar...") setLoadingProgress("adding navBar...")
await loadNavBarJson() await loadNavBarJson()
onLoadNavBar() onLoadNavBar()
} }
switch (CURRENT_PAGE) { switch (CURRENT_PAGE) {
case (PAGES.SYNTHWAVE): loadingScreenSynthwave(); break case (PAGES.SYNTHWAVE): loadingScreenSynthwave(); break
case (PAGES.LICENSE): loadingScreenStars(); await loadingScreenLicense(); break case (PAGES.LICENSE): loadingScreenStars(); await loadingScreenLicense(); break
case (PAGES.TOYS): loadingScreenStars(); break case (PAGES.TOYS): loadingScreenStars(); break
case (PAGES.LIBS): loadingScreenStars(); break case (PAGES.LIBS): loadingScreenStars(); break
} }
if (navBarPresent) {
pauseAnimBtn(localStorage["isAnimating"] || "true")
debugPrint("isAnimating", isAnimating)
}
if (navBarPresent) { if (CURRENT_PAGE == PAGES.LOADING) {
pauseAnimBtn(localStorage["isAnimating"] || "true") clearLoadingScreenClutter()
debugPrint("isAnimating", isAnimating)
}
if (CURRENT_PAGE == PAGES.LOADING) {
clearLoadingScreenClutter()
setLoadingProgress("") setLoadingProgress("")
setInterval(periodicallyChangeTips, 60 * 1000) setInterval(periodicallyChangeTips, 60 * 1000)
return return
} }
if (fakeLoading != "true") { if (fakeLoading != "true") {
removeLoadingScreen(true) removeLoadingScreen(true)
} }
else { else {
setLoadingProgress("Cleaning up...") setLoadingProgress("Cleaning up...")
loadingComplete = true loadingComplete = true
if (fakeLoadingComplete) { if (fakeLoadingComplete) {
removeLoadingScreen() removeLoadingScreen()
} }
} }
}, false) }, false)
window.addEventListener("resize", function () { window.addEventListener("resize", function() {
setVh() setVh()
calcPixelDensity() calcPixelDensity()
switch (CURRENT_PAGE) { switch (CURRENT_PAGE) {
case (PAGES.SYNTHWAVE): onResizeSynthwave() case (PAGES.SYNTHWAVE): onResizeSynthwave()
case (PAGES.LICENSE): scaleDisplayLicense() case (PAGES.LICENSE): scaleDisplayLicense()
} }
// unoptimal but works well enough // unoptimal but works well enough
if (gridVisible) { if (gridVisible) {
toggleGrid() toggleGrid()
toggleGrid() toggleGrid()
} }
}) })
if ("scrollRestoration" in history) { if ("scrollRestoration" in history) {
history.scrollRestoration = "manual"; history.scrollRestoration = "manual";
} }
window.addEventListener("pageshow", (event) => { window.addEventListener("pageshow", (event) => {
if (event.persisted) { if (event.persisted) {
// reload page to clear unwanted cache. // reload page to clear unwanted cache.
// for some reason the loading screen stays // for some reason the loading screen stays
// permanently open without this. // permanently open without this.
window.location.reload() window.location.reload()
} }
}) })
let prevAnimationState = isAnimating let prevAnimationState = isAnimating
@@ -271,27 +270,27 @@ async function sha256(text) {
/* /*
document.addEventListener("visibilitychange", function() { document.addEventListener("visibilitychange", function() {
if (document.hidden) { if (document.hidden) {
prevAnimationState = isAnimating prevAnimationState = isAnimating
isAnimating = false isAnimating = false
} }
else { else {
isAnimating = prevAnimationState isAnimating = prevAnimationState
} }
}) })
window.addEventListener("blur", function() { window.addEventListener("blur", function() {
if (document.visibilityState === "visible") { if (document.visibilityState === "visible") {
prevAnimationState = isAnimating prevAnimationState = isAnimating
isAnimating = false isAnimating = false
} }
}) })
window.addEventListener("focus", function() { window.addEventListener("focus", function() {
if (!document.hidden) { if (!document.hidden) {
isAnimating = prevAnimationState isAnimating = prevAnimationState
} }
}) })
*/ */