Skip to content

Commit 368b8f5

Browse files
committed
added some more stats to the result page
1 parent e74cb09 commit 368b8f5

3 files changed

Lines changed: 52 additions & 12 deletions

File tree

public/css/style.scss

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ key {
653653
"wpm acc"
654654
"wpm key"
655655
"raw time"
656-
"info info";
656+
"testType info";
657657
.group{
658658
.top{
659659
color: var(--sub-color);
@@ -666,7 +666,21 @@ key {
666666
line-height: 2rem;
667667
}
668668
}
669+
.testType{
670+
align-self: baseline;
671+
grid-area: testType;
672+
color: var(--sub-color);
673+
.top{
674+
font-size: 1rem;
675+
line-height: 1.25rem;
676+
}
677+
.bottom{
678+
font-size: 1rem;
679+
line-height: 1rem;
680+
}
681+
}
669682
.info{
683+
align-self: baseline;
670684
grid-area: info;
671685
color: var(--sub-color);
672686
.top{

public/index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,14 @@
183183
<div class="top">raw wpm</div>
184184
<div class="bottom">-</div>
185185
</div>
186-
<div class="group info">
186+
<div class="group testType">
187187
<div class="top">test type</div>
188188
<div class="bottom">-</div>
189189
</div>
190+
<div class="group info">
191+
<div class="top">other</div>
192+
<div class="bottom">-</div>
193+
</div>
190194
</div>
191195
<div class="chart">
192196
<!-- <div class="title">wpm over time</div> -->

public/js/script.js

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ function showResult(difficultyFailed = false) {
480480
setFocus(false);
481481
hideCaret();
482482
hideLiveWpm();
483+
testInvalid = false;
483484
let stats = calculateStats();
484485
if(stats === undefined){
485486
stats = {
@@ -563,6 +564,7 @@ function showResult(difficultyFailed = false) {
563564
}
564565
} else {
565566
showNotification("Test invalid", 3000);
567+
testInvalid = true;
566568
try{
567569
firebase.analytics().logEvent('testCompletedInvalid', completedEvent);
568570
}catch(e){
@@ -572,29 +574,49 @@ function showResult(difficultyFailed = false) {
572574
}
573575

574576

575-
let infoText = "";
577+
let testType = "";
576578

577579

578-
infoText += config.mode;
580+
testType += config.mode;
579581
if (config.mode == "time") {
580-
infoText += " " + config.time
582+
testType += " " + config.time
581583
} else if (config.mode == "words") {
582-
infoText += " " + config.words
584+
testType += " " + config.words
583585
}
584586
if(config.mode != "custom"){
585-
infoText += "<br>" + config.language.replace('_', ' ');
587+
testType += "<br>" + config.language.replace('_', ' ');
586588
}
587589
if (config.punctuation) {
588-
infoText += "<br>punctuation"
590+
testType += "<br>punctuation"
589591
}
590592
if (config.difficulty == "expert") {
591-
infoText += "<br>expert";
593+
testType += "<br>expert";
592594
}else if(config.difficulty == "master"){
593-
infoText += "<br>master";
595+
testType += "<br>master";
596+
}
597+
598+
$("#result .stats .testType .bottom").html(testType);
599+
600+
601+
let otherText = "";
602+
if(difficultyFailed){
603+
otherText += "<br>failed"
604+
}
605+
if(afkDetected){
606+
otherText += "<br>afk detected"
607+
}
608+
if(testInvalid){
609+
otherText += "<br>invalid"
610+
}
611+
612+
if(otherText == ""){
613+
$("#result .stats .info").addClass('hidden');
614+
}else{
615+
$("#result .stats .info").removeClass('hidden');
616+
otherText = otherText.substring(4);
617+
$("#result .stats .info .bottom").html(otherText);
594618
}
595619

596-
$("#result .stats .info .bottom").html(infoText);
597-
598620
let labels = [];
599621
for (let i = 1; i <= wpmHistory.length; i++) {
600622
labels.push(i.toString());

0 commit comments

Comments
 (0)