added raw wpm display to the account page

This commit is contained in:
Jack 2020-05-29 22:37:52 +01:00
parent 6f242e37b2
commit c4e9953e7c
3 changed files with 43 additions and 1 deletions

View file

@ -440,6 +440,21 @@
<div class="title">average wpm<br>(last 10 tests)</div>
<div class="val">-</div>
</div>
<div class="group highestRaw">
<div class="title">highest raw wpm</div>
<div class="val">-</div>
<div class="mode"></div>
</div>
<div class="group averageRaw">
<div class="title">average raw wpm</div>
<div class="val">-</div>
</div>
<div class="group averageRaw10">
<div class="title">average raw wpm<br>(last 10 tests)</div>
<div class="val">-</div>
</div>
<div class="group testsStarted">
<div class="title">tests started</div>
<div class="val">-</div>

View file

@ -401,6 +401,14 @@ function refreshAccountPage() {
let totalAcc = 0;
let totalAcc10 = 0;
let rawWpm = {
total: 0,
count: 0,
last10Total: 0,
last10Count: 0,
max: 0
}
$(".pageAccount .history table tbody").empty();
dbSnapshot.forEach(result => {
// console.log(result);
@ -440,6 +448,20 @@ function refreshAccountPage() {
}
testCount++;
if(result.rawWpm != null){
if(rawWpm.last10Count < 10){
rawWpm.last10Count++;
rawWpm.last10Total += result.rawWpm;
}
rawWpm.total += result.rawWpm;
rawWpm.count++;
if(result.rawWpm > rawWpm.max){
rawWpm.max = result.rawWpm;
}
}
totalAcc += result.acc;
if (result.restartCount != undefined) {
@ -514,6 +536,11 @@ function refreshAccountPage() {
$(".pageAccount .highestWpm .val").text(topWpm);
$(".pageAccount .averageWpm .val").text(Math.round(totalWpm/testCount));
$(".pageAccount .averageWpm10 .val").text(Math.round(wpmLast10total/last10));
$(".pageAccount .highestRaw .val").text(rawWpm.max);
$(".pageAccount .averageRaw .val").text(Math.round(rawWpm.total/rawWpm.count));
$(".pageAccount .averageRaw10 .val").text(Math.round(rawWpm.last10Total/rawWpm.last10Count));
$(".pageAccount .highestWpm .mode").html(topMode);
$(".pageAccount .testsTaken .val").text(testCount);

View file

@ -525,7 +525,7 @@ function showResult(difficultyFailed = false) {
}else{
let completedEvent = {
wpm: stats.wpm,
rawWpm: stats.rawWpm,
rawWpm: stats.wpmRaw,
correctChars: stats.correctChars + stats.spaces,
incorrectChars: stats.incorrectChars,
acc: stats.acc,