diff --git a/frontend/src/ts/test/test-logic.ts b/frontend/src/ts/test/test-logic.ts index 28206df798bf..96ee87c03e9c 100644 --- a/frontend/src/ts/test/test-logic.ts +++ b/frontend/src/ts/test/test-logic.ts @@ -904,7 +904,7 @@ export async function finish(difficultyFailed = false): Promise { //need one more calculation for the last word if test auto ended if (TestInput.burstHistory.length !== TestInput.input.getHistory()?.length) { - const burst = TestStats.calculateBurst(); + const burst = TestStats.calculateBurst(now); TestInput.pushBurstToHistory(burst); } diff --git a/frontend/src/ts/test/test-stats.ts b/frontend/src/ts/test/test-stats.ts index c86721225144..2644e4ee6a88 100644 --- a/frontend/src/ts/test/test-stats.ts +++ b/frontend/src/ts/test/test-stats.ts @@ -217,9 +217,9 @@ export function setLastSecondNotRound(): void { lastSecondNotRound = true; } -export function calculateBurst(): number { +export function calculateBurst(endTime: number = performance.now()): number { const containsKorean = TestInput.input.getKoreanStatus(); - const timeToWrite = (performance.now() - TestInput.currentBurstStart) / 1000; + const timeToWrite = (endTime - TestInput.currentBurstStart) / 1000; let wordLength: number; wordLength = !containsKorean ? TestInput.input.current.length diff --git a/frontend/src/ts/test/test-ui.ts b/frontend/src/ts/test/test-ui.ts index 6dfa81b14e32..d10e6e6651a8 100644 --- a/frontend/src/ts/test/test-ui.ts +++ b/frontend/src/ts/test/test-ui.ts @@ -1436,8 +1436,7 @@ export async function applyBurstHeatmap(): Promise { let burstlist = [...TestInput.burstHistory]; - burstlist = burstlist.filter((x) => x !== Infinity); - burstlist = burstlist.filter((x) => x < 500); + burstlist = burstlist.map((x) => (x >= 1000 ? Infinity : x)); const typingSpeedUnit = getTypingSpeedUnit(Config.typingSpeedUnit); burstlist.forEach((burst, index) => { @@ -1508,7 +1507,7 @@ export async function applyBurstHeatmap(): Promise { } $("#resultWordsHistory .heatmapLegend .box" + index).html( - `
${string}
`, + `
${Misc.escapeHTML(string)}
`, ); }); @@ -1977,7 +1976,7 @@ $(".pageTest #resultWordsHistory").on("mouseenter", ".words .word", (e) => { .replace(/>/g, ">")}
- ${Format.typingSpeed(burst, { showDecimalPlaces: false })} + ${isNaN(burst) || burst >= 1000 ? "Infinite" : Format.typingSpeed(burst, { showDecimalPlaces: false })} ${Config.typingSpeedUnit}
`,