1 function ProgressBar(size,interval) {
3 if(interval == null) interval = 100;
4 if(size == null) size = 10;
5 this.is_running = false;
8 this.interval = interval;
10 this.div = createAppElement("div");
11 this.div.className = "progress_bar";
15 this.percentDiv = createAppElement("div");
16 add_css_class(this.percentDiv, "progress_percent");
18 var divWidth = parseInt(100 / parseInt(size));
19 for( i = 0; i!= size; i++ ) {
20 var div = createAppElement("div");
21 div.className = "progress_bar_chunk";
22 div.style.width = "" + divWidth + "%";
23 this.div.appendChild(div);
27 ProgressBar.prototype.running = function() {
28 return this.is_running;
31 ProgressBar.prototype.getNode = function() {
35 ProgressBar.prototype.next = function() {
38 this.timeoutId = setTimeout( function(){ obj.next(); }, this.interval );
41 ProgressBar.prototype.start = function() {
42 this.is_running = true;
46 ProgressBar.prototype.stop = function() {
47 this.is_running = false;
48 this.current = this.size;
49 clearTimeout(this.timeoutId);
51 for(var i in this.div.childNodes) {
52 this.div.childNodes[i].className = "progress_bar_chunk_active";
55 add_css_class(this.percentDiv, "hide_me");
56 add_css_class(this.div, "progress_bar_done");
57 this.percentDiv.innerHTML = "";
62 ProgressBar.prototype.manualNext = function() {
63 if( this.current == this.size ) {
64 for( var i in this.div.childNodes ) {
65 if(!this.div.childNodes[i])
66 this.div.childNodes[i].className = "progress_bar_chunk";
70 var node = this.div.childNodes[this.current];
71 node.className = "progress_bar_chunk_active";
72 this.current = parseInt(this.current) + 1;
75 this.percentDiv.innerHTML = parseInt((parseInt(this.current) / parseInt(this.size) * 100)) + "%";