mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-22 16:26:18 +08:00
Merge branch 'master' of https://github.com/Miodec/monkey-type
This commit is contained in:
commit
e3a2dc09b8
3645
functions/package-lock.json
generated
3645
functions/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -115,6 +115,7 @@ const refactoredSrc = [
|
|||
"./src/js/test/keymap.js",
|
||||
"./src/js/test/live-wpm.js",
|
||||
"./src/js/test/caps-warning.js",
|
||||
"./src/js/test/live-acc.js"
|
||||
];
|
||||
|
||||
//legacy files
|
||||
|
|
10518
package-lock.json
generated
10518
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -129,7 +129,7 @@ let commands = {
|
|||
id: "toggleShowLiveAcc",
|
||||
display: "Toggle live accuracy display",
|
||||
exec: () => {
|
||||
toggleShowLiveAcc();
|
||||
LiveAcc.show();
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -44,3 +44,4 @@ import * as TestUI from "./test-ui";
|
|||
import * as Keymap from "./keymap";
|
||||
import * as LiveWpm from "./live-wpm";
|
||||
import * as CapsWarning from "./caps-warning";
|
||||
import * as LiveAcc from './live-acc';
|
|
@ -1262,7 +1262,7 @@ function showResult(difficultyFailed = false) {
|
|||
Caret.hide();
|
||||
LiveWpm.hide();
|
||||
hideCrown();
|
||||
hideLiveAcc();
|
||||
LiveAcc.hide();
|
||||
hideTimer();
|
||||
Keymap.hide();
|
||||
let stats = calculateStats();
|
||||
|
@ -2252,7 +2252,7 @@ function startTest() {
|
|||
showTimer();
|
||||
$("#liveWpm").text("0");
|
||||
LiveWpm.show();
|
||||
showLiveAcc();
|
||||
LiveAcc.show();
|
||||
updateTimer();
|
||||
clearTimeout(timer);
|
||||
|
||||
|
@ -2462,7 +2462,7 @@ function restartTest(withSameWordset = false, nosave = false, event) {
|
|||
Caret.hide();
|
||||
testActive = false;
|
||||
LiveWpm.hide();
|
||||
hideLiveAcc();
|
||||
LiveAcc.hide();
|
||||
hideTimer();
|
||||
bailout = false;
|
||||
paceCaret = null;
|
||||
|
@ -2807,70 +2807,6 @@ function liveWpmAndRaw() {
|
|||
};
|
||||
}
|
||||
|
||||
function updateLiveAcc(acc) {
|
||||
if (!testActive || !Config.showLiveAcc) {
|
||||
hideLiveAcc();
|
||||
} else {
|
||||
showLiveAcc();
|
||||
}
|
||||
let number = Math.floor(acc);
|
||||
if (Config.blindMode) {
|
||||
number = 100;
|
||||
}
|
||||
document.querySelector("#miniTimerAndLiveWpm .acc").innerHTML = number + "%";
|
||||
document.querySelector("#liveAcc").innerHTML = number + "%";
|
||||
}
|
||||
|
||||
function showLiveAcc() {
|
||||
if (!Config.showLiveAcc) return;
|
||||
if (!testActive) return;
|
||||
if (Config.timerStyle === "mini") {
|
||||
// $("#miniTimerAndLiveWpm .wpm").css("opacity", Config.timerOpacity);
|
||||
if (!$("#miniTimerAndLiveWpm .acc").hasClass("hidden")) return;
|
||||
$("#miniTimerAndLiveWpm .acc")
|
||||
.removeClass("hidden")
|
||||
.css("opacity", 0)
|
||||
.animate(
|
||||
{
|
||||
opacity: Config.timerOpacity,
|
||||
},
|
||||
125
|
||||
);
|
||||
} else {
|
||||
// $("#liveWpm").css("opacity", Config.timerOpacity);
|
||||
if (!$("#liveAcc").hasClass("hidden")) return;
|
||||
$("#liveAcc").removeClass("hidden").css("opacity", 0).animate(
|
||||
{
|
||||
opacity: Config.timerOpacity,
|
||||
},
|
||||
125
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function hideLiveAcc() {
|
||||
// $("#liveWpm").css("opacity", 0);
|
||||
// $("#miniTimerAndLiveWpm .wpm").css("opacity", 0);
|
||||
$("#liveAcc").animate(
|
||||
{
|
||||
opacity: Config.timerOpacity,
|
||||
},
|
||||
125,
|
||||
() => {
|
||||
$("#liveAcc").addClass("hidden");
|
||||
}
|
||||
);
|
||||
$("#miniTimerAndLiveWpm .acc").animate(
|
||||
{
|
||||
opacity: Config.timerOpacity,
|
||||
},
|
||||
125,
|
||||
() => {
|
||||
$("#miniTimerAndLiveWpm .acc").addClass("hidden");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function toggleResultWordsDisplay() {
|
||||
if (TestUI.resultVisible) {
|
||||
if ($("#resultWordsHistory").stop(true, true).hasClass("hidden")) {
|
||||
|
@ -4015,7 +3951,7 @@ $(document).keydown(function (event) {
|
|||
}
|
||||
|
||||
let acc = Misc.roundTo2(TestStats.calculateAccuracy());
|
||||
updateLiveAcc(acc);
|
||||
LiveAcc.update(acc);
|
||||
});
|
||||
|
||||
function handleTab(event) {
|
||||
|
|
61
src/js/test/live-acc.js
Normal file
61
src/js/test/live-acc.js
Normal file
|
@ -0,0 +1,61 @@
|
|||
import Config from './config';
|
||||
|
||||
export function update(acc) {
|
||||
let number = Math.floor(acc);
|
||||
if (Config.blindMode) {
|
||||
number = 100;
|
||||
}
|
||||
document.querySelector("#miniTimerAndLiveWpm .acc").innerHTML = number + "%";
|
||||
document.querySelector("#liveAcc").innerHTML = number + "%";
|
||||
}
|
||||
|
||||
|
||||
export function show() {
|
||||
if (!Config.showLiveAcc) return;
|
||||
// if (!testActive) return;
|
||||
if (Config.timerStyle === "mini") {
|
||||
// $("#miniTimerAndLiveWpm .wpm").css("opacity", Config.timerOpacity);
|
||||
if (!$("#miniTimerAndLiveWpm .acc").hasClass("hidden")) return;
|
||||
$("#miniTimerAndLiveWpm .acc")
|
||||
.removeClass("hidden")
|
||||
.css("opacity", 0)
|
||||
.animate(
|
||||
{
|
||||
opacity: Config.timerOpacity,
|
||||
},
|
||||
125
|
||||
);
|
||||
} else {
|
||||
// $("#liveWpm").css("opacity", Config.timerOpacity);
|
||||
if (!$("#liveAcc").hasClass("hidden")) return;
|
||||
$("#liveAcc").removeClass("hidden").css("opacity", 0).animate(
|
||||
{
|
||||
opacity: Config.timerOpacity,
|
||||
},
|
||||
125
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function hide() {
|
||||
// $("#liveWpm").css("opacity", 0);
|
||||
// $("#miniTimerAndLiveWpm .wpm").css("opacity", 0);
|
||||
$("#liveAcc").animate(
|
||||
{
|
||||
opacity: Config.timerOpacity,
|
||||
},
|
||||
125,
|
||||
() => {
|
||||
$("#liveAcc").addClass("hidden");
|
||||
}
|
||||
);
|
||||
$("#miniTimerAndLiveWpm .acc").animate(
|
||||
{
|
||||
opacity: Config.timerOpacity,
|
||||
},
|
||||
125,
|
||||
() => {
|
||||
$("#miniTimerAndLiveWpm .acc").addClass("hidden");
|
||||
}
|
||||
);
|
||||
}
|
|
@ -609,11 +609,21 @@ function setShowLiveAcc(live, nosave) {
|
|||
live = false;
|
||||
}
|
||||
ConfigSet.showLiveAcc(live);
|
||||
if (live) {
|
||||
LiveAcc.show();
|
||||
} else {
|
||||
LiveAcc.hide();
|
||||
}
|
||||
if (!nosave) saveConfigToCookie();
|
||||
}
|
||||
|
||||
function toggleShowLiveAcc() {
|
||||
function toggleLiveAcc() {
|
||||
ConfigSet.showLiveAcc(!Config.showLiveAcc);
|
||||
if (Config.showLiveAcc) {
|
||||
LiveAcc.show();
|
||||
} else {
|
||||
LiveAcc.hide();
|
||||
}
|
||||
saveConfigToCookie();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue