@@ -8,6 +8,7 @@ let testActive = false;
88let testStart , testEnd ;
99let wpmHistory = [ ] ;
1010let currentCommands = commands ;
11+ let restartCount = 0 ;
1112
1213let accuracyStats = {
1314 correct : 0 ,
@@ -432,14 +433,12 @@ function showCrown() {
432433}
433434
434435function showResult ( ) {
435- //TODO: #2 Sometimes the caret jumps to the top left corner when showing results
436436 testEnd = Date . now ( ) ;
437437 let stats = calculateStats ( ) ;
438438 clearIntervals ( ) ;
439439 $ ( "#result .stats .wpm .bottom" ) . text ( stats . wpm ) ;
440440 $ ( "#result .stats .acc .bottom" ) . text ( stats . acc + "%" ) ;
441441 $ ( "#result .stats .key .bottom" ) . text ( stats . correctChars + "/" + stats . incorrectChars ) ;
442-
443442 let mode2 = "" ;
444443 if ( config . mode == "time" ) {
445444 mode2 = config . time ;
@@ -456,8 +455,11 @@ function showResult() {
456455 mode2 : mode2 ,
457456 punctuation : config . punctuation ,
458457 timestamp : Date . now ( ) ,
459- language : config . language
458+ language : config . language ,
459+ restartCount : restartCount
460460 } ;
461+ console . log ( restartCount ) ;
462+ restartCount = 0 ;
461463 if ( stats . wpm > 0 && stats . wpm < 250 && stats . acc > 50 && stats . acc <= 100 ) {
462464 if ( firebase . auth ( ) . currentUser != null ) {
463465 db_getUserHighestWpm ( config . mode , mode2 ) . then ( data => {
@@ -538,7 +540,6 @@ function restartTest() {
538540 hideCaret ( ) ;
539541 testActive = false ;
540542 hideLiveWpm ( ) ;
541-
542543 $ ( "#words" ) . stop ( true , true ) . animate ( { opacity : 0 } , 125 ) ;
543544 $ ( "#result" ) . stop ( true , true ) . animate ( {
544545 opacity : 0
@@ -633,6 +634,7 @@ function changePage(page) {
633634 history . pushState ( '/' , null , '/' ) ;
634635 showTestConfig ( ) ;
635636 hideSignOutButton ( ) ;
637+ restartCount = 0 ;
636638 } else if ( page == "about" ) {
637639 $ ( ".page.pageAbout" ) . addClass ( 'active' ) ;
638640 swapElements ( activePage , $ ( ".page.pageAbout" ) , 250 ) ;
@@ -838,6 +840,9 @@ $(window).on('popstate', (e) => {
838840
839841$ ( document ) . on ( "keypress" , "#restartTestButton" , ( event ) => {
840842 if ( event . keyCode == 32 || event . keyCode == 13 ) {
843+ if ( testActive ) {
844+ restartCount ++ ;
845+ }
841846 restartTest ( ) ;
842847 }
843848} ) ;
@@ -936,6 +941,9 @@ $(document).keydown((event) => {
936941 if ( event [ "keyCode" ] == 9 ) {
937942 if ( config . quickTab && $ ( ".pageTest" ) . hasClass ( "active" ) ) {
938943 event . preventDefault ( ) ;
944+ if ( testActive ) {
945+ restartCount ++ ;
946+ }
939947 restartTest ( ) ;
940948 }
941949 }
0 commit comments