All pastes #742906 Raw Edit

Anonymous

public javascript v1 · immutable
·published 2007-10-19 22:26 UTC
rendered paste body
function createRequestObject() {		try {			var browser = navigator.appName;		var ajax;		if(browser == "Microsoft Internet Explorer") {						ajax = new ActiveXObject("Microsoft.XMLHTTP");					} else {						ajax = new XMLHttpRequest();					}				return ajax;		} catch(e) {				alert(e.message);			}}function ProgressBar() {		this.ajax = createRequestObject();	this.url = 'progress.php?key=';	this.self = this;	this.key = document.getElementById('progress_key');	this.container = document.getElementById('progress_container');	this.bar = document.getElementById('progress_bar');	}ProgressBar.prototype.show = function() {		this.container.style.display = 'block';	}ProgressBar.prototype.hide = function() {		this.container.style.display = 'none';	}ProgressBar.prototype.poll = function() {		var a = this;	closure = function() { 		a.update();	}; 			this.ajax.open('get', this.url+this.key);	this.ajax.onreadystatechange = closure;	this.ajax.send(null);}ProgressBar.prototype.update = function() {		if(this.ajax.readyState == 4) {			var result = eval('(' + this.ajax.responseText + ')');				if(result.done != null) {						/** We're done! **/					} else {									setTimeout(this.poll, 500);					}			}	}ProgressBar.prototype.start = function() { 	this.show();	this.poll();	}	function doSubmit() {		progressBar = new ProgressBar();	progressBar.start();	}