Usage:
$(document).ready(function() {
$("#pb1").progressBar();
$("#pb2").progressBar({ barImage: 'images/progressbg_yellow.gif'} );
$("#pb3").progressBar({ barImage: 'images/progressbg_orange.gif', showText: false} );
$("#pb4").progressBar(65, { showText: false, barImage: 'images/progressbg_red.gif'} );
$("#uploadprogressbar").progressBar();
});
Upload Form Javascript:
var progress_key = '= $uuid ?>';
// this sets up the progress bar
$(document).ready(function() {
$("#uploadprogressbar").progressBar();
});
// fades in the progress bar and starts polling the upload progress after 1.5seconds
function beginUpload() {
// uses ajax to poll the uploadprogress.php page with the id
// deserializes the json string, and computes the percentage (integer)
// update the jQuery progress bar
// sets a timer for the next poll in 750ms
$("#uploadprogressbar").fadeIn();
setInterval(function() {
$.getJSON("demo.php?id=" + progress_key, function(data) {
if (data == null)
return;
var percentage = Math.floor(100 * parseInt(data.bytes_uploaded) / parseInt(data.bytes_total));
$("#uploadprogressbar").progressBar(percentage);
});
}, 1500);
}