<div id="progressBar"><div></div></div>
$(document).ready(function(){
$("input[name='vidfile[]']").change(function(){
var t = this.files[0].size;
var sec = getseconds(t);
var dispopt = {/literal} '{$dispopt}' {literal};
if(dispopt == 'count')
{
startprogress(sec); //countdown opt
}else{
var maxsec = parseInt(sec);
var zippo = 0;
startProgressBar(zippo, maxsec, $('#progressBar')); //progress bar option
}//close else
});
});
/* progress bar */
function startProgressBar(begin, totaltime, $element)
{
$("form[name='viduploadForm']").submit(function(){
var defval = parseInt(begin);
var totaltimesec = parseInt(totaltime); //total secs to do the upload
//default first appearance
var progressBarWidth = defval * $element.width() / 100;
$element.find('div').animate({ width: progressBarWidth }, 500).html(defval + "% ");
startTimerBar(totaltime, $element);
});
}//close function
function startTimerBar(howlong, $element)
{
var totalsec = parseInt(howlong); //total sec it will take
var count = 0;
function timerbar()
{
count = count + 1;
if(count < totalsec)
{
//continue the loop
progressBarWidth = count * $element.width() / totalsec;
$element.find('div').animate({ width: progressBarWidth }, 500).html(count + "% ");
}else{
clearInterval(sb);
}//close else
};
timerbar();
var sb = setInterval(timerbar, 1000);
}//close function
برچسب:
نویسنده: آیلین رضوانی