mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-20 15:26:15 +08:00
== -> === in the rest of the files
This commit is contained in:
parent
55198831f9
commit
9d27820f1c
|
@ -61,7 +61,7 @@ export function isTestTooShort(result: MonkeyTypes.CompletedEvent): boolean {
|
|||
|
||||
if (mode === "time") {
|
||||
const setTimeTooShort = mode2 > 0 && mode2 < 15;
|
||||
const infiniteTimeTooShort = mode2 === 0 && testDuration < 15;
|
||||
const infiniteTimeTooShort = mode2 === "0" && testDuration < 15;
|
||||
const bailedOutTooShort = bailedOut
|
||||
? bailedOut && testDuration < 15
|
||||
: false;
|
||||
|
@ -70,7 +70,7 @@ export function isTestTooShort(result: MonkeyTypes.CompletedEvent): boolean {
|
|||
|
||||
if (mode === "words") {
|
||||
const setWordTooShort = mode2 > 0 && mode2 < 10;
|
||||
const infiniteWordTooShort = mode2 === 0 && testDuration < 15;
|
||||
const infiniteWordTooShort = mode2 === "0" && testDuration < 15;
|
||||
const bailedOutTooShort = bailedOut
|
||||
? bailedOut && testDuration < 15
|
||||
: false;
|
||||
|
|
|
@ -13,7 +13,7 @@ export function checkFunboxForcedConfigs(
|
|||
if (FunboxList.get(funbox).length === 0) return { result: true };
|
||||
|
||||
if (key === "words" || key === "time") {
|
||||
if (value == 0) {
|
||||
if (value === 0 || value === "0") {
|
||||
if (funbox === "nospace") {
|
||||
console.log("break");
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ export function canSetConfigWithCurrentFunboxes(
|
|||
)
|
||||
);
|
||||
}
|
||||
if (value === "quote" || value == "custom") {
|
||||
if (value === "quote" || value === "custom") {
|
||||
fb = fb.concat(
|
||||
FunboxList.get(funbox).filter(
|
||||
(f) =>
|
||||
|
@ -194,14 +194,14 @@ export function areFunboxesCompatible(
|
|||
let funboxesToCheck = FunboxList.get(funboxes);
|
||||
if (withFunbox !== undefined) {
|
||||
funboxesToCheck = funboxesToCheck.concat(
|
||||
FunboxList.getAll().filter((f) => f.name == withFunbox)
|
||||
FunboxList.getAll().filter((f) => f.name === withFunbox)
|
||||
);
|
||||
}
|
||||
|
||||
const allFunboxesAreValid =
|
||||
FunboxList.get(funboxes).filter(
|
||||
(f) => funboxes.split("#").find((cf) => cf == f.name) !== undefined
|
||||
).length == funboxes.split("#").length;
|
||||
(f) => funboxes.split("#").find((cf) => cf === f.name) !== undefined
|
||||
).length === funboxes.split("#").length;
|
||||
const oneWordModifierMax =
|
||||
funboxesToCheck.filter(
|
||||
(f) =>
|
||||
|
@ -211,53 +211,54 @@ export function areFunboxesCompatible(
|
|||
).length <= 1;
|
||||
const layoutUsability =
|
||||
funboxesToCheck.filter((f) =>
|
||||
f.properties?.find((fp) => fp == "changesLayout")
|
||||
).length == 0 ||
|
||||
f.properties?.find((fp) => fp === "changesLayout")
|
||||
).length === 0 ||
|
||||
funboxesToCheck.filter((f) =>
|
||||
f.properties?.find((fp) => fp == "ignoresLayout" || fp == "usesLayout")
|
||||
).length == 0;
|
||||
f.properties?.find((fp) => fp === "ignoresLayout" || fp === "usesLayout")
|
||||
).length === 0;
|
||||
const oneNospaceOrToPushMax =
|
||||
funboxesToCheck.filter((f) =>
|
||||
f.properties?.find((fp) => fp == "nospace" || fp.startsWith("toPush"))
|
||||
f.properties?.find((fp) => fp === "nospace" || fp.startsWith("toPush"))
|
||||
).length <= 1;
|
||||
const oneChangesWordsVisibilityMax =
|
||||
funboxesToCheck.filter((f) =>
|
||||
f.properties?.find((fp) => fp == "changesWordsVisibility")
|
||||
f.properties?.find((fp) => fp === "changesWordsVisibility")
|
||||
).length <= 1;
|
||||
const oneFrequencyChangesMax =
|
||||
funboxesToCheck.filter((f) =>
|
||||
f.properties?.find((fp) => fp == "changesWordsFrequency")
|
||||
f.properties?.find((fp) => fp === "changesWordsFrequency")
|
||||
).length <= 1;
|
||||
const noFrequencyChangesConflicts =
|
||||
funboxesToCheck.filter((f) =>
|
||||
f.properties?.find((fp) => fp == "changesWordsFrequency")
|
||||
).length == 0 ||
|
||||
f.properties?.find((fp) => fp === "changesWordsFrequency")
|
||||
).length === 0 ||
|
||||
funboxesToCheck.filter((f) =>
|
||||
f.properties?.find((fp) => fp == "ignoresLanguage")
|
||||
).length == 0;
|
||||
f.properties?.find((fp) => fp === "ignoresLanguage")
|
||||
).length === 0;
|
||||
const capitalisationChangePosibility =
|
||||
funboxesToCheck.filter((f) => f.properties?.find((fp) => fp == "noLetters"))
|
||||
.length == 0 ||
|
||||
funboxesToCheck.filter((f) =>
|
||||
f.properties?.find((fp) => fp == "changesCapitalisation")
|
||||
).length == 0;
|
||||
f.properties?.find((fp) => fp === "noLetters")
|
||||
).length === 0 ||
|
||||
funboxesToCheck.filter((f) =>
|
||||
f.properties?.find((fp) => fp === "changesCapitalisation")
|
||||
).length === 0;
|
||||
const noConflictsWithSymmetricChars =
|
||||
funboxesToCheck.filter((f) =>
|
||||
f.properties?.find((fp) => fp == "conflictsWithSymmetricChars")
|
||||
).length == 0 ||
|
||||
f.properties?.find((fp) => fp === "conflictsWithSymmetricChars")
|
||||
).length === 0 ||
|
||||
funboxesToCheck.filter((f) =>
|
||||
f.properties?.find((fp) => fp == "symmetricChars")
|
||||
).length == 0;
|
||||
f.properties?.find((fp) => fp === "symmetricChars")
|
||||
).length === 0;
|
||||
const canSpeak =
|
||||
funboxesToCheck.filter((f) =>
|
||||
f.properties?.find((fp) => fp == "speaks" || fp == "unspeakable")
|
||||
f.properties?.find((fp) => fp === "speaks" || fp === "unspeakable")
|
||||
).length <= 1;
|
||||
const hasLanguageToSpeak =
|
||||
funboxesToCheck.filter((f) => f.properties?.find((fp) => fp == "speaks"))
|
||||
.length == 0 ||
|
||||
funboxesToCheck.filter((f) => f.properties?.find((fp) => fp === "speaks"))
|
||||
.length === 0 ||
|
||||
funboxesToCheck.filter((f) =>
|
||||
f.properties?.find((fp) => fp == "ignoresLanguage")
|
||||
).length == 0;
|
||||
f.properties?.find((fp) => fp === "ignoresLanguage")
|
||||
).length === 0;
|
||||
const oneToPushOrPullSectionMax =
|
||||
funboxesToCheck.filter(
|
||||
(f) =>
|
||||
|
|
|
@ -196,7 +196,7 @@ function toggleReplayDisplay(): void {
|
|||
} else {
|
||||
//hide
|
||||
if (
|
||||
(toggleButton?.parentNode as Element)?.getAttribute("aria-label") !=
|
||||
(toggleButton?.parentNode as Element)?.getAttribute("aria-label") !==
|
||||
"Start replay"
|
||||
) {
|
||||
pauseReplay();
|
||||
|
|
|
@ -21,8 +21,8 @@ import * as TestStats from "./test-stats";
|
|||
import * as TestUI from "./test-ui";
|
||||
import * as TodayTracker from "./today-tracker";
|
||||
|
||||
// eslint-disable-next-line no-duplicate-imports -- need to ignore because eslint doesnt know what import type is
|
||||
import confetti from "canvas-confetti";
|
||||
// eslint-disable-next-line no-duplicate-imports -- need to ignore because eslint doesnt know what import type is
|
||||
import type { PluginChartOptions, ScaleChartOptions } from "chart.js";
|
||||
import type { AnnotationOptions } from "chartjs-plugin-annotation";
|
||||
import Ape from "../ape";
|
||||
|
|
|
@ -1,61 +1,61 @@
|
|||
import objectHash from "object-hash";
|
||||
import Ape from "../ape";
|
||||
import * as TestUI from "./test-ui";
|
||||
import * as ManualRestart from "./manual-restart-tracker";
|
||||
import Config, * as UpdateConfig from "../config";
|
||||
import * as Misc from "../utils/misc";
|
||||
import * as AdController from "../controllers/ad-controller";
|
||||
import * as AnalyticsController from "../controllers/analytics-controller";
|
||||
import * as ChallengeContoller from "../controllers/challenge-controller";
|
||||
import QuotesController from "../controllers/quotes-controller";
|
||||
import * as Notifications from "../elements/notifications";
|
||||
import * as CustomText from "./custom-text";
|
||||
import * as CustomTextState from "../states/custom-text-name";
|
||||
import * as TestStats from "./test-stats";
|
||||
import * as PractiseWords from "./practise-words";
|
||||
import * as ShiftTracker from "./shift-tracker";
|
||||
import * as Focus from "./focus";
|
||||
import * as Funbox from "./funbox/funbox";
|
||||
import * as Keymap from "../elements/keymap";
|
||||
import * as ThemeController from "../controllers/theme-controller";
|
||||
import * as PaceCaret from "./pace-caret";
|
||||
import * as Caret from "./caret";
|
||||
import * as LiveWpm from "./live-wpm";
|
||||
import * as LiveAcc from "./live-acc";
|
||||
import * as LiveBurst from "./live-burst";
|
||||
import * as TimerProgress from "./timer-progress";
|
||||
import * as DB from "../db";
|
||||
import * as AccountButton from "../elements/account-button";
|
||||
import * as Keymap from "../elements/keymap";
|
||||
import * as Last10Average from "../elements/last-10-average";
|
||||
import * as ModesNotice from "../elements/modes-notice";
|
||||
import * as MonkeyPower from "../elements/monkey-power";
|
||||
import * as Notifications from "../elements/notifications";
|
||||
import { Auth } from "../firebase";
|
||||
import * as ConfigEvent from "../observables/config-event";
|
||||
import * as KeymapEvent from "../observables/keymap-event";
|
||||
import * as TimerEvent from "../observables/timer-event";
|
||||
import * as QuoteRatePopup from "../popups/quote-rate-popup";
|
||||
import * as QuoteSearchPopup from "../popups/quote-search-popup";
|
||||
import * as QuoteSubmitPopup from "../popups/quote-submit-popup";
|
||||
import * as PbCrown from "./pb-crown";
|
||||
import * as TestTimer from "./test-timer";
|
||||
import * as OutOfFocus from "./out-of-focus";
|
||||
import * as AccountButton from "../elements/account-button";
|
||||
import * as DB from "../db";
|
||||
import * as Replay from "./replay";
|
||||
import * as TodayTracker from "./today-tracker";
|
||||
import * as Wordset from "./wordset";
|
||||
import * as ChallengeContoller from "../controllers/challenge-controller";
|
||||
import * as QuoteRatePopup from "../popups/quote-rate-popup";
|
||||
import * as BritishEnglish from "./british-english";
|
||||
import * as EnglishPunctuation from "./english-punctuation";
|
||||
import * as LazyMode from "./lazy-mode";
|
||||
import * as Result from "./result";
|
||||
import * as MonkeyPower from "../elements/monkey-power";
|
||||
import * as ActivePage from "../states/active-page";
|
||||
import * as TestInput from "./test-input";
|
||||
import * as TestWords from "./test-words";
|
||||
import * as TestState from "./test-state";
|
||||
import * as ModesNotice from "../elements/modes-notice";
|
||||
import * as PageTransition from "../states/page-transition";
|
||||
import * as ConfigEvent from "../observables/config-event";
|
||||
import * as TimerEvent from "../observables/timer-event";
|
||||
import * as Last10Average from "../elements/last-10-average";
|
||||
import * as Monkey from "./monkey";
|
||||
import objectHash from "object-hash";
|
||||
import * as AnalyticsController from "../controllers/analytics-controller";
|
||||
import { Auth } from "../firebase";
|
||||
import * as AdController from "../controllers/ad-controller";
|
||||
import * as TestConfig from "./test-config";
|
||||
import * as ConnectionState from "../states/connection";
|
||||
import * as CustomTextState from "../states/custom-text-name";
|
||||
import * as PageTransition from "../states/page-transition";
|
||||
import * as Misc from "../utils/misc";
|
||||
import * as BritishEnglish from "./british-english";
|
||||
import * as Caret from "./caret";
|
||||
import * as CustomText from "./custom-text";
|
||||
import * as EnglishPunctuation from "./english-punctuation";
|
||||
import * as Focus from "./focus";
|
||||
import * as Funbox from "./funbox/funbox";
|
||||
import * as FunboxList from "./funbox/funbox-list";
|
||||
import * as MemoryFunboxTimer from "./funbox/memory-funbox-timer";
|
||||
import * as KeymapEvent from "../observables/keymap-event";
|
||||
import * as LazyMode from "./lazy-mode";
|
||||
import * as LiveAcc from "./live-acc";
|
||||
import * as LiveBurst from "./live-burst";
|
||||
import * as LiveWpm from "./live-wpm";
|
||||
import * as ManualRestart from "./manual-restart-tracker";
|
||||
import * as Monkey from "./monkey";
|
||||
import * as OutOfFocus from "./out-of-focus";
|
||||
import * as PaceCaret from "./pace-caret";
|
||||
import * as PbCrown from "./pb-crown";
|
||||
import * as PractiseWords from "./practise-words";
|
||||
import * as Replay from "./replay";
|
||||
import * as Result from "./result";
|
||||
import * as ShiftTracker from "./shift-tracker";
|
||||
import * as TestConfig from "./test-config";
|
||||
import * as TestInput from "./test-input";
|
||||
import * as TestState from "./test-state";
|
||||
import * as TestStats from "./test-stats";
|
||||
import * as TestTimer from "./test-timer";
|
||||
import * as TestUI from "./test-ui";
|
||||
import * as TestWords from "./test-words";
|
||||
import * as TimerProgress from "./timer-progress";
|
||||
import * as TodayTracker from "./today-tracker";
|
||||
import * as Wordset from "./wordset";
|
||||
|
||||
let failReason = "";
|
||||
const koInputVisual = document.getElementById("koInputVisual") as HTMLElement;
|
||||
|
@ -98,19 +98,19 @@ export async function punctuateWord(
|
|||
return funbox.functions.punctuateWord(word);
|
||||
}
|
||||
if (
|
||||
currentLanguage != "code" &&
|
||||
currentLanguage != "georgian" &&
|
||||
(index == 0 || shouldCapitalize(lastChar))
|
||||
currentLanguage !== "code" &&
|
||||
currentLanguage !== "georgian" &&
|
||||
(index === 0 || shouldCapitalize(lastChar))
|
||||
) {
|
||||
//always capitalise the first word or if there was a dot unless using a code alphabet or the Georgian language
|
||||
|
||||
word = Misc.capitalizeFirstLetterOfEachWord(word);
|
||||
|
||||
if (currentLanguage == "turkish") {
|
||||
if (currentLanguage === "turkish") {
|
||||
word = word.replace(/I/g, "İ");
|
||||
}
|
||||
|
||||
if (currentLanguage == "spanish" || currentLanguage == "catalan") {
|
||||
if (currentLanguage === "spanish" || currentLanguage === "catalan") {
|
||||
const rand = Math.random();
|
||||
if (rand > 0.9) {
|
||||
word = "¿" + word;
|
||||
|
@ -122,20 +122,20 @@ export async function punctuateWord(
|
|||
}
|
||||
} else if (
|
||||
(Math.random() < 0.1 &&
|
||||
lastChar != "." &&
|
||||
lastChar != "," &&
|
||||
index != maxindex - 2) ||
|
||||
index == maxindex - 1
|
||||
lastChar !== "." &&
|
||||
lastChar !== "," &&
|
||||
index !== maxindex - 2) ||
|
||||
index === maxindex - 1
|
||||
) {
|
||||
if (currentLanguage == "spanish" || currentLanguage == "catalan") {
|
||||
if (spanishSentenceTracker == "?" || spanishSentenceTracker == "!") {
|
||||
if (currentLanguage === "spanish" || currentLanguage === "catalan") {
|
||||
if (spanishSentenceTracker === "?" || spanishSentenceTracker === "!") {
|
||||
word += spanishSentenceTracker;
|
||||
spanishSentenceTracker = "";
|
||||
}
|
||||
} else {
|
||||
const rand = Math.random();
|
||||
if (rand <= 0.8) {
|
||||
if (currentLanguage == "kurdish") {
|
||||
if (currentLanguage === "kurdish") {
|
||||
word += ".";
|
||||
} else if (currentLanguage === "nepali") {
|
||||
word += "।";
|
||||
|
@ -143,22 +143,22 @@ export async function punctuateWord(
|
|||
word += ".";
|
||||
}
|
||||
} else if (rand > 0.8 && rand < 0.9) {
|
||||
if (currentLanguage == "french") {
|
||||
if (currentLanguage === "french") {
|
||||
word = "?";
|
||||
} else if (
|
||||
currentLanguage == "arabic" ||
|
||||
currentLanguage == "persian" ||
|
||||
currentLanguage == "urdu" ||
|
||||
currentLanguage == "kurdish"
|
||||
currentLanguage === "arabic" ||
|
||||
currentLanguage === "persian" ||
|
||||
currentLanguage === "urdu" ||
|
||||
currentLanguage === "kurdish"
|
||||
) {
|
||||
word += "؟";
|
||||
} else if (currentLanguage == "greek") {
|
||||
} else if (currentLanguage === "greek") {
|
||||
word += ";";
|
||||
} else {
|
||||
word += "?";
|
||||
}
|
||||
} else {
|
||||
if (currentLanguage == "french") {
|
||||
if (currentLanguage === "french") {
|
||||
word = "!";
|
||||
} else {
|
||||
word += "!";
|
||||
|
@ -167,21 +167,21 @@ export async function punctuateWord(
|
|||
}
|
||||
} else if (
|
||||
Math.random() < 0.01 &&
|
||||
lastChar != "," &&
|
||||
lastChar != "." &&
|
||||
lastChar !== "," &&
|
||||
lastChar !== "." &&
|
||||
currentLanguage !== "russian"
|
||||
) {
|
||||
word = `"${word}"`;
|
||||
} else if (
|
||||
Math.random() < 0.011 &&
|
||||
lastChar != "," &&
|
||||
lastChar != "." &&
|
||||
lastChar !== "," &&
|
||||
lastChar !== "." &&
|
||||
currentLanguage !== "russian" &&
|
||||
currentLanguage !== "ukrainian"
|
||||
) {
|
||||
word = `'${word}'`;
|
||||
} else if (Math.random() < 0.012 && lastChar != "," && lastChar != ".") {
|
||||
if (currentLanguage == "code") {
|
||||
} else if (Math.random() < 0.012 && lastChar !== "," && lastChar !== ".") {
|
||||
if (currentLanguage === "code") {
|
||||
const r = Math.random();
|
||||
if (r < 0.25) {
|
||||
word = `(${word})`;
|
||||
|
@ -197,55 +197,55 @@ export async function punctuateWord(
|
|||
}
|
||||
} else if (
|
||||
Math.random() < 0.013 &&
|
||||
lastChar != "," &&
|
||||
lastChar != "." &&
|
||||
lastChar != ";" &&
|
||||
lastChar != "؛" &&
|
||||
lastChar != ":"
|
||||
lastChar !== "," &&
|
||||
lastChar !== "." &&
|
||||
lastChar !== ";" &&
|
||||
lastChar !== "؛" &&
|
||||
lastChar !== ":"
|
||||
) {
|
||||
if (currentLanguage == "french") {
|
||||
if (currentLanguage === "french") {
|
||||
word = ":";
|
||||
} else if (currentLanguage == "greek") {
|
||||
} else if (currentLanguage === "greek") {
|
||||
word = "·";
|
||||
} else {
|
||||
word += ":";
|
||||
}
|
||||
} else if (
|
||||
Math.random() < 0.014 &&
|
||||
lastChar != "," &&
|
||||
lastChar != "." &&
|
||||
previousWord != "-"
|
||||
lastChar !== "," &&
|
||||
lastChar !== "." &&
|
||||
previousWord !== "-"
|
||||
) {
|
||||
word = "-";
|
||||
} else if (
|
||||
Math.random() < 0.015 &&
|
||||
lastChar != "," &&
|
||||
lastChar != "." &&
|
||||
lastChar != ";" &&
|
||||
lastChar != "؛" &&
|
||||
lastChar != ":"
|
||||
lastChar !== "," &&
|
||||
lastChar !== "." &&
|
||||
lastChar !== ";" &&
|
||||
lastChar !== "؛" &&
|
||||
lastChar !== ":"
|
||||
) {
|
||||
if (currentLanguage == "french") {
|
||||
if (currentLanguage === "french") {
|
||||
word = ";";
|
||||
} else if (currentLanguage == "greek") {
|
||||
} else if (currentLanguage === "greek") {
|
||||
word = "·";
|
||||
} else if (currentLanguage == "arabic" || currentLanguage == "kurdish") {
|
||||
} else if (currentLanguage === "arabic" || currentLanguage === "kurdish") {
|
||||
word += "؛";
|
||||
} else {
|
||||
word += ";";
|
||||
}
|
||||
} else if (Math.random() < 0.2 && lastChar != ",") {
|
||||
} else if (Math.random() < 0.2 && lastChar !== ",") {
|
||||
if (
|
||||
currentLanguage == "arabic" ||
|
||||
currentLanguage == "urdu" ||
|
||||
currentLanguage == "persian" ||
|
||||
currentLanguage == "kurdish"
|
||||
currentLanguage === "arabic" ||
|
||||
currentLanguage === "urdu" ||
|
||||
currentLanguage === "persian" ||
|
||||
currentLanguage === "kurdish"
|
||||
) {
|
||||
word += "،";
|
||||
} else {
|
||||
word += ",";
|
||||
}
|
||||
} else if (Math.random() < 0.25 && currentLanguage == "code") {
|
||||
} else if (Math.random() < 0.25 && currentLanguage === "code") {
|
||||
const specials = ["{", "}", "[", "]", "(", ")", ";", "=", "+", "%", "/"];
|
||||
const specialsC = [
|
||||
"{",
|
||||
|
@ -379,7 +379,7 @@ export function restart(options = {} as RestartOptions): void {
|
|||
event?.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (ActivePage.get() == "test" && !TestUI.resultVisible) {
|
||||
if (ActivePage.get() === "test" && !TestUI.resultVisible) {
|
||||
if (!ManualRestart.get()) {
|
||||
if (
|
||||
TestWords.hasTab &&
|
||||
|
@ -441,7 +441,7 @@ export function restart(options = {} as RestartOptions): void {
|
|||
}
|
||||
}
|
||||
|
||||
if (Config.mode == "zen") {
|
||||
if (Config.mode === "zen") {
|
||||
$("#words").empty();
|
||||
}
|
||||
|
||||
|
@ -501,7 +501,7 @@ export function restart(options = {} as RestartOptions): void {
|
|||
$("#restartTestButton").blur();
|
||||
MemoryFunboxTimer.reset();
|
||||
QuoteRatePopup.clearQuoteStats();
|
||||
if (ActivePage.get() == "test" && window.scrollY > 0) {
|
||||
if (ActivePage.get() === "test" && window.scrollY > 0) {
|
||||
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||
}
|
||||
$("#wordsInput").val(" ");
|
||||
|
@ -536,7 +536,7 @@ export function restart(options = {} as RestartOptions): void {
|
|||
},
|
||||
options.noAnim ? 0 : 125,
|
||||
async () => {
|
||||
if (ActivePage.get() == "test") {
|
||||
if (ActivePage.get() === "test") {
|
||||
AdController.updateTestPageAds(false);
|
||||
Focus.set(false);
|
||||
}
|
||||
|
@ -733,18 +733,18 @@ async function getNextWord(
|
|||
|
||||
let randomWord = wordset.randomWord(funboxFrequency);
|
||||
const previousWord = TestWords.words.get(TestWords.words.length - 1, true);
|
||||
const previousWord2 = TestWords.words.get(TestWords.words.length - 2, true);
|
||||
// const previousWord2 = TestWords.words.get(TestWords.words.length - 2, true);
|
||||
if (Config.mode === "quote") {
|
||||
randomWord =
|
||||
TestWords.randomQuote.textSplit?.[TestWords.words.length] ?? "";
|
||||
} else if (
|
||||
Config.mode == "custom" &&
|
||||
Config.mode === "custom" &&
|
||||
!CustomText.isWordRandom &&
|
||||
!CustomText.isTimeRandom
|
||||
) {
|
||||
randomWord = CustomText.text[TestWords.words.length];
|
||||
} else if (
|
||||
Config.mode == "custom" &&
|
||||
Config.mode === "custom" &&
|
||||
(CustomText.isWordRandom || CustomText.isTimeRandom) &&
|
||||
(wordset.length < 4 || PractiseWords.before.mode !== null)
|
||||
) {
|
||||
|
@ -753,11 +753,10 @@ async function getNextWord(
|
|||
let regenarationCount = 0; //infinite loop emergency stop button
|
||||
while (
|
||||
regenarationCount < 100 &&
|
||||
(previousWord == randomWord ||
|
||||
previousWord2 == randomWord ||
|
||||
(previousWord === randomWord ||
|
||||
(Config.mode !== "custom" &&
|
||||
!Config.punctuation &&
|
||||
randomWord == "I") ||
|
||||
randomWord === "I") ||
|
||||
(Config.mode !== "custom" &&
|
||||
!Config.punctuation &&
|
||||
!Config.language.startsWith("code") &&
|
||||
|
@ -833,7 +832,7 @@ export async function init(): Promise<void> {
|
|||
TestInput.input.resetHistory();
|
||||
TestInput.input.resetCurrent();
|
||||
|
||||
if (ActivePage.get() == "test") {
|
||||
if (ActivePage.get() === "test") {
|
||||
await Funbox.activate();
|
||||
}
|
||||
|
||||
|
@ -919,7 +918,7 @@ export async function init(): Promise<void> {
|
|||
} else {
|
||||
wordsBound = CustomText.text.length;
|
||||
}
|
||||
} else if (Config.mode != "time") {
|
||||
} else if (Config.mode !== "time") {
|
||||
wordsBound = Config.words;
|
||||
}
|
||||
} else {
|
||||
|
@ -927,17 +926,17 @@ export async function init(): Promise<void> {
|
|||
wordsBound = Config.words;
|
||||
}
|
||||
if (
|
||||
Config.mode == "custom" &&
|
||||
Config.mode === "custom" &&
|
||||
CustomText.isWordRandom &&
|
||||
CustomText.word < wordsBound
|
||||
) {
|
||||
wordsBound = CustomText.word;
|
||||
}
|
||||
if (Config.mode == "custom" && CustomText.isTimeRandom) {
|
||||
if (Config.mode === "custom" && CustomText.isTimeRandom) {
|
||||
wordsBound = 100;
|
||||
}
|
||||
if (
|
||||
Config.mode == "custom" &&
|
||||
Config.mode === "custom" &&
|
||||
!CustomText.isWordRandom &&
|
||||
!CustomText.isTimeRandom &&
|
||||
CustomText.text.length < wordsBound
|
||||
|
@ -949,10 +948,10 @@ export async function init(): Promise<void> {
|
|||
if (
|
||||
(Config.mode === "custom" &&
|
||||
CustomText.isWordRandom &&
|
||||
CustomText.word == 0) ||
|
||||
CustomText.word === 0) ||
|
||||
(Config.mode === "custom" &&
|
||||
CustomText.isTimeRandom &&
|
||||
CustomText.time == 0)
|
||||
CustomText.time === 0)
|
||||
) {
|
||||
wordsBound = 100;
|
||||
}
|
||||
|
@ -962,12 +961,12 @@ export async function init(): Promise<void> {
|
|||
}
|
||||
|
||||
if (
|
||||
Config.mode == "time" ||
|
||||
Config.mode == "words" ||
|
||||
Config.mode == "custom"
|
||||
Config.mode === "time" ||
|
||||
Config.mode === "words" ||
|
||||
Config.mode === "custom"
|
||||
) {
|
||||
let wordList = language.words;
|
||||
if (Config.mode == "custom") {
|
||||
if (Config.mode === "custom") {
|
||||
wordList = CustomText.text;
|
||||
}
|
||||
const wordset = await Wordset.withWords(wordList);
|
||||
|
@ -978,7 +977,7 @@ export async function init(): Promise<void> {
|
|||
);
|
||||
if (sectionFunbox?.functions?.pullSection) {
|
||||
while (
|
||||
(Config.mode == "words" && Config.words >= wordCount) ||
|
||||
(Config.mode === "words" && Config.words >= wordCount) ||
|
||||
(Config.mode === "time" && wordCount < 100)
|
||||
) {
|
||||
const section = await sectionFunbox.functions.pullSection(
|
||||
|
@ -998,7 +997,7 @@ export async function init(): Promise<void> {
|
|||
if (section === undefined) continue;
|
||||
|
||||
for (const word of section.words) {
|
||||
if (wordCount >= Config.words && Config.mode == "words") {
|
||||
if (wordCount >= Config.words && Config.mode === "words") {
|
||||
wordCount++;
|
||||
break;
|
||||
}
|
||||
|
@ -1008,7 +1007,7 @@ export async function init(): Promise<void> {
|
|||
}
|
||||
}
|
||||
|
||||
if (wordCount == 0) {
|
||||
if (wordCount === 0) {
|
||||
for (let i = 0; i < wordsBound; i++) {
|
||||
const randomWord = await getNextWord(wordset, language, wordsBound);
|
||||
|
||||
|
@ -1026,15 +1025,15 @@ export async function init(): Promise<void> {
|
|||
id++;
|
||||
|
||||
if (
|
||||
TestWords.words.length == wordsBound &&
|
||||
Config.mode == "custom" &&
|
||||
TestWords.words.length === wordsBound &&
|
||||
Config.mode === "custom" &&
|
||||
CustomText.isWordRandom
|
||||
) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (
|
||||
Config.mode == "custom" &&
|
||||
Config.mode === "custom" &&
|
||||
!CustomText.isWordRandom &&
|
||||
!CustomText.isTimeRandom
|
||||
) {
|
||||
|
@ -1160,7 +1159,7 @@ export async function init(): Promise<void> {
|
|||
$("#resultWordsHistory .words").removeClass("withLigatures");
|
||||
$("#resultReplay .words").removeClass("withLigatures");
|
||||
}
|
||||
// if (Config.mode == "zen") {
|
||||
// if (Config.mode === "zen") {
|
||||
// // Creating an empty active word element for zen mode
|
||||
// $("#words").append('<div class="word active"></div>');
|
||||
// $("#words").css("height", "auto");
|
||||
|
@ -1197,7 +1196,7 @@ export async function addWord(): Promise<void> {
|
|||
(Config.mode === "custom" &&
|
||||
CustomText.isWordRandom &&
|
||||
TestWords.words.length >= CustomText.word &&
|
||||
CustomText.word != 0) ||
|
||||
CustomText.word !== 0) ||
|
||||
(Config.mode === "custom" &&
|
||||
!CustomText.isWordRandom &&
|
||||
!CustomText.isTimeRandom &&
|
||||
|
@ -1231,7 +1230,7 @@ export async function addWord(): Promise<void> {
|
|||
|
||||
let wordCount = 0;
|
||||
for (const word of section.words) {
|
||||
if (wordCount >= Config.words && Config.mode == "words") {
|
||||
if (wordCount >= Config.words && Config.mode === "words") {
|
||||
break;
|
||||
}
|
||||
wordCount++;
|
||||
|
@ -1357,7 +1356,7 @@ function buildCompletedEvent(difficultyFailed: boolean): CompletedEvent {
|
|||
|
||||
// stats
|
||||
const stats = TestStats.calculateStats();
|
||||
if (stats.time % 1 != 0 && Config.mode !== "time") {
|
||||
if (stats.time % 1 !== 0 && Config.mode !== "time") {
|
||||
TestStats.setLastSecondNotRound();
|
||||
}
|
||||
TestStats.setLastTestWpm(stats.wpm);
|
||||
|
@ -1475,14 +1474,14 @@ function buildCompletedEvent(difficultyFailed: boolean): CompletedEvent {
|
|||
} catch (e) {}
|
||||
completedEvent.tags = activeTagsIds;
|
||||
|
||||
if (completedEvent.mode != "custom") delete completedEvent.customText;
|
||||
if (completedEvent.mode !== "custom") delete completedEvent.customText;
|
||||
|
||||
return <CompletedEvent>completedEvent;
|
||||
}
|
||||
|
||||
export async function finish(difficultyFailed = false): Promise<void> {
|
||||
if (!TestState.isActive) return;
|
||||
if (TestInput.input.current.length != 0) {
|
||||
if (TestInput.input.current.length !== 0) {
|
||||
TestInput.input.pushHistory();
|
||||
TestInput.corrected.pushHistory();
|
||||
Replay.replayGetWordsList(TestInput.input.history);
|
||||
|
@ -1515,7 +1514,7 @@ export async function finish(difficultyFailed = false): Promise<void> {
|
|||
}
|
||||
|
||||
//remove afk from zen
|
||||
if (Config.mode == "zen" || TestInput.bailout) {
|
||||
if (Config.mode === "zen" || TestInput.bailout) {
|
||||
TestStats.removeAfkData();
|
||||
}
|
||||
|
||||
|
@ -1570,13 +1569,13 @@ export async function finish(difficultyFailed = false): Promise<void> {
|
|||
completedEvent.mode2 < 15 &&
|
||||
completedEvent.mode2 > 0) ||
|
||||
(Config.mode === "time" &&
|
||||
completedEvent.mode2 == 0 &&
|
||||
completedEvent.mode2 === "0" &&
|
||||
completedEvent.testDuration < 15) ||
|
||||
(Config.mode === "words" &&
|
||||
completedEvent.mode2 < 10 &&
|
||||
completedEvent.mode2 > 0) ||
|
||||
(Config.mode === "words" &&
|
||||
completedEvent.mode2 == 0 &&
|
||||
completedEvent.mode2 === "0" &&
|
||||
completedEvent.testDuration < 15) ||
|
||||
(Config.mode === "custom" &&
|
||||
!CustomText.isWordRandom &&
|
||||
|
@ -1598,11 +1597,11 @@ export async function finish(difficultyFailed = false): Promise<void> {
|
|||
} else if (
|
||||
completedEvent.wpm < 0 ||
|
||||
(completedEvent.wpm > 350 &&
|
||||
completedEvent.mode != "words" &&
|
||||
completedEvent.mode2 != "10") ||
|
||||
completedEvent.mode !== "words" &&
|
||||
completedEvent.mode2 !== "10") ||
|
||||
(completedEvent.wpm > 420 &&
|
||||
completedEvent.mode == "words" &&
|
||||
completedEvent.mode2 == "10")
|
||||
completedEvent.mode === "words" &&
|
||||
completedEvent.mode2 === "10")
|
||||
) {
|
||||
Notifications.add("Test invalid - wpm", 0);
|
||||
TestStats.setInvalid();
|
||||
|
@ -1610,11 +1609,12 @@ export async function finish(difficultyFailed = false): Promise<void> {
|
|||
} else if (
|
||||
completedEvent.rawWpm < 0 ||
|
||||
(completedEvent.rawWpm > 350 &&
|
||||
completedEvent.mode != "words" &&
|
||||
completedEvent.mode2 != "10") ||
|
||||
completedEvent.mode !== "words" &&
|
||||
completedEvent.mode2 !== "10" &&
|
||||
completedEvent.mode2 !== 10) ||
|
||||
(completedEvent.rawWpm > 420 &&
|
||||
completedEvent.mode == "words" &&
|
||||
completedEvent.mode2 == "10")
|
||||
completedEvent.mode === "words" &&
|
||||
completedEvent.mode2 === "10")
|
||||
) {
|
||||
Notifications.add("Test invalid - raw", 0);
|
||||
TestStats.setInvalid();
|
||||
|
@ -1924,7 +1924,7 @@ $(".pageTest").on("click", "#nextTestButton", () => {
|
|||
});
|
||||
|
||||
$(".pageTest").on("click", "#restartTestButtonWithSameWordset", () => {
|
||||
if (Config.mode == "zen") {
|
||||
if (Config.mode === "zen") {
|
||||
Notifications.add("Repeat test disabled in zen mode");
|
||||
return;
|
||||
}
|
||||
|
@ -1935,7 +1935,7 @@ $(".pageTest").on("click", "#restartTestButtonWithSameWordset", () => {
|
|||
});
|
||||
|
||||
$(document).on("keypress", "#restartTestButtonWithSameWordset", (event) => {
|
||||
if (Config.mode == "zen") {
|
||||
if (Config.mode === "zen") {
|
||||
Notifications.add("Repeat test disabled in zen mode");
|
||||
return;
|
||||
}
|
||||
|
@ -1959,7 +1959,7 @@ $(".pageTest").on("click", "#testConfig .mode .textButton", (e) => {
|
|||
$(".pageTest").on("click", "#testConfig .wordCount .textButton", (e) => {
|
||||
if (TestUI.testRestarting) return;
|
||||
const wrd = $(e.currentTarget).attr("wordCount") ?? "15";
|
||||
if (wrd != "custom") {
|
||||
if (wrd !== "custom") {
|
||||
UpdateConfig.setWordCount(parseInt(wrd));
|
||||
ManualRestart.set();
|
||||
restart();
|
||||
|
@ -1969,7 +1969,7 @@ $(".pageTest").on("click", "#testConfig .wordCount .textButton", (e) => {
|
|||
$(".pageTest").on("click", "#testConfig .time .textButton", (e) => {
|
||||
if (TestUI.testRestarting) return;
|
||||
const mode = $(e.currentTarget).attr("timeConfig") ?? "10";
|
||||
if (mode != "custom") {
|
||||
if (mode !== "custom") {
|
||||
UpdateConfig.setTimeConfig(parseInt(mode));
|
||||
ManualRestart.set();
|
||||
restart();
|
||||
|
@ -1981,8 +1981,8 @@ $(".pageTest").on("click", "#testConfig .quoteLength .textButton", (e) => {
|
|||
let len: MonkeyTypes.QuoteLength | MonkeyTypes.QuoteLength[] = <
|
||||
MonkeyTypes.QuoteLength
|
||||
>parseInt($(e.currentTarget).attr("quoteLength") ?? "1");
|
||||
if (len != -2) {
|
||||
if (len == -1) {
|
||||
if (len !== -2) {
|
||||
if (len === -1) {
|
||||
len = [0, 1, 2, 3];
|
||||
}
|
||||
UpdateConfig.setQuoteLength(len, false, e.shiftKey);
|
||||
|
|
Loading…
Reference in a new issue