2 return document.getElementById(name);
6 function sendRequest(url,callback,postData) {
7 var req = createXMLHTTPObject();
9 var method = (postData) ? "POST" : "GET";
10 req.open(method,url,true);
11 req.setRequestHeader('User-Agent','XMLHTTP/1.0');
13 req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
15 req.onreadystatechange = function () {
16 if(req.readyState != 4) {
20 if (req.status != 200 && req.status != 304) {
21 /* alert('url:' + dbg_url + ' HTTP error ' + req.status); */
22 progress_start_delayed();
27 if (req.readyState == 4) return;
31 var XMLHttpFactories = [
32 function () {return new XMLHttpRequest()},
33 function () {return new ActiveXObject("Msxml2.XMLHTTP")},
34 function () {return new ActiveXObject("Msxml3.XMLHTTP")},
35 function () {return new ActiveXObject("Microsoft.XMLHTTP")}
38 function createXMLHTTPObject() {
40 for (var i=0;i<XMLHttpFactories.length;i++) {
42 xmlhttp = XMLHttpFactories[i]();
53 function progress_start() {
54 sendRequest('~url~', progress_update_with);
57 function progress_start_delayed() {
58 setTimeout(progress_start, 1500);
62 function progress_finished() {
64 tag('wfpl_progress_header').innerHTML = 'Upload Finished';
65 appears = tag('wfpl_upload_finished');
67 appears.style.position = 'static';
69 if(wfpl_upload_finished) {
70 wfpl_upload_finished();
74 function progress_update_with(rec) {
75 length = rec.responseText.length;
76 bar = tag('wfpl_progress_bar');
77 bar.style.backgroundPosition = (Math.floor(length / 5) - 200) + 'px 0';
79 whole = Math.floor(length/10);
80 pct = '' + whole + '.' + (length - (whole * 10));
81 bar.innerHTML = pct + '%';
88 function submitting() {
89 if(wfpl_upload_starting) {
90 wfpl_upload_starting();
92 tag('wfpl_progress_form').style.display = 'none';
93 tag('wfpl_progress_section').style.position = 'static';
94 progress_start_delayed();