diff --git a/src/js/commandline.js b/src/js/commandline.js index 1ccf3b3f6..55e03e686 100644 --- a/src/js/commandline.js +++ b/src/js/commandline.js @@ -270,6 +270,15 @@ let commands = { showCommandLine(); }, }, + { + id: "changePaceCaret", + display: "Change min accuracy mode...", + subgroup: true, + exec: () => { + currentCommands.push(commandsMinAcc); + showCommandLine(); + }, + }, { id: "togglePlaySoundOnError", display: "Toggle play sound on error", @@ -1010,6 +1019,28 @@ let commandsMinWpm = { ], }; +let commandsMinAcc = { + title: "Change min accuracy mode...", + list: [ + { + id: "setMinAccOff", + display: "off", + exec: () => { + setMinAcc("off"); + }, + }, + { + id: "setMinAccCustom", + display: "custom...", + input: true, + exec: (input) => { + setMinAccCustom(input); + setMinAcc("custom"); + }, + }, + ], +}; + let commandsKeymapStyle = { title: "Change keymap style...", list: [ diff --git a/src/js/script.js b/src/js/script.js index 984571b2d..148d5213d 100644 --- a/src/js/script.js +++ b/src/js/script.js @@ -2635,10 +2635,18 @@ function startTest() { count: 0, words: [], }; + console.time(); + let acc = Misc.roundTo2( + (accuracyStats.correct / + (accuracyStats.correct + accuracyStats.incorrect)) * + 100 + ); + console.timeEnd(); if ( - config.minWpm === "custom" && - wpmAndRaw.wpm < parseInt(config.minWpmCustomSpeed) && - currentWordIndex > 3 + (config.minWpm === "custom" && + wpmAndRaw.wpm < parseInt(config.minWpmCustomSpeed) && + currentWordIndex > 3) || + (config.minAcc === "custom" && acc < parseInt(config.minAccCustom)) ) { clearTimeout(timer); hideCaret(); @@ -3406,6 +3414,12 @@ function updateTestModesNotice() { ); } + if (config.minAcc !== "off") { + $(".pageTest #testModesNotice").append( + `
min ${config.minAccCustom}% acc
` + ); + } + if (activeFunBox !== "none") { $(".pageTest #testModesNotice").append( `
${activeFunBox.replace( @@ -4885,11 +4899,15 @@ $(document).on("mouseenter", "#resultWordsHistory .words .word", (e) => { }); $(document).on("click", "#bottom .leftright .right .current-theme", (e) => { - if (config.customTheme) { + if (e.shiftKey) { togglePresetCustomTheme(); + } else { + if (config.customTheme) { + togglePresetCustomTheme(); + } + currentCommands.push(commandsThemes); + showCommandLine(); } - currentCommands.push(commandsThemes); - showCommandLine(); }); $(document).on("click", ".keymap .r5 #KeySpace", (e) => { diff --git a/src/js/settings.js b/src/js/settings.js index 094386d13..bfd88b26c 100644 --- a/src/js/settings.js +++ b/src/js/settings.js @@ -218,6 +218,13 @@ settingsGroups.minWpm = new SettingsGroup("minWpm", setMinWpm, () => { ); } }); +settingsGroups.minAcc = new SettingsGroup("minAcc", setMinAcc, () => { + if (config.minAcc === "custom") { + $(".pageSettings .section.minAcc input.customMinAcc").removeClass("hidden"); + } else { + $(".pageSettings .section.minAcc input.customMinAcc").addClass("hidden"); + } +}); settingsGroups.smoothLineScroll = new SettingsGroup( "smoothLineScroll", setSmoothLineScroll @@ -425,6 +432,15 @@ function updateSettingsPage() { "hidden" ); } + + if (config.minAcc === "custom") { + $(".pageSettings .section.minAcc input.customMinAcc").removeClass("hidden"); + $(".pageSettings .section.minAcc input.customMinAcc").val( + config.minAccCustom + ); + } else { + $(".pageSettings .section.minAcc input.customMinAcc").addClass("hidden"); + } } function showCustomThemeShare() { @@ -693,6 +709,16 @@ $(document).on( } ); +$(document).on( + "focusout", + ".pageSettings .section.minAcc input.customMinAcc", + (e) => { + setMinAccCustom( + parseInt($(".pageSettings .section.minAcc input.customMinAcc").val()) + ); + } +); + $(document).on("click", ".pageSettings .section.themes .theme.button", (e) => { let theme = $(e.currentTarget).attr("theme"); if (!$(e.target).hasClass("favButton")) { diff --git a/src/js/userconfig.js b/src/js/userconfig.js index 972d9b34e..409155182 100644 --- a/src/js/userconfig.js +++ b/src/js/userconfig.js @@ -71,6 +71,8 @@ let defaultConfig = { enableAds: "off", hideExtraLetters: false, strictSpace: false, + minAcc: "off", + minAccCustom: 90, }; let cookieConfig = null; @@ -223,6 +225,8 @@ function applyConfig(configObj) { setChartStyle(configObj.chartStyle, true); setMinWpm(configObj.minWpm, true); setMinWpmCustomSpeed(configObj.minWpmCustomSpeed, true); + setMinAcc(configObj.minAcc, true); + setMinAccCustom(configObj.minAccCustom, true); setNumbers(configObj.numbers, true); setPunctuation(configObj.punctuation, true); setHighlightMode(configObj.highlightMode, true); @@ -556,6 +560,24 @@ function setMinWpmCustomSpeed(val, nosave) { if (!nosave) saveConfigToCookie(); } +//min acc +function setMinAcc(min, nosave) { + if (min == undefined) { + min = "off"; + } + config.minAcc = min; + updateTestModesNotice(); + if (!nosave) saveConfigToCookie(); +} + +function setMinAccCustom(val, nosave) { + if (val == undefined || Number.isNaN(parseInt(val))) { + val = 90; + } + config.minAccCustom = val; + if (!nosave) saveConfigToCookie(); +} + //always show words history function setAlwaysShowWordsHistory(val, nosave) { if (val == undefined) { diff --git a/static/index.html b/static/index.html index 285bf37ea..6bc120b32 100644 --- a/static/index.html +++ b/static/index.html @@ -1752,6 +1752,39 @@ />
+
+

min accuracy

+
+ Automatically fails a test if your accuracy falls below a + threshold. +
+
+
+ off +
+
+ custom +
+ +
+

language

@@ -3440,7 +3473,13 @@
- current theme + + current theme +