improved tips code quality

This commit is contained in:
2025-01-05 01:38:21 +01:00
parent d913d95793
commit cde06f7a85
6 changed files with 56 additions and 36 deletions
+37 -3
View File
@@ -1,3 +1,10 @@
const PAGES = {
null: -1,
SYNTHWAVE: 0,
}
let CURRENT_PAGE = PAGES.null
let isAnimating = true
function randomFloat(min, max) {
@@ -19,9 +26,9 @@ function clampNearest(n, mul) {
if(n > 0)
return Math.ceil(n / mul) * mul;
else if( n < 0)
return Math.floor(n / mul) * mul;
return Math.floor(n / mul) * mul;
else
return 0;
return 0;
}
@@ -78,4 +85,31 @@ function pauseAnimBtn(state) {
}
localStorage["isAnimating"] = state
}
}
document.addEventListener("DOMContentLoaded", async function() {
startLoadingScreen()
setLoadingProgress("Fetching tips...")
await loadTips()
newTip()
setLoadingProgress("Calculating pixel density...")
calcPixelDensity()
switch (CURRENT_PAGE) {
case (PAGES.SYNTHWAVE): loadingScreenSynthwave()
}
pauseAnimBtn(localStorage["isAnimating"] || "true")
if (showLoading != "true") {
removeLoadingScreen()
}
else {
setLoadingProgress("Cleaning up...")
}
}, false)