showing custom text,

syncing numbers, punc, minwpm, minacc
This commit is contained in:
Miodec 2021-01-23 01:47:02 +00:00
parent 50c8835617
commit 52bb457ba7
2 changed files with 64 additions and 6 deletions

View file

@ -137,6 +137,16 @@ function mp_applyRoomConfig(cfg) {
activateFunbox(cfg.funbox, null, true);
setStopOnError(cfg.stopOnError, true, true);
setConfidenceMode(cfg.confidenceMode, true, true);
setPunctuation(cfg.punctuation, true, true);
setNumbers(cfg.numbers, true, true);
if (cfg.minAcc != null) {
setMinAcc("custom", true, true);
setMinAccCustom(cfg.minAcc, true, true);
}
if (cfg.minWpm != null) {
setMinWpm("custom", true, true);
setMinWpmCustomSpeed(cfg.minAcc, true, true);
}
customText = cfg.customText;
}
@ -177,6 +187,10 @@ function mp_syncConfig() {
stopOnError: config.stopOnError,
confidenceMode: config.confidenceMode,
customText: customText,
punctuation: config.punctuation,
numbers: config.numbers,
minWpm: config.minWpm === "custom" ? config.minWpmCustomSpeed : null,
minAcc: config.minAcc === "custom" ? config.minAccCustom : null,
},
});
}
@ -329,6 +343,28 @@ function mp_refreshConfig() {
<i class="fas fa-quote-right"></i>${qstring}
</div>
`);
} else if (MP.room.config.mode === "custom") {
let t = "Custom settings:";
t += `\ntext length: ${customText.text.length}`;
if (customText.isTimeRandom || customText.isWordRandom) {
let r = "";
let n = "";
if (customText.isTimeRandom) {
r = "time";
n = customText.time;
} else if (customText.isWordRandom) {
r = "words";
n = customText.word;
}
t += `\nrandom: ${r} ${n}`;
}
$(".pageTribe .lobby .currentSettings .groups").append(`
<div class='group' aria-label="${t}" data-balloon-pos="up" data-balloon-break>
<i class="fas fa-tools"></i>custom
</div>
`);
}
$(".pageTribe .lobby .currentSettings .groups").append(`
@ -1019,6 +1055,10 @@ $(".pageTribe #createPrivateRoom").click((f) => {
stopOnError: config.stopOnError,
confidenceMode: config.confidenceMode,
customText: customText,
punctuation: config.punctuation,
numbers: config.numbers,
minWpm: config.minWpm === "custom" ? config.minWpmCustomSpeed : null,
minAcc: config.minAcc === "custom" ? config.minAccCustom : null,
},
});
});

View file

@ -425,7 +425,10 @@ function setPaceCaretCustomSpeed(val, nosave) {
}
//min wpm
function setMinWpm(minwpm, nosave) {
function setMinWpm(minwpm, nosave, mp = false) {
if (!mp_checkIfCanChangeConfig(mp)) {
return;
}
if (minwpm == undefined) {
minwpm = "off";
}
@ -434,7 +437,10 @@ function setMinWpm(minwpm, nosave) {
if (!nosave) saveConfigToCookie();
}
function setMinWpmCustomSpeed(val, nosave) {
function setMinWpmCustomSpeed(val, nosave, mp = false) {
if (!mp_checkIfCanChangeConfig(mp)) {
return;
}
if (val == undefined || Number.isNaN(parseInt(val))) {
val = 100;
}
@ -443,7 +449,10 @@ function setMinWpmCustomSpeed(val, nosave) {
}
//min acc
function setMinAcc(min, nosave) {
function setMinAcc(min, nosave, mp = false) {
if (!mp_checkIfCanChangeConfig(mp)) {
return;
}
if (min == undefined) {
min = "off";
}
@ -452,7 +461,10 @@ function setMinAcc(min, nosave) {
if (!nosave) saveConfigToCookie();
}
function setMinAccCustom(val, nosave) {
function setMinAccCustom(val, nosave, mp = false) {
if (!mp_checkIfCanChangeConfig(mp)) {
return;
}
if (val == undefined || Number.isNaN(parseInt(val))) {
val = 90;
}
@ -932,7 +944,10 @@ function toggleQuickTabMode() {
}
//numbers
function setNumbers(numb, nosave) {
function setNumbers(numb, nosave, mp = false) {
if (!mp_checkIfCanChangeConfig(mp)) {
return;
}
config.numbers = numb;
if (!config.numbers) {
$("#top .config .numbersMode .text-button").removeClass("active");
@ -953,7 +968,10 @@ function toggleNumbers() {
}
//punctuation
function setPunctuation(punc, nosave) {
function setPunctuation(punc, nosave, mp = false) {
if (!mp_checkIfCanChangeConfig(mp)) {
return;
}
config.punctuation = punc;
if (!config.punctuation) {
$("#top .config .punctuationMode .text-button").removeClass("active");