Last active
August 29, 2015 14:05
-
-
Save anjianshi/7f8f3ffc1d38279bccc7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function normal() { | |
var color1, color1box, color2, color2box; | |
var boxes = document.querySelectorAll('#box > span'), boxLen = boxes.length; | |
for(var i = 0; i < boxLen; i++) { | |
var box = boxes[i], color = box.style.backgroundColor; | |
if(i == 0) { | |
color1 = color; | |
color1box = box; | |
} else if(!color2) { | |
if(color != color1) { | |
if(i > 1) { | |
box.click(); | |
setTimeout(normal); | |
return; | |
} else { | |
color2 = color; | |
color2box = box; | |
} | |
} | |
} else { | |
(color == color1 ? color2box : color1box).click(); | |
setTimeout(normal); | |
return; | |
} | |
} | |
} | |
function start() { | |
document.getElementById('box').style.display = 'none'; | |
normal(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment