mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-09-13 01:57:38 +08:00
added min accuracy
This commit is contained in:
parent
4bb4341343
commit
0a42dee46a
5 changed files with 143 additions and 7 deletions
|
@ -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: [
|
||||
|
|
|
@ -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(
|
||||
`<div class="text-button" commands="commandsMinAcc"><i class="fas fa-bomb"></i>min ${config.minAccCustom}% acc</div>`
|
||||
);
|
||||
}
|
||||
|
||||
if (activeFunBox !== "none") {
|
||||
$(".pageTest #testModesNotice").append(
|
||||
`<div class="text-button" commands="commandsFunbox"><i class="fas fa-gamepad"></i>${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) => {
|
||||
|
|
|
@ -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")) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -1752,6 +1752,39 @@
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section minAcc" section="">
|
||||
<h1>min accuracy</h1>
|
||||
<div class="text">
|
||||
Automatically fails a test if your accuracy falls below a
|
||||
threshold.
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<div
|
||||
class="button"
|
||||
minAcc="off"
|
||||
tabindex="0"
|
||||
onclick="this.blur();"
|
||||
>
|
||||
off
|
||||
</div>
|
||||
<div
|
||||
class="button"
|
||||
minAcc="custom"
|
||||
tabindex="0"
|
||||
onclick="this.blur();"
|
||||
>
|
||||
custom
|
||||
</div>
|
||||
<input
|
||||
type="number"
|
||||
step="1"
|
||||
class="customMinAcc"
|
||||
placeholder="wpm"
|
||||
min="0"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section language">
|
||||
<h1>language</h1>
|
||||
<div class="buttons"></div>
|
||||
|
@ -3440,7 +3473,13 @@
|
|||
<div class="right">
|
||||
<div>
|
||||
<i class="fas fa-palette"></i>
|
||||
<span class="current-theme">current theme</span>
|
||||
<span
|
||||
class="current-theme"
|
||||
aria-label="Shift-click to toggle custom theme"
|
||||
data-balloon-pos="up"
|
||||
>
|
||||
current theme
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<i class="fas fa-code-branch"></i>
|
||||
|
|
Loading…
Add table
Reference in a new issue