
(function($,undefined){var dpProgress={_refreshProgress:0,_create:function(){this.element.html('<div class="percent"></div><div class="pbar"></div><div class="remaining"></div>');},_init:function(){this.element.children('.pbar').progressbar();this._refreshProgress=setInterval($.proxy(this._updateProgress,this),this.options.interval);},progress:function(progress){if(progress==undefined){return this.options.progress;}
else{this.options.progress=this._constrainProgress(progress);}},options:{start:new Date(),progress:0.0,interval:500},_updateProgress:function(){var Sms=1000;var Mms=60*Sms;var Hms=3600*Sms;var Dms=24*3600*Sms;var perc=this.options.progress;var leftMs=0;if(perc>0)
leftMs=(1.0-perc)*(new Date()-this.options.start)/perc;var leftDays=parseInt(leftMs/Dms),leftHours=parseInt((leftMs-(leftDays*Dms))/Hms),leftMin=parseInt((leftMs-(leftDays*Dms)-(leftHours*Hms))/Mms),leftSec=parseInt((leftMs-(leftDays*Dms)-(leftMin*Mms)-(leftHours*Hms))/Sms);this.element.children('.percent').html('<b>'+(perc*100).toFixed(1)+'%</b>');this.element.children('.remaining').html(leftDays+' days '+leftHours+'h:'+leftMin+'m:'+leftSec+'s</b>');this.element.children('.pbar').children('.ui-progressbar-value').css('width',perc*100+'%');if(perc>=1){clearInterval(this._refreshProgress);this.element.children('.percent').html('<b>100%</b>');this.element.children('.elapsed').html('Finished');this.element.trigger('finished');}},_constrainProgress:function(value){if(value>100){value=100.0;}
if(value>1){value=value/100.0;}
if(value<0){value=0.0;}
return value;}};$.widget('ui.dpProgress',dpProgress);}(jQuery));