Subversion Repositories ALCASAR

Rev

Rev 788 | Rev 2097 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

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