diff --git a/globalScript.js b/globalScript.js index 6525491..66e0ce3 100644 --- a/globalScript.js +++ b/globalScript.js @@ -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 -} \ No newline at end of file +} + + +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) \ No newline at end of file diff --git a/index.html b/index.html index b9c65f0..d755a93 100644 --- a/index.html +++ b/index.html @@ -67,12 +67,16 @@

Loading...
Loading files...

Tip: Tip loading...

- - + + + + + + diff --git a/loadingScreen.js b/loadingScreen.js index 97000d5..6ee87ef 100644 --- a/loadingScreen.js +++ b/loadingScreen.js @@ -4,25 +4,17 @@ let loadingScreenProgress = document.getElementById("loadingText") let loadingScreenEl = document.getElementById("loadingScreen") -let tipsJson; +let tipsJson -(function loadTipsSync() { - const xhr = new XMLHttpRequest(); - xhr.open("GET", "./loadingScreenTips.json", false) - xhr.send(null) - if (xhr.status === 200) { - tipsJson = JSON.parse(xhr.responseText) - } else { - console.error("Failed to load tips:", xhr.status, xhr.statusText) - tipsJson = [] - } -})() +async function loadTips() { + let tipsText = await fetch("./loadingScreenTips.json").then(response => response.text()) + tipsJson = JSON.parse(tipsText) +} -console.log(tipsJson) -let selectedTip = tipsJson[randomIntFrom0(tipsJson.length)] const showLoading = localStorage["showLoading"] || "true" +let selectedTip = "undefined" function newTip() { diff --git a/loadingScreenTips.json b/loadingScreenTips.json index 6c31803..06bf9fa 100644 --- a/loadingScreenTips.json +++ b/loadingScreenTips.json @@ -6,7 +6,7 @@ "Bad at a game? Just press the \"get good at games\" button!", "I AM NOT A FEMBOY NOR GAY. (I support though :thumbsup:)", "You should listen to that song that goes \"do do do do do do do do do.\"", - "(Almost) Every pixel in this website's pixel art is positioned pixel perfect.", + "(Almost) Every pixel in this website's pixel art is positioned pixel perfectly.", "Shouldn't I be talking about tips?", "Did you know that... uh... hold on let me think... I don't know, I forgot.", "This tip is very helpful.", diff --git a/script.js b/script.js index c5a2028..014b4e1 100644 --- a/script.js +++ b/script.js @@ -1,21 +1,9 @@ -document.addEventListener("DOMContentLoaded", function() { - startLoadingScreen() +CURRENT_PAGE = PAGES.SYNTHWAVE - setLoadingProgress("Calculating pixel density...") - calcPixelDensity() - +function loadingScreenSynthwave() { setLoadingProgress("Adding stars...") addStars() - - pauseAnimBtn(localStorage["isAnimating"] || "true") - - if (showLoading != "true") { - removeLoadingScreen() - } - else { - setLoadingProgress("Cleaning up...") - } -}, false) +} function addStars() { diff --git a/style.css b/style.css index 9c88132..81f7ad3 100644 --- a/style.css +++ b/style.css @@ -39,6 +39,8 @@ body { } #synthwaveCanvas { position: absolute; - bottom: round(0%, var(--pxDensityPx)); + top: round(0%, var(--pxDensityPx)); left: round(0%, var(--pxDensityPx)); + width: 100%; + height: 100%; } \ No newline at end of file