mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-04 20:47:54 +08:00
Prevented timer and other progress displays from breaking during zen mode
This commit is contained in:
parent
7de3cfd24a
commit
d41f9b222c
2 changed files with 18 additions and 15 deletions
|
@ -620,10 +620,6 @@ let commands = {
|
|||
display: "Yes, I am sure",
|
||||
exec: () => {
|
||||
bailout = true;
|
||||
if (config.mode == "zen" && currentInput.length != 0) {
|
||||
inputHistory.push(currentInput);
|
||||
correctedHistory.push(currentCorrected);
|
||||
}
|
||||
showResult();
|
||||
},
|
||||
available: () => {
|
||||
|
|
|
@ -1233,7 +1233,7 @@ function highlightBadWord(index, showError) {
|
|||
|
||||
function showTimer() {
|
||||
let op = config.showTimerProgress ? config.timerOpacity : 0;
|
||||
if (config.timerStyle === "bar") {
|
||||
if (config.mode != "zen" && config.timerStyle === "bar") {
|
||||
$("#timerWrapper").stop(true, true).removeClass("hidden").animate(
|
||||
{
|
||||
opacity: op,
|
||||
|
@ -1251,7 +1251,7 @@ function showTimer() {
|
|||
},
|
||||
125
|
||||
);
|
||||
} else if (config.timerStyle === "mini") {
|
||||
} else if (config.mode == "zen" || config.timerStyle === "mini") {
|
||||
if (op > 0) {
|
||||
$("#miniTimerAndLiveWpm .time")
|
||||
.stop(true, true)
|
||||
|
@ -1409,6 +1409,12 @@ function updateTimer() {
|
|||
$("#miniTimerAndLiveWpm .time").html(`${inputHistory.length}/${outof}`);
|
||||
}
|
||||
}
|
||||
} else if (config.mode == "zen") {
|
||||
if (config.timerStyle === "text") {
|
||||
$("#timerNumber").html("<div>" + `${inputHistory.length}` + "</div>");
|
||||
} else {
|
||||
$("#miniTimerAndLiveWpm .time").html(`${inputHistory.length}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1797,7 +1803,6 @@ function calculateStats() {
|
|||
(accuracyStats.correct + accuracyStats.incorrect)) *
|
||||
100
|
||||
);
|
||||
console.log(acc);
|
||||
return {
|
||||
wpm: isNaN(wpm) ? 0 : wpm,
|
||||
wpmRaw: isNaN(wpmraw) ? 0 : wpmraw,
|
||||
|
@ -1849,6 +1854,11 @@ function failTest() {
|
|||
|
||||
let resultCalculating = false;
|
||||
function showResult(difficultyFailed = false) {
|
||||
if (config.mode == "zen" && currentInput.length != 0) {
|
||||
inputHistory.push(currentInput);
|
||||
correctedHistory.push(currentCorrected);
|
||||
}
|
||||
|
||||
resultCalculating = true;
|
||||
resultVisible = true;
|
||||
testEnd = performance.now();
|
||||
|
@ -3257,11 +3267,6 @@ function setMode(mode, nosave) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (config.mode === "zen" && mode !== "zen") {
|
||||
console.log("Toggling timer");
|
||||
toggleShowTimerProgress();
|
||||
}
|
||||
|
||||
config.mode = mode;
|
||||
$("#top .config .mode .text-button").removeClass("active");
|
||||
$("#top .config .mode .text-button[mode='" + mode + "']").addClass("active");
|
||||
|
@ -3312,8 +3317,6 @@ function setMode(mode, nosave) {
|
|||
$("#top .config .punctuationMode").addClass("hidden");
|
||||
$("#top .config .numbersMode").addClass("hidden");
|
||||
$("#top .config .quoteLength").addClass("hidden");
|
||||
hideLiveWpm();
|
||||
config.showTimerProgress = false;
|
||||
}
|
||||
if (!nosave) saveConfigToCookie();
|
||||
}
|
||||
|
@ -5330,7 +5333,8 @@ function handleSpace(event, isEnter) {
|
|||
if (
|
||||
config.mode === "words" ||
|
||||
config.mode === "custom" ||
|
||||
config.mode === "quote"
|
||||
config.mode === "quote" ||
|
||||
config.mode === "zen"
|
||||
) {
|
||||
updateTimer();
|
||||
}
|
||||
|
@ -5407,6 +5411,9 @@ function handleAlpha(event) {
|
|||
}
|
||||
|
||||
if (event.key === "Enter") {
|
||||
if (event.shiftKey && config.mode == "zen") {
|
||||
showResult();
|
||||
}
|
||||
event.key = "\n";
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue