mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-22 16:26:18 +08:00
Merge branch 'master' into newads
This commit is contained in:
commit
efef1bce85
|
@ -238,7 +238,6 @@ function handleSpace(): void {
|
|||
Caret.updatePosition();
|
||||
TestInput.incrementKeypressCount();
|
||||
TestInput.pushKeypressWord(TestWords.words.currentIndex);
|
||||
TestInput.updateLastKeypress();
|
||||
if (Config.difficulty == "expert" || Config.difficulty == "master") {
|
||||
TestLogic.fail("difficulty");
|
||||
return;
|
||||
|
@ -249,6 +248,7 @@ function handleSpace(): void {
|
|||
}
|
||||
Replay.addReplayEvent("submitErrorWord");
|
||||
}
|
||||
TestInput.updateLastKeypress();
|
||||
|
||||
let wordLength: number;
|
||||
if (Config.mode === "zen") {
|
||||
|
@ -885,7 +885,7 @@ $(document).keydown(async (event) => {
|
|||
0,
|
||||
{
|
||||
important: true,
|
||||
duration: 5000,
|
||||
duration: 5,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1555,6 +1555,11 @@ export async function finish(difficultyFailed = false): Promise<void> {
|
|||
|
||||
TestInput.forceKeyup(now); //this ensures that the last keypress(es) are registered
|
||||
|
||||
const endAfkSeconds = (now - TestInput.keypressTimings.spacing.last) / 1000;
|
||||
if ((Config.mode == "zen" || TestInput.bailout) && endAfkSeconds < 7) {
|
||||
TestStats.setEnd(TestInput.keypressTimings.spacing.last);
|
||||
}
|
||||
|
||||
TestUI.setResultCalculating(true);
|
||||
TestUI.setResultVisible(true);
|
||||
TestState.setActive(false);
|
||||
|
|
|
@ -4,6 +4,7 @@ import * as Misc from "../utils/misc";
|
|||
import * as TestInput from "./test-input";
|
||||
import * as TestWords from "./test-words";
|
||||
import * as FunboxList from "./funbox/funbox-list";
|
||||
import * as TestState from "./test-state";
|
||||
|
||||
interface CharCount {
|
||||
spaces: number;
|
||||
|
@ -186,16 +187,12 @@ export function setInvalid(): void {
|
|||
|
||||
export function calculateTestSeconds(now?: number): number {
|
||||
if (now === undefined) {
|
||||
const endAfkSeconds = (end - TestInput.lastKeypress) / 1000;
|
||||
if ((Config.mode == "zen" || TestInput.bailout) && endAfkSeconds < 7) {
|
||||
return (TestInput.lastKeypress - start) / 1000;
|
||||
} else {
|
||||
return (end - start) / 1000;
|
||||
}
|
||||
return (end - start) / 1000;
|
||||
} else {
|
||||
return (now - start) / 1000;
|
||||
}
|
||||
}
|
||||
|
||||
let avg = 0;
|
||||
export function calculateWpmAndRaw(): MonkeyTypes.WordsPerMinuteAndRaw {
|
||||
const start = performance.now();
|
||||
|
@ -279,13 +276,15 @@ export function calculateWpmAndRaw(): MonkeyTypes.WordsPerMinuteAndRaw {
|
|||
spaces = 0;
|
||||
}
|
||||
chars += currTestInput.length;
|
||||
const testSeconds = calculateTestSeconds(performance.now());
|
||||
const testSeconds = calculateTestSeconds(
|
||||
TestState.isActive ? performance.now() : end
|
||||
);
|
||||
const wpm = Math.round(
|
||||
((correctWordChars + spaces) * (60 / testSeconds)) / 5
|
||||
);
|
||||
const raw = Math.round(((chars + spaces) * (60 / testSeconds)) / 5);
|
||||
const end = performance.now();
|
||||
avg = (end - start + avg) / 2;
|
||||
const endPerf = performance.now();
|
||||
avg = (endPerf - start + avg) / 2;
|
||||
return {
|
||||
wpm: wpm,
|
||||
raw: raw,
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
"John",
|
||||
"Moanatari",
|
||||
"Gregory",
|
||||
"Yen Cheng",
|
||||
"Hopeless Love",
|
||||
"Kalen",
|
||||
"Ben",
|
||||
|
|
Loading…
Reference in a new issue