bzr branch
http://gegoxaren.bato24.eu/bzr/lenasys/trunk
1
by Henrik G.
First seed of Lenasys ... Needs to be Organized Further |
1 |
/*--------------------------------------------------------------------------------
|
4.8.1
by galaxyAbstractor
Cleaned up shitty code |
2 |
AJAX Queue
|
3 |
----------------------------------------------------------------------------------*/ |
|
4 |
||
5 |
var ajaxQueue = new Array; |
|
6 |
var ajaxServiceRunning = false; |
|
7 |
||
8 |
var httpAjax = false; |
|
9 |
||
10 |
/*--------------------------------------------------------------------------------
|
|
11 |
AjaxService
|
|
12 |
||
13 |
This is the only interface to the AJAX wrapper. This makes the ajax service
|
|
14 |
browser agnostic and provides a single interface for all of the services.
|
|
15 |
||
16 |
Each service uses a different url and a different parameter layout.
|
|
17 |
|
|
18 |
----------------------------------------------------------------------------------*/
|
|
19 |
function AjaxService(servicename, serviceparam) { |
|
20 |
||
21 |
ajaxQueue.push(servicename); |
|
22 |
ajaxQueue.push(serviceparam); |
|
23 |
||
24 |
if(!ajaxServiceRunning) { |
|
25 |
ajaxServiceRunning = true; |
|
26 |
var aParam = ajaxQueue.pop(); |
|
27 |
var aService = ajaxQueue.pop(); |
|
28 |
ajaxServiceExec(aService, aParam); |
|
29 |
} |
|
30 |
}
|
|
31 |
||
32 |
/*--------------------------------------------------------------------------------
|
|
33 |
AjaxService
|
|
34 |
||
35 |
This is the only interface to the AJAX wrapper. This makes the ajax service
|
|
36 |
browser agnostic and provides a single interface for all of the services.
|
|
37 |
||
38 |
Each service uses a different url and a different parameter layout.
|
|
39 |
|
|
40 |
----------------------------------------------------------------------------------*/
|
|
41 |
function ajaxServiceExec(servicename, serviceparam) { |
|
42 |
||
43 |
// Parameters are set, initiate AJAX engine |
|
44 |
if (window.XMLHttpRequest) { |
|
45 |
httpAjax = new XMLHttpRequest(); |
|
46 |
if (httpAjax.overrideMimeType) { |
|
47 |
httpAjax.overrideMimeType('text/xml'); |
|
48 |
} |
|
49 |
} else if(window.ActiveXObject) { |
|
50 |
try { |
|
51 |
httpAjax = new ActiveXObject("Msxml2.XMLHTTP"); |
|
52 |
} catch(e) { |
|
53 |
try { |
|
54 |
httpAjax = new ActiveXObject("Microsoft.XMLHTTP"); |
|
55 |
} catch(e) { |
|
56 |
alert("CouldnŽt build an AJAX instance."); |
|
57 |
return false; |
|
58 |
} |
|
59 |
} |
|
60 |
} |
|
61 |
||
62 |
// Send request to Server and initiate callback. |
|
63 |
try { |
|
64 |
httpAjax.onreadystatechange = getPage; |
|
65 |
httpAjax.open('POST', servicename, true); |
|
66 |
httpAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;"); |
|
67 |
httpAjax.send(serviceparam); |
|
68 |
} catch(e) { |
|
69 |
//alert("onreadystatechange didnŽt go well!"); |
|
70 |
return false; |
|
71 |
} |
|
72 |
||
73 |
return true; |
|
74 |
||
75 |
}
|
|
76 |
||
77 |
/*--------------------------------------------------------------------------------
|
|
78 |
getPage
|
|
79 |
||
80 |
This is the AJAX callback function. It detects the invoking service and handles
|
|
81 |
the reply from each service accordingly.
|
|
82 |
|
|
83 |
----------------------------------------------------------------------------------*/
|
|
84 |
function getPage() { |
|
85 |
||
86 |
if(httpAjax.readyState == 4) { |
|
87 |
||
88 |
str = httpAjax.responseText; |
|
89 |
||
90 |
if(ajaxQueue.length>0) { |
|
91 |
var Aparam = ajaxQueue.pop(); |
|
92 |
var Aservice = ajaxQueue.pop(); |
|
93 |
ajaxServiceExec(Aservice, Aparam); |
|
94 |
} else { |
|
95 |
ajaxServiceRunning=false; |
|
96 |
} |
|
97 |
||
98 |
return true; |
|
99 |
} else { |
|
100 |
// If any other ready state than prepared, do nothing! |
|
101 |
} |
|
102 |
}
|
|
103 |
||
1
by Henrik G.
First seed of Lenasys ... Needs to be Organized Further |
104 |