let isLoading = true
let stopLoading = false
let loadingScreenEl = document.getElementById("loadingScreen")
let loadingComplete = false
let fakeLoadingComplete = false
loadingScreenEl.className = "bgDiv"
loadingScreenEl.innerHTML = `
Loading...
Loading files...
Tip: Tip loading...
`
let loadingScreenProgress = document.getElementById("loadingText")
let tipsJson
async function loadTips() {
let tipsText = await fetch("/data/loadingScreenTips.json").then(response => response.text())
tipsJson = JSON.parse(tipsText)
console.log(tipsJson)
}
const fakeLoading = localStorage["fakeLoading"] != "false"
let selectedTip = "undefined"
function newTip() {
if (randomIntFrom0(1000) == 0) {
// If you snitch the code for this easter egg
// then I'll permanently remove the easter egg.
selectedTip = `You like kissing boys, don't you?
`
}
else {
selectedTip = tipsJson[randomIntFrom0(tipsJson.length)]
}
debugPrint("new tip", selectedTip)
}
function setLoadingProgress(newText) {
loadingScreenProgress.innerHTML = `Loading...
${newText}
Tip: ${selectedTip}`
}
function startLoadingScreen() {
loadingScreenProgress.innerHTML = `Loading...
Tip: ${selectedTip}`
const loadDur = randomFloat(2000, 4000)
debugPrint("loadDur initial", loadDur)
setTimeout(function() {
if (loadingComplete) { removeLoadingScreen() }
fakeLoadingComplete = true
}, loadDur)
}
function removeLoadingScreen() {
if (!isLoading) { return }
setLoadingProgress("Done!")
isLoading = false
const fadeOutDur = 0.5
setTimeout(function() {
loadingScreenEl.style.animation = `fade-out ${fadeOutDur}s forwards`
setTimeout(function() {
loadingScreenEl.style.left = "100vw"
newTip()
}, fadeOutDur * 1000)
}, 500)
}
function setShowFakeLoading(state) {
localStorage["fakeLoading"] = state.toString()
}
document.addEventListener("keydown", function(event) {
if (event.key === "Escape") {
removeLoadingScreen()
}
})