From 24863a40d10f1b2fafb9d5338d4c879951bb748d Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 8 Jun 2020 18:58:18 +0100 Subject: [PATCH] added incomplete test seconds to better estimate time spent typign --- public/js/account.js | 4 +++- public/js/script.js | 23 +++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/public/js/account.js b/public/js/account.js index 77b59cbc9..f2fa5cb3f 100644 --- a/public/js/account.js +++ b/public/js/account.js @@ -484,7 +484,9 @@ function refreshAccountPage() { }else{ tt = parseFloat(result.testDuration); } - if(result.restartCount != null){ + if(result.incompleteTestSeconds != undefined){ + tt += result.incompleteTestSeconds; + }else if(result.restartCount != undefined && result.restartCount > 0){ tt += (tt/4) * result.restartCount; } totalSeconds += tt; diff --git a/public/js/script.js b/public/js/script.js index f00109daf..55efbfe94 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -353,6 +353,9 @@ function compareInput(wrdIndex,input,showError) { } else { if(config.difficulty == "master"){ if(!resultVisible) showResult(true); + let testNow = Date.now(); + let testSeconds = roundTo2((testNow - testStart) / 1000); + incompleteTestSeconds += testSeconds; restartCount++; } if(!showError){ @@ -651,12 +654,15 @@ function showResult(difficultyFailed = false) { timestamp: Date.now(), language: config.language, restartCount: restartCount, + incompleteTestSeconds: incompleteTestSeconds, difficulty: config.difficulty, testDuration: testtime, blindMode: config.blindMode, theme: config.theme }; if(config.difficulty == "normal" || ((config.difficulty == "master" || config.difficulty == "expert") && !difficultyFailed)){ + // console.log(incompleteTestSeconds); + // console.log(restartCount); restartCount = 0; incompleteTestSeconds = 0; } @@ -1295,6 +1301,9 @@ $(window).on('popstate', (e) => { $(document).on("keypress", "#restartTestButton", (event) => { if (event.keyCode == 32 || event.keyCode == 13) { if (testActive) { + let testNow = Date.now(); + let testSeconds = roundTo2((testNow - testStart) / 1000); + incompleteTestSeconds += testSeconds; restartCount++; } restartTest(); @@ -1448,6 +1457,9 @@ $(document).keydown((event) => { if (config.quickTab && $(".pageTest").hasClass("active")) { event.preventDefault(); if (testActive) { + let testNow = Date.now(); + let testSeconds = roundTo2((testNow - testStart) / 1000); + incompleteTestSeconds += testSeconds; restartCount++; } restartTest(); @@ -1539,6 +1551,9 @@ $(document).keydown((event) => { return; }else if(config.difficulty == "expert" || config.difficulty == "master"){ showResult(true); + let testNow = Date.now(); + let testSeconds = roundTo2((testNow - testStart) / 1000); + incompleteTestSeconds += testSeconds; restartCount++; return; } @@ -1664,7 +1679,7 @@ let wpmOverTimeChart = new Chart(ctx, { ticks: { fontFamily: "Roboto Mono", autoSkip: true, - autoSkipPadding: 20 + autoSkipPadding: 40 }, display: true, scaleLabel: { @@ -1686,7 +1701,7 @@ let wpmOverTimeChart = new Chart(ctx, { beginAtZero: true, min: 0, autoSkip: true, - autoSkipPadding: 20 + autoSkipPadding: 40 }, gridLines: { display:false @@ -1705,7 +1720,7 @@ let wpmOverTimeChart = new Chart(ctx, { beginAtZero: true, min: 0, autoSkip: true, - autoSkipPadding: 20 + autoSkipPadding: 40 }, gridLines: { display:false @@ -1725,7 +1740,7 @@ let wpmOverTimeChart = new Chart(ctx, { fontFamily: 'Roboto Mono', beginAtZero: true, autoSkip: true, - autoSkipPadding: 20 + autoSkipPadding: 40 }, gridLines: { display:true