Created
June 28, 2011 10:37
-
-
Save dmitry-ilyashevich/1050884 to your computer and use it in GitHub Desktop.
Timed event
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($) { | |
var minimumTime = 1000; // minimum ms between events | |
var canFireEvent = true; | |
function myTimedEvent() { | |
if (canFireEvent) { | |
canFireEvent = false; | |
window.setTimeout(function() { | |
canFireEvent = true; | |
}, minimumTime); | |
executeFunction(); | |
} | |
} | |
function executeFunction() { | |
console.log("executed at " + (new Date()).toString()); | |
} | |
$(document).ready(function() { | |
$('button').click(myTimedEvent); | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment