Subversion Repositories ALCASAR

Rev

Rev 2370 | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
514 richard 1
chilliController.interval = 20;
484 stephane 2
chilliController.onUpdate = updateUI ;
3
chilliController.onError  = handleError ;
4
chilliClock.onTick = function () { }
537 stephane 5
 
528 stephane 6
var isloggedout = false;
484 stephane 7
 
8
if (!window.queryObj) {
9
    window.queryObj = new Object();
10
    window.location.search.replace(new RegExp("([^?=&]+)(=([^&]*))?","g"), function($0,$1,$2,$3) { queryObj[$1] = $3; });
11
}
12
 
13
chilliController.queryObj = window.queryObj;
14
 
15
function ie_getElementsByTagName(str) {
16
  if (str=="*") return document.all;
17
  else return document.all.tags(str);
18
}
19
 
20
if (document.all) 
21
  document.getElementsByTagName = ie_getElementsByTagName;
22
 
23
function hidePage(page) { 
24
    var e = document.getElementById(page);
25
    if (e != null) e.style.display='none';
26
}
27
 
28
function showPage(page) { 
29
    var e = document.getElementById(page);
30
    if (e != null) e.style.display='inline';
31
}
32
 
33
function setElementValue(elem, val, forceHTML) {
34
    var e = document.getElementById(elem);
35
    if (e != null) {
36
	var node = e;
37
	if (!forceHTML && node.firstChild) {
38
	    node = node.firstChild;
39
	    node.nodeValue = val;
40
	} else {
41
	    node.innerHTML = val;
42
	}
43
    }
44
}
45
 
46
chilliClock.onChange = function ( newval ) {
47
    setElementValue("sessionTime", chilliController.formatTime(newval));
48
}
49
 
50
function updateUI (cmd ) {
51
    log ( "Update UI is called. chilliController.clientState = " + chilliController.clientState ) ; 
52
 
53
    clearTimeout ( delayTimer );
54
 
55
    if ( chilliController.redir ) {
56
	if (chilliController.redir.originalURL != null &&
57
	    chilliController.redir.originalURL != '') {
58
	    setElementValue('originalURL', '<a target="_blank" href="'+chilliController.redir.originalURL+
59
			    '">'+chilliController.redir.originalURL+'</a>', true);
60
	}
61
	if (chilliController.redir.redirectionURL != null &&
62
	    chilliController.redir.redirectionURL != '') {
63
	    setElementValue('redirectionURL', chilliController.redir.redirectionURL);
64
	}
65
    }
66
 
67
    if ( chilliController.message ) {
68
	setElementValue('logonMessage', chilliController.message);
69
	chilliController.message = null;
70
	chilliController.refresh();
71
    }
72
 
73
    if ( chilliController.location ) {
74
	setElementValue('locationName', chilliController.location.name);
75
	chilliController.location = null;
76
    }
77
 
78
    if ( chilliController.clientState == 0 ) {
79
        showLoggedOutPage();
80
		setTimeout('chilliController.refresh()', 1000*chilliController.interval);//WBR for status page only
81
    }
82
 
83
    if ( chilliController.clientState == 1 ) {
84
        if ( chilliController.statusURL ) {
85
			chilliController.statusWindow = window.open(chilliController.statusURL, "");
86
		} else {
87
			showStatusPage();
88
        }
89
    }
90
 
91
    if (chilliController.redir.redirectionURL) {
92
	//chilliController.nextWindow = window.open(chilliController.redir.redirectionURL,'nextURL');
93
	window.location.href = chilliController.redir.redirectionURL;
94
	chilliController.redir.redirectionURL = null;
95
    }
96
 
97
    if ( chilliController.clientState == 2 ) showWaitPage();
98
}
99
 
100
function handleError( code ) {
101
    clearTimeout(delayTimer);
102
    //showErrorPage(code);
103
}
104
 
105
/* User interface pages update */
106
function showLoggedOutPage() {
528 stephane 107
	isloggedout = true;
484 stephane 108
    showPage("loggedOutPage");
109
    hidePage("statusPage");
110
    hidePage("waitPage");
111
    hidePage("errorPage");
112
    window.setTimeout("closePopup()",1000);
113
}
114
 
115
function showStatusPage() {
528 stephane 116
	isloggedout = false;
484 stephane 117
    hidePage("loggedOutPage");
118
    showPage("statusPage");
119
    hidePage("waitPage");
120
    hidePage("errorPage");
121
 
2883 rexy 122
    //We check if user is still connected while he gets 'still_connected.php'
2097 raphael.pi 123
    var xhttp = new XMLHttpRequest();
124
    xhttp.open('GET','still_connected.php',true);
125
    xhttp.send();
126
 
484 stephane 127
    // Update message
128
    if ( chilliController.message ) { 
129
	setElementValue("statusMessage", chilliController.message);
130
    }
131
 
132
    // Update session
133
    setElementValue("sessionId",
134
		    chilliController.session.sessionId ?
135
		    chilliController.session.sessionId :
136
		    "Not available");
137
 
138
	setElementValue("userName",
139
		    chilliController.session.userName ?
140
		    chilliController.session.userName :
141
		    "Not available");
142
 
143
    setElementValue("startTime",
144
		    chilliController.session.startTime ?
145
		    chilliController.session.startTime.toLocaleString() :
146
		    "Not available");
147
 
148
    setElementValue("sessionTimeout",
149
		    chilliController.formatTime(chilliController.session.sessionTimeout, 'unlimited'));
150
 
151
    setElementValue("idleTimeout",
152
		    chilliController.formatTime(chilliController.session.idleTimeout, 'unlimited'));
153
 
154
    setElementValue("maxInputOctets",
155
		    chilliController.formatBytes(chilliController.session.maxInputOctets));
156
    setElementValue("maxOutputOctets",
157
		    chilliController.formatBytes(chilliController.session.maxOutputOctets));
158
    setElementValue("maxTotalOctets",
159
		    chilliController.formatBytes(chilliController.session.maxTotalOctets));
160
 
161
    // Update accounting
162
    setElementValue("sessionTime",
163
		    chilliController.formatTime(chilliController.accounting.sessionTime));
164
 
165
    setElementValue("idleTime",
166
		    chilliController.formatTime(chilliController.accounting.idleTime));
167
 
168
    setElementValue("inputOctets" , chilliController.formatBytes(chilliController.accounting.inputOctets));
169
    setElementValue("outputOctets", chilliController.formatBytes(chilliController.accounting.outputOctets));
170
 
171
    chilliClock.resync (chilliController.accounting.sessionTime);
172
}
173
 
174
function showWaitPage(delay) {
175
    /* Wait for delay  */
176
    clearTimeout(delayTimer);	
177
    if (typeof(delay) == 'number' && (delay > 10)) {
178
	delayTimer= setTimeout('showWaitPage(0)' , delay);
179
	return;
180
    }
181
 
182
    /* show the waitPage */
183
    hidePage("loggedOutPage");
184
    hidePage("statusPage");
185
    showPage("waitPage");
186
    hidePage("errorPage");
187
}
188
 
189
function showErrorPage( str )  {
190
    setTimeout('chilliController.refresh()', 15000);
191
 
192
    hidePage("loggedOutPage");
193
    hidePage("statusPage");
194
    hidePage("waitPage");
195
    showPage("errorPage");
196
    setElementValue("errorMessage", str);
197
}
198
 
537 stephane 199
function closePopup(){
200
	this.focus();
201
	self.opener=this;
202
	self.close();
203
}
204
function alcasarLogoff(){
205
	if (isloggedout == false){
206
  		chilliClock.stop();
207
		chilliController.logoff();
208
	}
209
	showWaitPage(1000);
210
	isloggedout = true;
211
}
212
function logout() {
213
	alcasarLogoff();
214
	window.setTimeout("closePopup()",1000);
215
}
216
function logoutWithConfirmation(msg) {
217
	if (confirm(msg)) {
218
		logout();
219
	}
220
return false;
221
}
222
 
484 stephane 223
var chillijsWindowOnLoad = window.onload;
224
var delayTimer; // global reference to delayTimer
225
 
226
window.onload = function() {
227
    if (chillijsWindowOnLoad) 
228
	chillijsWindowOnLoad();
229
 
230
    var head = document.getElementsByTagName("head")[0];
231
    if (head == null) head = document.body;
232
 
233
    showWaitPage(); 
764 stephane 234
    setTimeout('chilliController.refresh()', 1500);
537 stephane 235
}
236