Browse Source

static object ?

gcmalloc 7 years ago
parent
commit
9e0cd57552
1 changed files with 13 additions and 13 deletions
  1. 13 13
      main.js

+ 13 - 13
main.js

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