var tasker = function(task, msMin, msMax){
(function loop() {
var rand = Math.round(Math.random() * (msMax - msMin/2)) + msMin;
setTimeout(function() {
task();
loop();
}, rand);
}());
};
/*things to do*/
function doSomething() {
/*action here*/
}
function doSomethingAgain() {
/*another action here*/
}
/*usage*/
tasker(doSomething, 500, 1500);
tasker(doSomethingAgain, 1500, 2500);
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.