@@ -28,6 +28,8 @@ var audio = new Audio(music_list[music_random]);
28
28
var play_status = false ;
29
29
var new_record_notif = "" ;
30
30
var player_name_object ;
31
+ var focus_flag = false ;
32
+ var time = 3 * 60 ;
31
33
32
34
33
35
audio . onended = function ( ) {
@@ -222,6 +224,8 @@ function init(flag) {
222
224
if ( flag == 2 ) {
223
225
reset_counter = reset_counter + 1 ;
224
226
overall_reset = overall_reset + 1 ;
227
+ overall_move = overall_move - parseInt ( move . innerHTML ) ;
228
+ total_move = total_move - parseInt ( move . innerHTML ) ;
225
229
reset . innerHTML = "Reset" + " (" + reset_counter + ")" ;
226
230
}
227
231
while ( random_counter < random_init ) {
@@ -248,12 +252,13 @@ function init(flag) {
248
252
function reply_click ( e ) {
249
253
var input_id , ele , move ;
250
254
move = document . getElementById ( "move" ) ;
251
- if ( first_move == true && init_flag == false ) {
255
+ if ( ( first_move == true && init_flag == false ) || focus_flag == true ) {
252
256
display = document . querySelector ( '#time' ) ;
253
257
// rythm.stop();
254
258
// document.getElementById("lightsout").style=null;
255
- startTimer ( 60 * 3 , display ) ;
259
+ startTimer ( time , display ) ;
256
260
first_move = false ;
261
+ focus_flag = false ;
257
262
}
258
263
input_id = parseInt ( e ) ;
259
264
if ( first_init == 1 ) {
@@ -389,7 +394,11 @@ function startTimer(duration, display) {
389
394
var interval_id = setInterval ( function ( ) {
390
395
minutes = parseInt ( timer / 60 , 10 )
391
396
seconds = parseInt ( timer % 60 , 10 ) ;
392
-
397
+ if ( ! document . hasFocus ( ) ) {
398
+ focus_flag = true ;
399
+ clearInterval ( interval_id ) ;
400
+ time = timer ;
401
+ }
393
402
minutes = minutes < 10 ? "0" + minutes : minutes ;
394
403
seconds = seconds < 10 ? "0" + seconds : seconds ;
395
404
@@ -437,6 +446,7 @@ function startTimer(duration, display) {
437
446
total_hint_counter = total_hint_counter - hint_counter ;
438
447
}
439
448
timer = duration ;
449
+ time = 3 * 60 ;
440
450
restart_config ( display ) ;
441
451
clearInterval ( interval_id ) ;
442
452
0 commit comments