Skip to content

Commit e252996

Browse files
fix : focus mode pause added
1 parent cb91277 commit e252996

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<link rel="stylesheet" href="css/themes/google/google.css">
88
<link rel="stylesheet" type="text/css" href="css/sweetalert.css">
99
<script src="js/shortcut.js"></script>
10-
<script src="js/script.min.js" type="text/javascript"></script>
10+
<script src="js/script.js" type="text/javascript"></script>
1111
<title>Lights Out Game</title>
1212
<meta name="description" content="Lights Out, Linear Algebra Game ;-), The goal of the puzzle is to switch all the lights off, preferably in as few button presses as possible" />
1313
<meta property="og:title" content="Lights Out" />

js/script.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ var audio = new Audio(music_list[music_random]);
2828
var play_status=false;
2929
var new_record_notif="";
3030
var player_name_object;
31+
var focus_flag=false;
32+
var time=3*60;
3133

3234

3335
audio.onended = function(){
@@ -222,6 +224,8 @@ function init(flag) {
222224
if (flag == 2) {
223225
reset_counter = reset_counter + 1;
224226
overall_reset = overall_reset + 1;
227+
overall_move=overall_move-parseInt(move.innerHTML);
228+
total_move=total_move-parseInt(move.innerHTML);
225229
reset.innerHTML = "Reset" + " (" + reset_counter + ")";
226230
}
227231
while (random_counter < random_init) {
@@ -248,12 +252,13 @@ function init(flag) {
248252
function reply_click(e) {
249253
var input_id, ele, move;
250254
move = document.getElementById("move");
251-
if (first_move==true&&init_flag==false){
255+
if ((first_move==true&&init_flag==false)||focus_flag==true){
252256
display = document.querySelector('#time');
253257
// rythm.stop();
254258
// document.getElementById("lightsout").style=null;
255-
startTimer(60*3, display);
259+
startTimer(time, display);
256260
first_move=false;
261+
focus_flag=false;
257262
}
258263
input_id = parseInt(e);
259264
if (first_init == 1) {
@@ -389,7 +394,11 @@ function startTimer(duration, display) {
389394
var interval_id = setInterval(function () {
390395
minutes = parseInt(timer / 60, 10)
391396
seconds = parseInt(timer % 60, 10);
392-
397+
if ( !document.hasFocus() ) {
398+
focus_flag=true;
399+
clearInterval(interval_id);
400+
time=timer;
401+
}
393402
minutes = minutes < 10 ? "0" + minutes : minutes;
394403
seconds = seconds < 10 ? "0" + seconds : seconds;
395404

@@ -437,6 +446,7 @@ function startTimer(duration, display) {
437446
total_hint_counter=total_hint_counter-hint_counter;
438447
}
439448
timer = duration;
449+
time=3*60;
440450
restart_config(display);
441451
clearInterval(interval_id);
442452

0 commit comments

Comments
 (0)