Basic stats section

This commit is contained in:
bingus_violet 2024-04-23 09:08:04 -05:00
parent 4e05808f4f
commit 2899126ff2
2 changed files with 32 additions and 3 deletions

View file

@ -18,6 +18,7 @@ var commitCount = "400+"
var lanyardData = undefined
var uptime = Date.now()
var reloads = 0
function firstToUpper(str) {
return str.charAt(0).toUpperCase() + str.slice(1)
@ -25,7 +26,23 @@ function firstToUpper(str) {
var thumborURL = "https://thumbor.violets-purgatory.dev/unsafe/"
function timeFormatter(seconds) {
seconds = Math.ceil(seconds)
var minutes = Math.ceil(seconds / 60)
var hours = Math.floor(minutes / 60)
if (seconds <= 60) {
return 'about ' + seconds + ' seconds'
} else if (minutes < 60) {
return `${minutes} Minutes`
}
return `${hours} hours and ${minutes % 60} minutes`
}
function converter(html, query) {
reloads += 1
var startTime = Date.now()
while (html.includes("{PATH_")) {
var pagePath = html.substring(html.indexOf("{PATH_"))
pagePath = pagePath.substring(6, pagePath.indexOf('}'))
@ -77,7 +94,9 @@ function converter(html, query) {
"DISCORD_USER": username,
"CUSTOM_STATUS": statusText,
"LATEST_YOUTUBE": "filler",
"SPINCOUNT": globalSpins
"SPINCOUNT": globalSpins,
"UPTIME": timeFormatter((Date.now() - uptime) / 1000),
"RELOAD_COUNT": reloads
}
var rpTable = Object.keys(replacers)
@ -115,6 +134,8 @@ function converter(html, query) {
html = html.replaceAll("{WEATHER_TEXT}", "")
}
html = html.replaceAll("{LOAD_TIME}", (Date.now() - startTime).toString() + "ms")
return html
}

View file

@ -55,7 +55,7 @@
<div class="linkContainer">
<a class="chip" href="./socials/">Socials</a>
<a class="chip" href="https://blog.violets-purgatory.dev">Blog</a>
<a class="chip" href="./stats">Stats</a>
<!-- <a class="chip" href="./stats">Stats</a> -->
<a class="chip" href="./faq">Nerd FAQ</a>
<a class="chip" href="https://{BRANCH_SUB}violets-purgatory.dev">{BRANCH_NAME} site</a>
<a class="chip" href="https://fs.violets-purgatory.dev">FileShare</a>
@ -80,10 +80,18 @@
<hr>
<h1>Socials</h1>
{PATH_SOCIALS}
<p class="note">Please note I am extremely unhinged and gay on Fedi, I don't use Github, and I barely understand Docker.</p>
<br>
<!-- <h1>FAQ:</h1>
{PATH_FAQ} -->
<h1><hr>Stats</h1>
<br>
<ul>
<li>Page generation time: {LOAD_TIME}</li>
<li>Uptime: {UPTIME}</li>
<li>Total reloads: {RELOAD_COUNT}</li>
</ul>
<p>{WEATHER_TEXT}</p>
<br>
</main>