Subversion Repositories ALCASAR

Rev

Rev 503 | Rev 528 | 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 () { }
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
/* Action triggered when buttons are pressed */
106
function connect() {
107
    var username =  document.getElementById('username').value ;
108
    var password =  document.getElementById('password').value ;
109
 
110
    if (username == null || username == '')
111
	return setElementValue('logonMessage', 'Username is required');
112
 
113
    showWaitPage(1000);
114
    chilliController.logon( username , password ) ;
115
}
116
 
117
function disconnect() {
118
    if (confirm("Are you sure you want to disconnect now?")) {
119
	chilliClock.stop();
120
	showWaitPage(1000);
121
	chilliController.logoff();
122
    }
123
    return false;
124
}
125
 
126
/* User interface pages update */
127
function showLoggedOutPage() {
128
    showPage("loggedOutPage");
129
    hidePage("statusPage");
130
    hidePage("waitPage");
131
    hidePage("errorPage");
132
    window.setTimeout("closePopup()",1000);
133
}
134
 
135
function showStatusPage() {
136
    hidePage("loggedOutPage");
137
    showPage("statusPage");
138
    hidePage("waitPage");
139
    hidePage("errorPage");
140
 
141
    // Update message
142
    if ( chilliController.message ) { 
143
	setElementValue("statusMessage", chilliController.message);
144
    }
145
 
146
    // Update session
147
    setElementValue("sessionId",
148
		    chilliController.session.sessionId ?
149
		    chilliController.session.sessionId :
150
		    "Not available");
151
 
152
	setElementValue("userName",
153
		    chilliController.session.userName ?
154
		    chilliController.session.userName :
155
		    "Not available");
156
 
157
    setElementValue("startTime",
158
		    chilliController.session.startTime ?
159
		    chilliController.session.startTime.toLocaleString() :
160
		    "Not available");
161
 
162
    setElementValue("sessionTimeout",
163
		    chilliController.formatTime(chilliController.session.sessionTimeout, 'unlimited'));
164
 
165
    setElementValue("idleTimeout",
166
		    chilliController.formatTime(chilliController.session.idleTimeout, 'unlimited'));
167
 
168
    setElementValue("maxInputOctets",
169
		    chilliController.formatBytes(chilliController.session.maxInputOctets));
170
    setElementValue("maxOutputOctets",
171
		    chilliController.formatBytes(chilliController.session.maxOutputOctets));
172
    setElementValue("maxTotalOctets",
173
		    chilliController.formatBytes(chilliController.session.maxTotalOctets));
174
 
175
    // Update accounting
176
    setElementValue("sessionTime",
177
		    chilliController.formatTime(chilliController.accounting.sessionTime));
178
 
179
    setElementValue("idleTime",
180
		    chilliController.formatTime(chilliController.accounting.idleTime));
181
 
182
    setElementValue("inputOctets" , chilliController.formatBytes(chilliController.accounting.inputOctets));
183
    setElementValue("outputOctets", chilliController.formatBytes(chilliController.accounting.outputOctets));
184
 
185
    chilliClock.resync (chilliController.accounting.sessionTime);
186
}
187
 
188
function showWaitPage(delay) {
189
    /* Wait for delay  */
190
    clearTimeout(delayTimer);	
191
    if (typeof(delay) == 'number' && (delay > 10)) {
192
	delayTimer= setTimeout('showWaitPage(0)' , delay);
193
	return;
194
    }
195
 
196
    /* show the waitPage */
197
    hidePage("loggedOutPage");
198
    hidePage("statusPage");
199
    showPage("waitPage");
200
    hidePage("errorPage");
201
}
202
 
203
function showErrorPage( str )  {
204
    setTimeout('chilliController.refresh()', 15000);
205
 
206
    hidePage("loggedOutPage");
207
    hidePage("statusPage");
208
    hidePage("waitPage");
209
    showPage("errorPage");
210
    setElementValue("errorMessage", str);
211
}
212
 
213
var chillijsWindowOnLoad = window.onload;
214
var delayTimer; // global reference to delayTimer
215
 
216
window.onload = function() {
217
    if (chillijsWindowOnLoad) 
218
	chillijsWindowOnLoad();
219
 
220
    //var logonForm = document.getElementById('logonForm');
221
	var logonForm = document.getElementById('loggedOutPage');
222
 
223
    var head = document.getElementsByTagName("head")[0];
224
    if (head == null) head = document.body;
225
 
226
    if (logonForm == null) {
227
        logonForm = document.getElementById('loginForm');
228
    }
229
    showWaitPage(); 
230
    setTimeout('chilliController.refresh()', 500);
231
}