added average wpm to account page

This commit is contained in:
unknown 2020-05-19 20:27:08 +01:00
parent 1f451ac37c
commit e5e2f3403c
2 changed files with 8 additions and 1 deletions

View file

@ -297,11 +297,14 @@
<div class="title">favourite test</div>
<div class="val">words 10</div>
</div>
<div class="group averageWpm">
<div class="title">average wpm</div>
<div class="val">1</div>
</div>
<div class="group testCompletion">
<div class="title">test completion</div>
<div class="val">-</div>
</div>
<div></div>
<div class="group avgRestart">
<div class="title">avg restarts per completed test</div>
<div class="val">-</div>

View file

@ -327,6 +327,7 @@ function refreshAccountPage() {
let topWpm = 0;
let topMode = '';
let testRestarts = 0;
let totalWpm = 0;
let testCount = dbSnapshot.length;
$(".pageAccount .history table tbody").empty();
@ -383,6 +384,8 @@ function refreshAccountPage() {
topWpm = result.wpm;
topMode = result.mode + " " + result.mode2 + puncsctring;
}
totalWpm += result.wpm;
})
let subColor = getComputedStyle(document.body).getPropertyValue('--sub-color').replace(' ','');
@ -403,6 +406,7 @@ function refreshAccountPage() {
resultHistoryChart.data.datasets[9].data = testModes.custom;
$(".pageAccount .highestWpm .val").text(topWpm);
$(".pageAccount .averageWpm .val").text(Math.round(totalWpm/testCount));
$(".pageAccount .highestWpm .mode").html(topMode);
$(".pageAccount .testsTaken .val").text(testCount);