From 368b8f59eb7e39383f5861b5db50a81a329eab4a Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 29 May 2020 14:28:15 +0100 Subject: [PATCH] added some more stats to the result page --- public/css/style.scss | 16 +++++++++++++++- public/index.html | 6 +++++- public/js/script.js | 42 ++++++++++++++++++++++++++++++++---------- 3 files changed, 52 insertions(+), 12 deletions(-) diff --git a/public/css/style.scss b/public/css/style.scss index 38922e2df..a0e770671 100644 --- a/public/css/style.scss +++ b/public/css/style.scss @@ -653,7 +653,7 @@ key { "wpm acc" "wpm key" "raw time" - "info info"; + "testType info"; .group{ .top{ color: var(--sub-color); @@ -666,7 +666,21 @@ key { line-height: 2rem; } } + .testType{ + align-self: baseline; + grid-area: testType; + color: var(--sub-color); + .top{ + font-size: 1rem; + line-height: 1.25rem; + } + .bottom{ + font-size: 1rem; + line-height: 1rem; + } + } .info{ + align-self: baseline; grid-area: info; color: var(--sub-color); .top{ diff --git a/public/index.html b/public/index.html index a746243a6..1be7b5b1e 100644 --- a/public/index.html +++ b/public/index.html @@ -183,10 +183,14 @@
raw wpm
-
-
+
test type
-
+
+
other
+
-
+
diff --git a/public/js/script.js b/public/js/script.js index fde5a748a..38f165ff9 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -480,6 +480,7 @@ function showResult(difficultyFailed = false) { setFocus(false); hideCaret(); hideLiveWpm(); + testInvalid = false; let stats = calculateStats(); if(stats === undefined){ stats = { @@ -563,6 +564,7 @@ function showResult(difficultyFailed = false) { } } else { showNotification("Test invalid", 3000); + testInvalid = true; try{ firebase.analytics().logEvent('testCompletedInvalid', completedEvent); }catch(e){ @@ -572,29 +574,49 @@ function showResult(difficultyFailed = false) { } - let infoText = ""; + let testType = ""; - infoText += config.mode; + testType += config.mode; if (config.mode == "time") { - infoText += " " + config.time + testType += " " + config.time } else if (config.mode == "words") { - infoText += " " + config.words + testType += " " + config.words } if(config.mode != "custom"){ - infoText += "
" + config.language.replace('_', ' '); + testType += "
" + config.language.replace('_', ' '); } if (config.punctuation) { - infoText += "
punctuation" + testType += "
punctuation" } if (config.difficulty == "expert") { - infoText += "
expert"; + testType += "
expert"; }else if(config.difficulty == "master"){ - infoText += "
master"; + testType += "
master"; + } + + $("#result .stats .testType .bottom").html(testType); + + + let otherText = ""; + if(difficultyFailed){ + otherText += "
failed" + } + if(afkDetected){ + otherText += "
afk detected" + } + if(testInvalid){ + otherText += "
invalid" + } + + if(otherText == ""){ + $("#result .stats .info").addClass('hidden'); + }else{ + $("#result .stats .info").removeClass('hidden'); + otherText = otherText.substring(4); + $("#result .stats .info .bottom").html(otherText); } - $("#result .stats .info .bottom").html(infoText); - let labels = []; for (let i = 1; i <= wpmHistory.length; i++) { labels.push(i.toString());