Browse Source

Try to stop police asap

Aubort Jean-Baptiste 5 years ago
parent
commit
405565b9fc
1 changed files with 9 additions and 6 deletions
  1. 9 6
      main.js

+ 9 - 6
main.js

@@ -210,15 +210,18 @@ var Police = {
     policeEvent: 0,
     delay: 100,
     switchOff: function switchOff() {
-        window.clearInterval(Police.policeEvent)
+        window.clearInterval(Police.policeEvent);
+        Police.policeEvent = 0;
     },
     switchOn: function switchOn(red) {
-        if (red) {
-            switchTheLight(255, 0, 0);
-        } else {
-            switchTheLight(0, 0, 255);
+        if(Police.policeEvent != 0) {
+            if (red) {
+                switchTheLight(255, 0, 0);
+            } else {
+                switchTheLight(0, 0, 255);
+            }
         }
-        Police.policeEvent = window.setTimeout(function() { Police.switchOn(!red)}, Police.delay)
+        Police.policeEvent = window.setTimeout(function() { Police.switchOn(!red)}, Police.delay);
     },
 };