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