${
pbData.acc === undefined ? "-" : Math.floor(pbData.acc) + "%"
}
diff --git a/frontend/src/ts/elements/leaderboards.ts b/frontend/src/ts/elements/leaderboards.ts
index 6cbab8b82..7b2174e78 100644
--- a/frontend/src/ts/elements/leaderboards.ts
+++ b/frontend/src/ts/elements/leaderboards.ts
@@ -187,9 +187,9 @@ function updateFooter(lb: LbKey): void {
| ${entry.rank} |
You${toppercent ? toppercent : ""} |
- ${typingSpeedUnit.convert(entry.wpm).toFixed(2)}
+ | ${typingSpeedUnit.fromWpm(entry.wpm).toFixed(2)}
${entry.acc.toFixed(2)}% |
- ${typingSpeedUnit.convert(entry.raw).toFixed(2)}
+ | ${typingSpeedUnit.fromWpm(entry.raw).toFixed(2)}
${
!entry.consistency || entry.consistency === "-"
? "-"
@@ -341,9 +341,9 @@ async function fillTable(lb: LbKey, prepend?: number): Promise {
${entry.badgeId ? getBadgeHTMLbyId(entry.badgeId) : ""}
|
- ${typingSpeedUnit.convert(entry.wpm).toFixed(2)}
+ | ${typingSpeedUnit.fromWpm(entry.wpm).toFixed(2)}
${entry.acc.toFixed(2)}% |
- ${typingSpeedUnit.convert(entry.raw).toFixed(2)}
+ | ${typingSpeedUnit.fromWpm(entry.raw).toFixed(2)}
${
!entry.consistency || entry.consistency === "-"
? "-"
diff --git a/frontend/src/ts/pages/account.ts b/frontend/src/ts/pages/account.ts
index 55a1ce250..73224c28e 100644
--- a/frontend/src/ts/pages/account.ts
+++ b/frontend/src/ts/pages/account.ts
@@ -53,7 +53,7 @@ function loadMoreLines(lineIndex?: number): void {
let raw;
try {
- raw = typingSpeedUnit.convert(result.rawWpm).toFixed(2);
+ raw = typingSpeedUnit.fromWpm(result.rawWpm).toFixed(2);
if (raw === undefined) {
raw = "-";
}
@@ -161,7 +161,7 @@ function loadMoreLines(lineIndex?: number): void {
$(".pageAccount .history table tbody").append(`
| ${pb} |
- ${typingSpeedUnit.convert(result.wpm).toFixed(2)} |
+ ${typingSpeedUnit.fromWpm(result.wpm).toFixed(2)} |
${raw} |
${result.acc.toFixed(2)}% |
${consistency} |
@@ -538,7 +538,7 @@ async function fillContent(): Promise {
const bucketSize = typingSpeedUnit.histogramDataBucketSize;
const bucket = Math.floor(
- typingSpeedUnit.convert(result.wpm) / bucketSize
+ typingSpeedUnit.fromWpm(result.wpm) / bucketSize
);
//grow array if needed
@@ -619,8 +619,8 @@ async function fillContent(): Promise {
chartData.push({
x: filteredResults.length,
- y: Misc.roundTo2(typingSpeedUnit.convert(result.wpm)),
- wpm: Misc.roundTo2(typingSpeedUnit.convert(result.wpm)),
+ y: Misc.roundTo2(typingSpeedUnit.fromWpm(result.wpm)),
+ wpm: Misc.roundTo2(typingSpeedUnit.fromWpm(result.wpm)),
acc: result.acc,
mode: result.mode,
mode2: result.mode2,
@@ -628,7 +628,7 @@ async function fillContent(): Promise {
language: result.language,
timestamp: result.timestamp,
difficulty: result.difficulty,
- raw: Misc.roundTo2(typingSpeedUnit.convert(result.rawWpm)),
+ raw: Misc.roundTo2(typingSpeedUnit.fromWpm(result.rawWpm)),
isPb: result.isPb ?? false,
});
@@ -683,7 +683,7 @@ async function fillContent(): Promise {
activityChartData_avgWpm.push({
x: dateInt,
y: Misc.roundTo2(
- typingSpeedUnit.convert(activityChartData[dateInt].totalWpm) /
+ typingSpeedUnit.fromWpm(activityChartData[dateInt].totalWpm) /
activityChartData[dateInt].amount
),
});
@@ -844,7 +844,7 @@ async function fillContent(): Promise {
Misc.secondsToString(Math.round(totalSecondsFiltered), true, true)
);
- let highestSpeed: number | string = typingSpeedUnit.convert(topWpm);
+ let highestSpeed: number | string = typingSpeedUnit.fromWpm(topWpm);
if (Config.alwaysShowDecimalPlaces) {
highestSpeed = Misc.roundTo2(highestSpeed).toFixed(2);
@@ -857,7 +857,7 @@ async function fillContent(): Promise {
$(".pageAccount .highestWpm .title").text(`highest ${speedUnit}`);
$(".pageAccount .highestWpm .val").text(highestSpeed);
- let averageSpeed: number | string = typingSpeedUnit.convert(totalWpm);
+ let averageSpeed: number | string = typingSpeedUnit.fromWpm(totalWpm);
if (Config.alwaysShowDecimalPlaces) {
averageSpeed = Misc.roundTo2(averageSpeed / testCount).toFixed(2);
} else {
@@ -868,7 +868,7 @@ async function fillContent(): Promise {
$(".pageAccount .averageWpm .val").text(averageSpeed);
let averageSpeedLast10: number | string =
- typingSpeedUnit.convert(wpmLast10total);
+ typingSpeedUnit.fromWpm(wpmLast10total);
if (Config.alwaysShowDecimalPlaces) {
averageSpeedLast10 = Misc.roundTo2(averageSpeedLast10 / last10).toFixed(2);
} else {
@@ -880,7 +880,7 @@ async function fillContent(): Promise {
);
$(".pageAccount .averageWpm10 .val").text(averageSpeedLast10);
- let highestRawSpeed: number | string = typingSpeedUnit.convert(rawWpm.max);
+ let highestRawSpeed: number | string = typingSpeedUnit.fromWpm(rawWpm.max);
if (Config.alwaysShowDecimalPlaces) {
highestRawSpeed = Misc.roundTo2(highestRawSpeed).toFixed(2);
} else {
@@ -890,7 +890,7 @@ async function fillContent(): Promise {
$(".pageAccount .highestRaw .title").text(`highest raw ${speedUnit}`);
$(".pageAccount .highestRaw .val").text(highestRawSpeed);
- let averageRawSpeed: number | string = typingSpeedUnit.convert(rawWpm.total);
+ let averageRawSpeed: number | string = typingSpeedUnit.fromWpm(rawWpm.total);
if (Config.alwaysShowDecimalPlaces) {
averageRawSpeed = Misc.roundTo2(averageRawSpeed / rawWpm.count).toFixed(2);
} else {
@@ -900,7 +900,7 @@ async function fillContent(): Promise {
$(".pageAccount .averageRaw .title").text(`average raw ${speedUnit}`);
$(".pageAccount .averageRaw .val").text(averageRawSpeed);
- let averageRawSpeedLast10: number | string = typingSpeedUnit.convert(
+ let averageRawSpeedLast10: number | string = typingSpeedUnit.fromWpm(
rawWpm.last10Total
);
if (Config.alwaysShowDecimalPlaces) {
@@ -1007,7 +1007,7 @@ async function fillContent(): Promise {
$(".pageAccount .group.chart .below .text").text(
`Speed change per hour spent typing: ${
- plus + Misc.roundTo2(typingSpeedUnit.convert(wpmChangePerHour))
+ plus + Misc.roundTo2(typingSpeedUnit.fromWpm(wpmChangePerHour))
} ${Config.typingSpeedUnit}`
);
diff --git a/frontend/src/ts/test/live-burst.ts b/frontend/src/ts/test/live-burst.ts
index a2c4b9c3b..58b73397f 100644
--- a/frontend/src/ts/test/live-burst.ts
+++ b/frontend/src/ts/test/live-burst.ts
@@ -5,7 +5,7 @@ import { get as getTypingSpeedUnit } from "../utils/typing-speed-units";
export async function update(burst: number): Promise {
if (!Config.showLiveBurst) return;
- burst = Math.round(getTypingSpeedUnit(Config.typingSpeedUnit).convert(burst));
+ burst = Math.round(getTypingSpeedUnit(Config.typingSpeedUnit).fromWpm(burst));
(document.querySelector("#miniTimerAndLiveWpm .burst") as Element).innerHTML =
burst.toString();
(document.querySelector("#liveBurst") as Element).innerHTML =
diff --git a/frontend/src/ts/test/live-wpm.ts b/frontend/src/ts/test/live-wpm.ts
index 9f44c37c0..569c783da 100644
--- a/frontend/src/ts/test/live-wpm.ts
+++ b/frontend/src/ts/test/live-wpm.ts
@@ -14,7 +14,7 @@ export function update(wpm: number, raw: number): void {
number = raw;
}
number = Math.round(
- getTypingSpeedUnit(Config.typingSpeedUnit).convert(number)
+ getTypingSpeedUnit(Config.typingSpeedUnit).fromWpm(number)
);
miniLiveWpmElement.innerHTML = number.toString();
liveWpmElement.innerHTML = number.toString();
diff --git a/frontend/src/ts/test/result.ts b/frontend/src/ts/test/result.ts
index 170756b5c..f489f49ed 100644
--- a/frontend/src/ts/test/result.ts
+++ b/frontend/src/ts/test/result.ts
@@ -64,7 +64,7 @@ async function updateGraph(): Promise {
const chartData1 = [
...TestInput.wpmHistory.map((a) =>
- Misc.roundTo2(typingSpeedUnit.convert(a))
+ Misc.roundTo2(typingSpeedUnit.fromWpm(a))
),
];
@@ -72,7 +72,7 @@ async function updateGraph(): Promise {
const chartData2 = [
...result.chartData.raw.map((a) =>
- Misc.roundTo2(typingSpeedUnit.convert(a))
+ Misc.roundTo2(typingSpeedUnit.fromWpm(a))
),
];
@@ -171,7 +171,7 @@ export async function updateGraphPBLine(): Promise {
);
if (lpb === 0) return;
const typingSpeedUnit = getTypingSpeedUnit(Config.typingSpeedUnit);
- const chartlpb = Misc.roundTo2(typingSpeedUnit.convert(lpb)).toFixed(2);
+ const chartlpb = Misc.roundTo2(typingSpeedUnit.fromWpm(lpb)).toFixed(2);
resultAnnotation.push({
display: true,
type: "line",
@@ -198,7 +198,7 @@ export async function updateGraphPBLine(): Promise {
content: `PB: ${chartlpb}`,
},
});
- const lpbRange = typingSpeedUnit.convert(20);
+ const lpbRange = typingSpeedUnit.fromWpm(20);
if (
maxChartVal >= parseFloat(chartlpb) - lpbRange &&
maxChartVal <= parseFloat(chartlpb) + lpbRange
@@ -222,11 +222,11 @@ function updateWpmAndAcc(): void {
$("#result .stats .wpm .bottom").text("Infinite");
} else {
$("#result .stats .wpm .bottom").text(
- Misc.roundTo2(typingSpeedUnit.convert(result.wpm)).toFixed(2)
+ Misc.roundTo2(typingSpeedUnit.fromWpm(result.wpm)).toFixed(2)
);
}
$("#result .stats .raw .bottom").text(
- Misc.roundTo2(typingSpeedUnit.convert(result.rawWpm)).toFixed(2)
+ Misc.roundTo2(typingSpeedUnit.fromWpm(result.rawWpm)).toFixed(2)
);
if (Config.typingSpeedUnit != "wpm") {
@@ -272,11 +272,11 @@ function updateWpmAndAcc(): void {
$("#result .stats .wpm .bottom").text("Infinite");
} else {
$("#result .stats .wpm .bottom").text(
- Math.round(typingSpeedUnit.convert(result.wpm))
+ Math.round(typingSpeedUnit.fromWpm(result.wpm))
);
}
$("#result .stats .raw .bottom").text(
- Math.round(typingSpeedUnit.convert(result.rawWpm))
+ Math.round(typingSpeedUnit.fromWpm(result.rawWpm))
);
$("#result .stats .raw .bottom").attr("aria-label", rawWpmHover);
@@ -415,7 +415,7 @@ export async function updateCrown(): Promise {
pbDiff = Math.abs(result.wpm - lpb);
$("#result .stats .wpm .crown").attr(
"aria-label",
- "+" + Misc.roundTo2(typingSpeedUnit.convert(pbDiff))
+ "+" + Misc.roundTo2(typingSpeedUnit.fromWpm(pbDiff))
);
}
@@ -506,7 +506,7 @@ async function updateTags(dontSave: boolean): Promise {
type: "line",
id: "tpb",
scaleID: "wpm",
- value: typingSpeedUnit.convert(tpb),
+ value: typingSpeedUnit.fromWpm(tpb),
borderColor: themecolors["sub"],
borderWidth: 1,
borderDash: [2, 2],
@@ -526,7 +526,7 @@ async function updateTags(dontSave: boolean): Promise {
xAdjust: labelAdjust,
enabled: true,
content: `${tag.display} PB: ${Misc.roundTo2(
- typingSpeedUnit.convert(tpb)
+ typingSpeedUnit.fromWpm(tpb)
).toFixed(2)}`,
},
});
diff --git a/frontend/src/ts/test/test-ui.ts b/frontend/src/ts/test/test-ui.ts
index 0aed1abfd..c6a9af326 100644
--- a/frontend/src/ts/test/test-ui.ts
+++ b/frontend/src/ts/test/test-ui.ts
@@ -1246,7 +1246,7 @@ $(".pageTest #resultWordsHistory").on("mouseenter", ".words .word", (e) => {
${Math.round(
- getTypingSpeedUnit(Config.typingSpeedUnit).convert(burst)
+ getTypingSpeedUnit(Config.typingSpeedUnit).fromWpm(burst)
)}${Config.typingSpeedUnit}
`
diff --git a/frontend/src/ts/types/types.d.ts b/frontend/src/ts/types/types.d.ts
index 1439a41a9..492cf321a 100644
--- a/frontend/src/ts/types/types.d.ts
+++ b/frontend/src/ts/types/types.d.ts
@@ -884,7 +884,7 @@ declare namespace MonkeyTypes {
type TypingSpeedUnit = "wpm" | "cpm" | "wps" | "cps" | "wph";
interface TypingSpeedUnitSettings {
- convert: (number) => number;
+ fromWpm: (number) => number;
convertWithUnitSuffix: (number) => string;
fullUnitString: string;
histogramDataBucketSize: number;
diff --git a/frontend/src/ts/utils/typing-speed-units.ts b/frontend/src/ts/utils/typing-speed-units.ts
index 4d27ce2b6..4d206b7a6 100644
--- a/frontend/src/ts/utils/typing-speed-units.ts
+++ b/frontend/src/ts/utils/typing-speed-units.ts
@@ -4,7 +4,7 @@ const typingSpeedUnits: Record<
MonkeyTypes.TypingSpeedUnitSettings
> = {
wpm: {
- convert: (wpm: number) => wpm,
+ fromWpm: (wpm: number) => wpm,
convertWithUnitSuffix: (wpm: number) => {
return convertTypingSpeedWithUnitSuffix("wpm", wpm);
},
@@ -14,7 +14,7 @@ const typingSpeedUnits: Record<
historyStepSize: 10,
},
cpm: {
- convert: (wpm: number) => wpm * 5,
+ fromWpm: (wpm: number) => wpm * 5,
convertWithUnitSuffix: (wpm: number) => {
return convertTypingSpeedWithUnitSuffix("cpm", wpm);
},
@@ -23,7 +23,7 @@ const typingSpeedUnits: Record<
historyStepSize: 100,
},
wps: {
- convert: (wpm: number) => wpm / 60,
+ fromWpm: (wpm: number) => wpm / 60,
convertWithUnitSuffix: (wpm: number) => {
return convertTypingSpeedWithUnitSuffix("wps", wpm);
},
@@ -32,7 +32,7 @@ const typingSpeedUnits: Record<
historyStepSize: 2,
},
cps: {
- convert: (wpm: number) => (wpm * 5) / 60,
+ fromWpm: (wpm: number) => (wpm * 5) / 60,
convertWithUnitSuffix: (wpm: number) => {
return convertTypingSpeedWithUnitSuffix("cps", wpm);
},
@@ -41,7 +41,7 @@ const typingSpeedUnits: Record<
historyStepSize: 5,
},
wph: {
- convert: (wpm: number) => wpm * 60,
+ fromWpm: (wpm: number) => wpm * 60,
convertWithUnitSuffix: (wpm: number) => {
return convertTypingSpeedWithUnitSuffix("wph", wpm);
},
@@ -62,5 +62,5 @@ function convertTypingSpeedWithUnitSuffix(
unit: MonkeyTypes.TypingSpeedUnit,
wpm: number
): string {
- return roundTo2(get(unit).convert(wpm)).toFixed(2) + " " + unit;
+ return roundTo2(get(unit).fromWpm(wpm)).toFixed(2) + " " + unit;
}
|