more classic style of visitor count - have a minimum amount of digits

This commit is contained in:
2024-10-09 21:27:33 +02:00
parent 07357557e6
commit 801e1dd965
+9 -1
View File
@@ -1,6 +1,11 @@
<div class="view-counter">
<div data-viewcount>
<span>?</span>
<span>?</span>
<span>?</span>
<span>?</span>
<span>?</span>
<span>?</span>
</div>
<div>unique visitors</div>
</div>
@@ -52,7 +57,10 @@
if (result === null) return;
const json = await result.json();
const rawCount = json.count;
const chars = rawCount.toString();
let chars = rawCount.toString();
while (chars.length < 6) {
chars = "0" + chars;
}
viewCounter.innerHTML = "";
for (let i = 0; i < chars.length; i++) {
const span = document.createElement("span");