@@ -7,6 +7,7 @@ const scratch = document.getElementById("scratch");
77const scratchStartRect = scratch . getBoundingClientRect ( ) ;
88if ( localStorage . getItem ( "scratchRecordHeight" ) == null ) {
99 localStorage . setItem ( "scratchRecordHeight" , 0 ) ;
10+ localStorage . setItem ( "scratchTrysTotal" , 0 ) ;
1011 localStorage . setItem ( "scratchTrys" , 0 ) ;
1112}
1213// const ha = document.getElementById("ha");
@@ -50,18 +51,23 @@ scratch.addEventListener("mouseout", () => {
5051 const scratchRect = scratch . getBoundingClientRect ( ) ;
5152 const scratchHeight = Math . abs ( scratchRect . top - scratchStartRect . top ) ;
5253 const scratchRecordHeight = localStorage . getItem ( "scratchRecordHeight" ) ;
54+ let scratchTrysTotal = localStorage . getItem ( "scratchTrysTotal" ) ;
5355 let scratchTrys = localStorage . getItem ( "scratchTrys" ) ;
54- scratchTrys ++ ;
5556 console . log ( "scratchHeight: " + scratchHeight ) ;
5657
57- //Versuche counter
58- localStorage . setItem ( "scratchTrys" , scratchTrys ) ;
59- trysField . innerHTML = scratchTrys ;
60-
6158 if ( scratchHeight > scratchRecordHeight ) {
6259 localStorage . setItem ( "scratchRecordHeight" , scratchHeight ) ;
6360 console . log ( "NEUER REKORD" ) ;
6461 recordField . innerHTML = parseInt ( scratchHeight ) ;
6562 newRecord . showModal ( ) ;
63+ } else {
64+ scratchTrys ++ ;
65+ localStorage . setItem ( "scratchTrys" , scratchTrys ) ;
6666 }
67+
68+ //Versuche counter
69+ scratchTrysTotal ++ ;
70+ localStorage . setItem ( "scratchTrysTotal" , scratchTrysTotal ) ;
71+
72+ trysField . innerHTML = scratchTrys + "/" + scratchTrysTotal ;
6773} ) ;
0 commit comments