Last active
January 12, 2016 19:05
-
-
Save quantumJLBass/5c413a91c18756485776 to your computer and use it in GitHub Desktop.
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
(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