2929 <!-- Latest compiled and minified JavaScript -->
3030 < script src ="color.js "> </ script >
3131
32- < body style ="background-color: transparent; ">
32+ < body style ="background-color: transparent; " id ="tehbody ">
33+ < h1 id ="scorecount " style ="color: black; padding-left: 20px ">
34+ </ h1 >
3335 < center >
3436 < h1 class ="words " style ="font-family: captcha ">
3537 </ h1 >
@@ -48,6 +50,7 @@ <h1 class="win2" style="display: none">
4850 </ body >
4951 < script src ="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js "> </ script >
5052 < script src ="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js " crossorigin ="anonymous "> </ script >
53+ < script src ="js/nanobar.min.js " crossorigin ="anonymous "> </ script >
5154 < script src ="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.6.8/sweetalert2.min.js "> </ script >
5255< link rel ="stylesheet " type ="text/css " href ="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.6.8/sweetalert2.min.css ">
5356 < script >
@@ -75,6 +78,21 @@ <h1 class="win2" style="display: none">
7578 ]
7679 var out = [ ] ; // Initialise array of names of fruits
7780 var mappings = { } ;
81+ var options = {
82+ id : 'my-id' ,
83+ target : document . getElementById ( 'tehbody' )
84+ } ;
85+
86+ var nanobar = new Nanobar ( options ) ;
87+ var b = 0 ;
88+ var meee = setInterval ( function ( ) {
89+ b ++
90+ nanobar . go ( Math . round ( ( b / 600 ) * 100 ) )
91+ if ( b > 600 ) {
92+ clearInterval ( meee )
93+ }
94+ } , 100 )
95+
7896 for ( var i = 0 ; i < fruits . length ; i ++ ) { // Go throught fruit objects
7997 out . push ( fruits [ i ] . name ) // Else, add the name of fruit to Array
8098 console . log ( fruits [ i ] . pics )
@@ -126,7 +144,7 @@ <h1 class="win2" style="display: none">
126144 console . log ( "Yay" )
127145 pic = "url('legendary.png')"
128146 }
129- $ ( ".words" ) . css ( "color" , color ( pic . replace ( "url('" , "" ) . replace ( "')" , "" ) ) ) ;
147+ $ ( ".words" ) . css ( "color" , color ( pic . replace ( "url('" , "" ) . replace ( "')" , "" ) , fruits [ 2 ] . pics . indexOf ( pic ) !== - 1 ) ) ;
130148 randomMove ( $ ( ".words" ) ) // CHANGED: Now moves text each time
131149 current . pic = pic ;
132150 current . word = word ;
@@ -136,7 +154,7 @@ <h1 class="win2" style="display: none">
136154 $ ( "html" ) . css ( "background-image" , "" ) ; // Remove background image
137155 $ ( "html" ) . css ( "background-color" , "black" ) ; // Set the background black
138156 $ ( ".words" ) . remove ( ) // Remove the current word (ie banana)
139- $ ( ".win2" ) . text ( "You scored " + rounds + " points." ) // Set winning text
157+ $ ( ".win2" ) . text ( "You scored " + ( correct - incorrect ) + " points." ) // Set winning text
140158 $ ( ".win2" ) . fadeIn ( ) // Fade in the winning text
141159 $ ( ".sboard" ) . fadeIn ( ) // Fade in the scoreboard
142160 swal ( { // Create a dialog box:
@@ -153,7 +171,7 @@ <h1 class="win2" style="display: none">
153171 data : { } ,
154172 headers : {
155173 "XName" : name , // The data name and score, where name is what the user put in the box
156- "XScore" : rounds
174+ "XScore" : ( correct - incorrect )
157175 } ,
158176 dataType : 'json' ,
159177 success : function ( data ) { // Then when that data is successfully sent
@@ -170,23 +188,25 @@ <h1 class="win2" style="display: none">
170188 document . onkeyup = function ( ) { } ; // Finally, set the "onkeyup" function to empty so that users can't continue playing
171189 } , 60000 )
172190
173- var rounds = 0 ; // Start at 0 wins
174-
191+ var correct = 0 ; // Start at 0 wins
192+ var incorrect = 0
175193
176194 document . onkeyup = function ( e ) { // When someone lets go of a key
177195 var mapped = mappings [ e . code ] // Get the key from "mappings", which was defined earlier
178196 if ( mapped == undefined ) return ; // If the key isn't registered, forget about it
179197 if ( mapped == current . word ) { // If the key is the correct one TODO: Count incorrect keys
180198 var key = choose ( out ) // Then pick two random fruits
181199 var key2 = choose ( out ) // ^
182- rounds ++ ; // Add 1 to the win counter
183- if ( rounds >= 40 && rounds <= 42 ) {
200+ correct ++ ; // Add 1 to the win counter
201+ $ ( "#scorecount" ) . text ( correct - incorrect )
202+ if ( correct >= 40 && correct <= 42 ) {
184203 initPic ( "url('legendary.png')" , key )
185204 } else {
186205 initPic ( getImageFromName ( key2 ) , key ) // And set the background and text to those random fruits
187206 }
188- }
189- else {
207+ } else {
208+ incorrect = incorrect + 1 ;
209+ $ ( "#scorecount" ) . text ( correct - incorrect )
190210 }
191211
192212
0 commit comments