Last active
August 29, 2015 14:05
-
-
Save DC3/2f28b2ba5fa2f5b54745 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
# http://www.1758.com/hlmy/yanse2.htm | |
$ -> | |
timeEl = $('.time') | |
boxEl = $('#box') | |
interval = null | |
eachTime = 1 # ms | |
replaceRE = /[^\d]+/g | |
getColor = (str) -> | |
+str.replace(replaceRE, '') | |
sortHandler = (a, b) -> | |
getColor(a.style.backgroundColor) - getColor(b.style.backgroundColor) | |
clickHandler = -> boxEl.find('span').sort(sortHandler).last().trigger('click') | |
intervalHandler = -> | |
return if isNaN((countdown = parseInt(timeEl.text(), 10))) | |
return clickHandler() if countdown > 0 | |
clearInterval interval | |
$('body').on 'click', '.play-btn', -> | |
interval = setInterval intervalHandler, eachTime | |
boxEl.hide() | |
console.log '点击开始游戏按钮' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment