Created
October 21, 2013 15:14
-
-
Save zzuhan/7085542 to your computer and use it in GitHub Desktop.
code_structure single var
This file contains hidden or 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
$('#timer').focus(function(){ | |
// turn on timer | |
startTimer(); | |
}).blur(function(){ | |
// turn off timer | |
endTimer(); | |
}); | |
var lastValue = "", | |
$timer = $('#timer'), | |
timerCheckCount = 0, | |
checkInputChange = function(){ | |
timerCheckCount++; | |
if(lastValue !== $timer.val()) { | |
$timer.next().stop(true, true).fadeIn(0).html('[timer detected changed'+ | |
timerCheckCount + 'times!]' + $timer.val()).fadeOut(2000); | |
lastValue = $timer.val(); | |
} | |
}, | |
timer = null, | |
startTimer = function(){ | |
timer = startTimer(checkInputChange, 200); | |
}, | |
endTimer = function(){ | |
clearInterval(timer); | |
timerCheckCount = 0; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment