Skip to content

Commit e5e2f34

Browse files
committed
added average wpm to account page
1 parent 1f451ac commit e5e2f34

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

public/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,14 @@ <h1>theme</h1>
297297
<div class="title">favourite test</div>
298298
<div class="val">words 10</div>
299299
</div>
300+
<div class="group averageWpm">
301+
<div class="title">average wpm</div>
302+
<div class="val">1</div>
303+
</div>
300304
<div class="group testCompletion">
301305
<div class="title">test completion</div>
302306
<div class="val">-</div>
303307
</div>
304-
<div></div>
305308
<div class="group avgRestart">
306309
<div class="title">avg restarts per completed test</div>
307310
<div class="val">-</div>

public/js/account.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ function refreshAccountPage() {
327327
let topWpm = 0;
328328
let topMode = '';
329329
let testRestarts = 0;
330+
let totalWpm = 0;
330331

331332
let testCount = dbSnapshot.length;
332333
$(".pageAccount .history table tbody").empty();
@@ -383,6 +384,8 @@ function refreshAccountPage() {
383384
topWpm = result.wpm;
384385
topMode = result.mode + " " + result.mode2 + puncsctring;
385386
}
387+
388+
totalWpm += result.wpm;
386389
})
387390

388391
let subColor = getComputedStyle(document.body).getPropertyValue('--sub-color').replace(' ','');
@@ -403,6 +406,7 @@ function refreshAccountPage() {
403406
resultHistoryChart.data.datasets[9].data = testModes.custom;
404407

405408
$(".pageAccount .highestWpm .val").text(topWpm);
409+
$(".pageAccount .averageWpm .val").text(Math.round(totalWpm/testCount));
406410
$(".pageAccount .highestWpm .mode").html(topMode);
407411
$(".pageAccount .testsTaken .val").text(testCount);
408412

0 commit comments

Comments
 (0)