Skip to content

Commit

Permalink
impr(about): add spaces to the stats numbers to make them easier to read
Browse files Browse the repository at this point in the history
  • Loading branch information
Miodec committed Oct 30, 2023
1 parent 1b71d05 commit eb89b83
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions frontend/src/ts/pages/about.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -70,7 +70,7 @@ function updateStatsAndHistogram(): void {
);
$(".pageAbout #totalStartedTestsStat").attr(
"aria-label",
typingStatsResponseData.testsStarted + " tests"
Misc.numberWithSpaces(typingStatsResponseData.testsStarted) + " tests"
);

const completedWIthMagnitude = Misc.getNumberWithMagnitude(
Expand All @@ -87,7 +87,7 @@ function updateStatsAndHistogram(): void {
);
$(".pageAbout #totalCompletedTestsStat").attr(
"aria-label",
typingStatsResponseData.testsCompleted + " tests"
Misc.numberWithSpaces(typingStatsResponseData.testsCompleted) + " tests"
);
}
}
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/ts/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit eb89b83

Please sign in to comment.