From 801e1dd9658d5a8636c1ea07e73f953c15a4ae1f Mon Sep 17 00:00:00 2001 From: YouHaveTrouble Date: Wed, 9 Oct 2024 21:27:33 +0200 Subject: [PATCH] more classic style of visitor count - have a minimum amount of digits --- src/components/ViewCounter.astro | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/ViewCounter.astro b/src/components/ViewCounter.astro index bd2a969..c77704d 100644 --- a/src/components/ViewCounter.astro +++ b/src/components/ViewCounter.astro @@ -1,6 +1,11 @@
? + ? + ? + ? + ? + ?
unique visitors
@@ -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");