mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-03 20:40:48 +08:00
added stop on error
This commit is contained in:
parent
0f8f8a7253
commit
ec09868699
5 changed files with 53 additions and 2 deletions
|
@ -781,6 +781,15 @@
|
|||
<div class="button off" tabindex="0" onclick="this.blur();">off</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section stopOnError">
|
||||
<h1>stop on error</h1>
|
||||
<div class="text">When enabled, incorrect input will not be registered and words need to be 100% correct to be
|
||||
able to move on to the next.</div>
|
||||
<div class="buttons">
|
||||
<div class="button on" tabindex="0" onclick="this.blur();">on</div>
|
||||
<div class="button off" tabindex="0" onclick="this.blur();">off</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section blindMode">
|
||||
<h1>blind mode</h1>
|
||||
<div class="text">No errors or incorrect words are highlighted. Helps you to focus on raw speed. If enabled,
|
||||
|
|
|
@ -109,6 +109,13 @@ let commands = {
|
|||
toggleBlindMode();
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "toggleStopOnError",
|
||||
display: "Toggle stop on error",
|
||||
exec: () => {
|
||||
toggleStopOnError();
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "toggleQuickEnd",
|
||||
display: "Toggle quick end",
|
||||
|
|
|
@ -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 = "";
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue