-//Please do not use the following code as a best practice! :)
-var Runner = function(){
- var f = function(v, pbar, btn, count, cb){
- return function(){
- if(v > count){
- btn.dom.disabled = false;
- cb();
- }else{
- if(pbar.id=='pbar4'){
- //give this one a different count style for fun
- var i = v/count;
- pbar.updateProgress(i, Math.round(100*i)+'% completed...');
- }else{
- pbar.updateProgress(v/count, 'Loading item ' + v + ' of '+count+'...');
- }
- }
- };
- };
- return {
- run : function(pbar, btn, count, cb){
- btn.dom.disabled = true;
- var ms = 5000/count;
- for(var i = 1; i < (count+2); i++){
- setTimeout(f(i, pbar, btn, count, cb), i*ms);
- }
- }
- }
-}();
\ No newline at end of file