Merge pull request #4 from Miodec/master

update
This commit is contained in:
UnrealApex 2021-03-08 13:25:07 -08:00 committed by GitHub
commit 147bc47e43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 24 deletions

View file

@ -828,18 +828,18 @@ function validateResult(result) {
);
return false;
}
if (result.allChars != undefined) {
let raw = roundTo2((result.allChars * (60 / result.testDuration)) / 5);
if (
raw < result.rawWpm - result.rawWpm * 0.01 ||
raw > result.rawWpm + result.rawWpm * 0.01
) {
console.error(
`Could not validate result for ${result.uid}. raw ${raw} != ${result.rawWpm}`
);
return false;
}
}
// if (result.allChars != undefined) {
// let raw = roundTo2((result.allChars * (60 / result.testDuration)) / 5);
// if (
// raw < result.rawWpm - result.rawWpm * 0.01 ||
// raw > result.rawWpm + result.rawWpm * 0.01
// ) {
// console.error(
// `Could not validate result for ${result.uid}. raw ${raw} != ${result.rawWpm}`
// );
// return false;
// }
// }
if (result.mode === "time" && (result.mode2 === 15 || result.mode2 === 60)) {
let keyPressTimeSum =
result.keySpacing.reduce((total, val) => {
@ -870,7 +870,7 @@ function validateResult(result) {
if (result.chartData.wpm.filter((w) => w > 400).length > 0) return false;
}
if (result.consistency < 10) return false;
if (result.wpm > 100 && result.consistency < 10) return false;
return true;
}

View file

@ -974,6 +974,14 @@ let commandsCaretStyle = {
setCaretStyle("underline");
},
},
{
id: "setCaretStyleCarrot",
display: "carrot",
visible: false,
exec: () => {
setCaretStyle("carrot");
},
},
],
};

View file

@ -1766,16 +1766,13 @@ function calculateStats() {
let wpm = Misc.roundTo2(
((chars.correctWordChars + chars.correctSpaces) * (60 / testSeconds)) / 5
);
// let wpmraw = Misc.roundTo2(
// ((chars.allCorrectChars +
// chars.spaces +
// chars.incorrectChars +
// chars.extraChars) *
// (60 / testSeconds)) /
// 5
// );
let wpmraw = Misc.roundTo2(
rawHistory.reduce((a, b) => a + b, 0) / rawHistory.length
((chars.allCorrectChars +
chars.spaces +
chars.incorrectChars +
chars.extraChars) *
(60 / testSeconds)) /
5
);
let acc = Misc.roundTo2(
(accuracyStats.correct /
@ -3452,8 +3449,7 @@ function liveWpmAndRaw() {
let testNow = performance.now();
let testSeconds = (testNow - testStart) / 1000;
let wpm = Math.round(((correctWordChars + spaces) * (60 / testSeconds)) / 5);
// let raw = Math.round(((chars + spaces) * (60 / testSeconds)) / 5);
let raw = Math.round((currentKeypress.count * (60 / 1)) / 5);
let raw = Math.round(((chars + spaces) * (60 / testSeconds)) / 5);
return {
wpm: wpm,
raw: raw,

View file

@ -607,6 +607,7 @@ function setCaretStyle(caretStyle, nosave) {
$("#caret").removeClass("underline");
$("#caret").removeClass("outline");
$("#caret").removeClass("block");
$("#caret").removeClass("carrot");
if (caretStyle == "off") {
$("#caret").addClass("off");
@ -618,6 +619,8 @@ function setCaretStyle(caretStyle, nosave) {
$("#caret").addClass("outline");
} else if (caretStyle == "underline") {
$("#caret").addClass("underline");
} else if (caretStyle == "carrot") {
$("#caret").addClass("carrot");
}
if (!nosave) saveConfigToCookie();
}

View file

@ -1145,6 +1145,21 @@ a:hover {
width: 2px;
}
&.carrot {
background-color: transparent;
background-image: url("../carrot.png");
background-size: contain;
background-position: center;
background-repeat: no-repeat;
width: 0.25rem;
&.size2 {
margin-left: -0.1rem;
}
&.size3 {
margin-left: -0.2rem;
}
}
&.block {
width: 0.7em;
margin-left: 0.25em;

BIN
static/carrot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB