/lenasys/0.1

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/0.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*--------------------------------------------------------------------------------
AJAX Queue
----------------------------------------------------------------------------------*/		

var ajaxQueue = new Array;
var ajaxServiceRunning = false;

var httpAjax = false;

/*--------------------------------------------------------------------------------
AjaxService

This is the only interface to the AJAX wrapper. This makes the ajax service 
browser agnostic and provides a single interface for all of the services.

Each service uses a different url and a different parameter layout.
				
----------------------------------------------------------------------------------*/
function AjaxService(servicename, serviceparam) {

	ajaxQueue.push(servicename);
	ajaxQueue.push(serviceparam);

	if(!ajaxServiceRunning) {
		ajaxServiceRunning = true;
		var aParam = ajaxQueue.pop();
		var aService = ajaxQueue.pop();
		ajaxServiceExec(aService, aParam);
	}				
}

/*--------------------------------------------------------------------------------
AjaxService

This is the only interface to the AJAX wrapper. This makes the ajax service 
browser agnostic and provides a single interface for all of the services.

Each service uses a different url and a different parameter layout.
				
----------------------------------------------------------------------------------*/
function ajaxServiceExec(servicename, serviceparam) {

	// Parameters are set, initiate AJAX engine
	if (window.XMLHttpRequest) {
		httpAjax = new XMLHttpRequest();
		if (httpAjax.overrideMimeType) {
			httpAjax.overrideMimeType('text/xml');
		}
	} else if(window.ActiveXObject) {
		try {
			httpAjax = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				httpAjax = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				alert("CouldnŽt build an AJAX instance.");
				return false;
			}
		}
	}

	// Send request to Server and initiate callback.
	try {
		httpAjax.onreadystatechange = getPage;
		httpAjax.open('POST', servicename, true);
		httpAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
		httpAjax.send(serviceparam);		
	} catch(e) {
		//alert("onreadystatechange didnŽt go well!");
		return false;
	}

	return true;

}

/*--------------------------------------------------------------------------------
getPage

This is the AJAX callback function. It detects the invoking service and handles
the reply from each service accordingly.				
		
----------------------------------------------------------------------------------*/
function getPage() {

	if(httpAjax.readyState == 4) { 

		str = httpAjax.responseText;

		if(ajaxQueue.length>0) {
			var Aparam = ajaxQueue.pop();
			var Aservice = ajaxQueue.pop();
			ajaxServiceExec(Aservice, Aparam);
		} else {
			ajaxServiceRunning=false;				
		}

		return true;				
	} else {
	// If any other ready state than prepared, do nothing!
	}
}