diff --git a/public/index.html b/public/index.html
index 9d8fa1ad3..2803b308a 100644
--- a/public/index.html
+++ b/public/index.html
@@ -781,6 +781,15 @@
blind mode
No errors or incorrect words are highlighted. Helps you to focus on raw speed. If enabled,
diff --git a/public/js/commandline.js b/public/js/commandline.js
index 3a69458e7..fb8d848e7 100644
--- a/public/js/commandline.js
+++ b/public/js/commandline.js
@@ -109,6 +109,13 @@ let commands = {
toggleBlindMode();
},
},
+ {
+ id: "toggleStopOnError",
+ display: "Toggle stop on error",
+ exec: () => {
+ toggleStopOnError();
+ },
+ },
{
id: "toggleQuickEnd",
display: "Toggle quick end",
diff --git a/public/js/script.js b/public/js/script.js
index 2bb2fb5a6..1f4121891 100644
--- a/public/js/script.js
+++ b/public/js/script.js
@@ -1814,7 +1814,6 @@ function showLiveWpm() {
}
function hideLiveWpm() {
- console.log("hiding");
$("#liveWpm").css("opacity", 0);
}
@@ -2457,6 +2456,7 @@ $(document).keypress(function (event) {
} else {
if (!testActive) return;
}
+ let thisCharCorrect;
if (
wordsList[currentWordIndex].substring(
currentInput.length,
@@ -2465,10 +2465,15 @@ $(document).keypress(function (event) {
) {
accuracyStats.incorrect++;
currentErrorCount++;
+ thisCharCorrect = false;
} else {
accuracyStats.correct++;
+ thisCharCorrect = true;
}
currentKeypressCount++;
+
+ if (config.stopOnError && !thisCharCorrect) return;
+
currentInput += event["key"];
setFocus(true);
activeWordTopBeforeJump = activeWordTop;
@@ -2622,7 +2627,7 @@ $(document).keydown((event) => {
updateActiveElement();
updateCaretPosition();
currentKeypressCount++;
- } else {
+ } else if (!config.stopOnError) {
inputHistory.push(currentInput);
highlightBadWord(currentWordIndex, !config.blindMode);
currentInput = "";
diff --git a/public/js/settings.js b/public/js/settings.js
index 983ff17aa..1ace49548 100644
--- a/public/js/settings.js
+++ b/public/js/settings.js
@@ -49,6 +49,7 @@ function updateSettingsPage() {
setSettingsButton("colorfulMode", config.colorfulMode);
setSettingsButton("maxConfidence", config.maxConfidence);
setSettingsButton("randomTheme", config.randomTheme);
+ setSettingsButton("stopOnError", config.stopOnError);
setActiveThemeButton();
setActiveLanguageButton();
@@ -652,6 +653,16 @@ $(".pageSettings .section.randomTheme .buttons .button.off").click((e) => {
setSettingsButton("randomTheme", config.randomTheme);
});
+//stop on error
+$(".pageSettings .section.stopOnError .buttons .button.on").click((e) => {
+ setStopOnError(true);
+ setSettingsButton("stopOnError", config.stopOnError);
+});
+$(".pageSettings .section.stopOnError .buttons .button.off").click((e) => {
+ setStopOnError(false);
+ setSettingsButton("stopOnError", config.stopOnError);
+});
+
//discord
$(
".pageSettings .section.discordIntegration .buttons .generateCodeButton"
diff --git a/public/js/userconfig.js b/public/js/userconfig.js
index b47e63b8b..0695a2931 100644
--- a/public/js/userconfig.js
+++ b/public/js/userconfig.js
@@ -38,6 +38,7 @@ let defaultConfig = {
randomTheme: false,
timerColor: "black",
timerOpacity: "0.25",
+ stopOnError: false,
};
let cookieConfig = null;
@@ -230,6 +231,24 @@ function setBlindMode(blind, nosave) {
if (!nosave) saveConfigToCookie();
}
+//stoponerror
+function toggleStopOnError() {
+ soe = !config.stopOnError;
+ if (soe == undefined) {
+ soe = false;
+ }
+ config.stopOnError = soe;
+ saveConfigToCookie();
+}
+
+function setStopOnError(soe, nosave) {
+ if (soe == undefined) {
+ soe = false;
+ }
+ config.stopOnError = soe;
+ if (!nosave) saveConfigToCookie();
+}
+
//quickend
function toggleQuickEnd() {
qe = !config.quickEnd;