Skip to content

Instantly share code, notes, and snippets.

@quantumJLBass
Last active January 12, 2016 19:05
Show Gist options
  • Save quantumJLBass/5c413a91c18756485776 to your computer and use it in GitHub Desktop.
Save quantumJLBass/5c413a91c18756485776 to your computer and use it in GitHub Desktop.
(function( window, $, WSU ){
WSU.time = null;
WSU.timer = function( time, callback){
console.log("clear old timer");
window.clearTimeout(WSU.time);
WSU.time = null;
console.log("set timer");
WSU.time = window.setInterval(function(){
console.log("do timer callback");
if( "function" === typeof callback){
callback();
}else{
console.log("no callback");
}
},time||1000);
};
$(window.document).ready(function(){
//custom code to controll what to do on time
$(window.document).on("click, keypress", function(){
console.clear();
console.log("resetting timer");
WSU.timer(500,function(){
console.log("what i want to do");
});
});
WSU.timer(500,function(){
console.log("starting timer");
});
});
}( window, jQuery, jQuery.WSU||{} ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment