Subversion Repositories ALCASAR

Rev

Rev 528 | Rev 764 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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

Generated by GNU Enscript 1.6.6.
-
 
237
 
-
 
238
 
-
 
239
 
-