impr(about): add spaces to the stats numbers to make them easier to read

This commit is contained in:
Miodec 2023-10-30 12:33:43 +00:00
parent 1b71d05a9f
commit eb89b838a5
2 changed files with 7 additions and 3 deletions

View file

@ -53,7 +53,7 @@ function updateStatsAndHistogram(): void {
$(".pageAbout #totalTimeTypingStat .valSmall").text("years");
$(".pageAbout #totalTimeTypingStat").attr(
"aria-label",
Math.round(secondsRounded / 3600) + " hours"
Misc.numberWithSpaces(Math.round(secondsRounded / 3600)) + " hours"
);
const startedWithMagnitude = Misc.getNumberWithMagnitude(
@ -70,7 +70,7 @@ function updateStatsAndHistogram(): void {
);
$(".pageAbout #totalStartedTestsStat").attr(
"aria-label",
typingStatsResponseData.testsStarted + " tests"
Misc.numberWithSpaces(typingStatsResponseData.testsStarted) + " tests"
);
const completedWIthMagnitude = Misc.getNumberWithMagnitude(
@ -87,7 +87,7 @@ function updateStatsAndHistogram(): void {
);
$(".pageAbout #totalCompletedTestsStat").attr(
"aria-label",
typingStatsResponseData.testsCompleted + " tests"
Misc.numberWithSpaces(typingStatsResponseData.testsCompleted) + " tests"
);
}
}

View file

@ -1707,4 +1707,8 @@ export function getNumberWithMagnitude(num: number): {
};
}
export function numberWithSpaces(x: number): string {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
}
// DO NOT ALTER GLOBAL OBJECTSONSTRUCTOR, IT WILL BREAK RESULT HASHES