Last active
May 6, 2025 04:40
-
-
Save xero/beec5dd7946df39703737750b58da282 to your computer and use it in GitHub Desktop.
self contained classic BBS style page loading animation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// modified bbs loading animation from bootstrap 386 | |
// https://github.com/kristopolous/BOOTSTRA.386 | |
// view it in action at https://0w.nz | |
document.addEventListener("DOMContentLoaded", function () { | |
$ = function $(selector, context = document) { | |
return Array.from(context.querySelectorAll(selector)); | |
}; | |
_ = function _(action, obj, parent = document.body) { | |
action == "add" ? parent.appendChild(obj) : parent.removeChild(obj); | |
}; | |
(function () { | |
var onePass = true; | |
(character = { height: 20, width: 12.4 }), | |
(pass = 0), | |
(speedFactor = (1 / (1.25 || 1)) * 165000), | |
(wrap = document.createElement("div")), | |
(bar = wrap.appendChild(document.createElement("div"))), | |
(cursor = document.createElement("div")), | |
(height = window.innerHeight), | |
(width = window.innerWidth), | |
(rounds = (height * width) / speedFactor), | |
(col = width), | |
(row = height - character.height); | |
wrap.id = "splash"; | |
bar.id = "bbs"; | |
cursor.id = "cursor"; | |
if (pass === 0) { | |
_("add", wrap); | |
} else { | |
_("add", cursor); | |
rounds /= 2; | |
character.height *= 4; | |
} | |
cursor.innerHTML = bar.innerHTML = "▄"; | |
var l = setInterval(function () { | |
for (var m = 0; m < rounds; m++) { | |
col -= character.width; | |
if (col <= 0) { | |
col = width; | |
row -= character.height; | |
} | |
if (row <= 0) { | |
pass++; | |
row = height - character.height; | |
if (pass == 2) { | |
_("rm", cursor); | |
clearInterval(l); | |
} else { | |
_("rm", wrap, wrap.parentNode); | |
if (onePass) { | |
clearInterval(l); | |
} else { | |
_("add", cursor); | |
rounds /= 2; | |
character.height *= 4; | |
} | |
} | |
} | |
if (pass === 0) { | |
bar.style.width = col + "px"; | |
wrap.style.height = row + "px"; | |
} else { | |
cursor.style.right = col + "px"; | |
cursor.style.bottom = row + "px"; | |
} | |
} | |
}, 1); | |
})(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment