added separate setting for repeated pace

This commit is contained in:
Miodec 2021-05-17 15:36:27 +01:00
parent 774f26bf09
commit c284532e73
7 changed files with 52 additions and 16 deletions

View file

@ -614,13 +614,6 @@ let commandsPaceCaret = {
UpdateConfig.setPaceCaret("average");
},
},
{
id: "setPaceCaretRepeat",
display: "repeat",
exec: () => {
UpdateConfig.setPaceCaret("repeat");
},
},
{
id: "setPaceCaretCustom",
display: "custom...",
@ -633,6 +626,7 @@ let commandsPaceCaret = {
],
};
let commandsMinWpm = {
title: "Change min wpm mode...",
list: [
@ -1669,6 +1663,13 @@ export let defaultCommands = {
Commandline.show();
},
},
{
id: "toggleRepeatedPace",
display: "Toggle repeated pace",
exec: () => {
UpdateConfig.toggleRepeatedPace();
},
},
{
id: "changeTimerStyle",
display: "Change timer/progress style...",

View file

@ -99,6 +99,7 @@ let defaultConfig = {
showOutOfFocusWarning: true,
paceCaret: "off",
paceCaretCustomSpeed: 100,
repeatedPace: true,
pageWidth: "100",
chartAccuracy: true,
chartStyle: "line",
@ -502,6 +503,24 @@ export function setPaceCaretCustomSpeed(val, nosave) {
if (!nosave) saveToLocalStorage();
}
//repeated pace
export function toggleRepeatedPace() {
let pace = !config.repeatedPace;
if (pace == undefined) {
pace = true;
}
config.repeatedPace = pace;
saveToLocalStorage();
}
export function setRepeatedPace(pace, nosave) {
if (pace == undefined) {
pace = true;
}
config.repeatedPace = pace;
if (!nosave) saveToLocalStorage();
}
//min wpm
export function setMinWpm(minwpm, nosave) {
if (minwpm == undefined) {
@ -1516,6 +1535,7 @@ export function apply(configObj) {
setShowOutOfFocusWarning(configObj.showOutOfFocusWarning, true);
setPaceCaret(configObj.paceCaret, true);
setPaceCaretCustomSpeed(configObj.paceCaretCustomSpeed, true);
setRepeatedPace(configObj.repeatedPace, true);
setPageWidth(configObj.pageWidth, true);
setChartAccuracy(configObj.chartAccuracy, true);
setChartStyle(configObj.chartStyle, true);

View file

@ -193,6 +193,10 @@ async function initGroups() {
}
}
);
groups.repeatedPace = new SettingsGroup(
"repeatedPace",
UpdateConfig.setRepeatedPace
);
groups.minWpm = new SettingsGroup("minWpm", UpdateConfig.setMinWpm, () => {
if (Config.minWpm === "custom") {
$(".pageSettings .section.minWpm input.customMinWpmSpeed").removeClass(

View file

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

View file

@ -343,8 +343,8 @@ export function startTest() {
try {
if (
Config.paceCaret !== "off" &&
(Config.paceCaret !== "repeat" || isPaceRepeat)
Config.paceCaret !== "off" ||
(Config.repeatedPace && isPaceRepeat)
)
PaceCaret.start();
} catch (e) {}

View file

@ -492,8 +492,8 @@ export function updateModesNotice() {
}
if (
Config.paceCaret !== "off" &&
(Config.paceCaret !== "repeat" || TestLogic.isPaceRepeat)
Config.paceCaret !== "off" ||
(Config.repeatedPace && TestLogic.isPaceRepeat)
) {
let speed = "";
try {

View file

@ -2703,6 +2703,20 @@
/>
</div>
</div>
<div class="section repeatedPace" section="">
<h1>repeated pace</h1>
<div class="text">
When repeating a test, a pace caret will automatically be enabled for one test set to match the speed of your previous test. It does not override the pace caret settings if it's already enabled.
</div>
<div class="buttons">
<div class="button off" tabindex="0" onclick="this.blur();">
off
</div>
<div class="button on" tabindex="0" onclick="this.blur();">
on
</div>
</div>
</div>
<div class="section paceCaretStyle" section="">
<h1>pace caret style</h1>
<div class="text">