Added repeat mode to settings

This commit is contained in:
Estebene 2021-05-17 16:12:43 +12:00
parent 4938e3b930
commit 774f26bf09
5 changed files with 46 additions and 10 deletions

View file

@ -614,6 +614,13 @@ let commandsPaceCaret = {
UpdateConfig.setPaceCaret("average");
},
},
{
id: "setPaceCaretRepeat",
display: "repeat",
exec: () => {
UpdateConfig.setPaceCaret("repeat");
},
},
{
id: "setPaceCaretCustom",
display: "custom...",

View file

@ -6,7 +6,11 @@ import * as DB from "./db";
export let settings = null;
function resetCaretPosition() {
if (Config.paceCaret === "off" && !TestLogic.isPaceRepeat) return;
if (
Config.paceCaret !== "off" &&
(Config.paceCaret !== "repeat" || TestLogic.isPaceRepeat)
)
return;
if (!$("#paceCaret").hasClass("hidden")) {
$("#paceCaret").addClass("hidden");
}
@ -69,7 +73,7 @@ export async function init() {
console.log("avg pace " + wpm);
} else if (Config.paceCaret === "custom") {
wpm = Config.paceCaretCustomSpeed;
} else if (TestLogic.isPaceRepeat == true) {
} else if (Config.paceCaret === "repeat" && Repeat) {
wpm = TestLogic.lastTestWpm;
}
if (wpm < 1 || wpm == false || wpm == undefined || Number.isNaN(wpm)) {

View file

@ -342,7 +342,11 @@ export function startTest() {
}
try {
if (Config.paceCaret !== "off" || isPaceRepeat) PaceCaret.start();
if (
Config.paceCaret !== "off" &&
(Config.paceCaret !== "repeat" || isPaceRepeat)
)
PaceCaret.start();
} catch (e) {}
//use a recursive self-adjusting timer to avoid time drift
TestStats.setStart(performance.now());

View file

@ -195,8 +195,8 @@ export function screenshot() {
if (firebase.auth().currentUser == null)
$(".pageTest .loginTip").removeClass("hidden");
}
if (!$("#resultReplay").hasClass('hidden')) {
if (!$("#resultReplay").hasClass("hidden")) {
revealReplay = true;
Replay.pauseReplay();
}
@ -491,7 +491,10 @@ export function updateModesNotice() {
);
}
if (Config.paceCaret !== "off" || TestLogic.isPaceRepeat) {
if (
Config.paceCaret !== "off" &&
(Config.paceCaret !== "repeat" || TestLogic.isPaceRepeat)
) {
let speed = "";
try {
speed = ` (${Math.round(PaceCaret.settings.wpm)} wpm)`;
@ -502,7 +505,7 @@ export function updateModesNotice() {
? "average"
: Config.paceCaret === "pb"
? "pb"
: Config.paceCaret == "off"
: Config.paceCaret == "repeat"
? "repeated"
: "custom"
} pace${speed}</div>`

View file

@ -2648,7 +2648,9 @@
<div class="section paceCaret" section="">
<h1>pace caret</h1>
<div class="text">
Displays a second caret that moves at constant speed.
Displays a second caret that moves at constant speed. The
repeat option enables a pace caret when a test is repeated
that will have the wpm of the previous test.
</div>
<div class="buttons">
<div
@ -2675,6 +2677,14 @@
>
pb
</div>
<div
class="button"
paceCaret="repeat"
tabindex="0"
onclick="this.blur();"
>
repeat
</div>
<div
class="button"
paceCaret="custom"
@ -2699,6 +2709,14 @@
Change the style of the pace caret during the test.
</div>
<div class="buttons">
<div
class="button"
paceCaretStyle="off"
tabindex="0"
onclick="this.blur();"
>
off
</div>
<div
class="button"
paceCaretStyle="default"
@ -3740,12 +3758,12 @@
</div>
<div class="button signIn">
<i class="fas fa-sign-in-alt"></i>
Sign in with email
Sign In
</div>
<div style="font-size: 0.75rem; text-align: center">or</div>
<div class="button signInWithGoogle">
<i class="fab fa-google"></i>
Sign in with Google
Google Sign In
</div>
</form>
</div>