1 dump('entering auth/controller.js\n');
3 if (typeof auth == 'undefined') auth = {};
4 auth.controller = function (w) {
5 JSAN.use('util.error'); this.error = new util.error();
11 auth.controller.prototype = {
13 'init' : function () {
15 var obj = this; // so the 'this' in event handlers don't confuse us
18 // This talks to our ILS
19 JSAN.use('auth.session');
20 obj.session = new auth.session(obj);
22 // Attach this object to the XUL through event listeners
24 var cmd_login = w.document.getElementById('cmd_login');
26 cmd_login.addEventListener('command',function () { obj.login(); },false);
28 var cmd_logoff = w.document.getElementById('cmd_logoff');
30 cmd_logoff.addEventListener('command',function () { obj.logoff(); },false);
32 var cmd_close_window = w.document.getElementById('cmd_close_window');
34 cmd_close_window.addEventListener('command',function () { obj.close(); },false);
36 obj.view.name_prompt = w.document.getElementById('name_prompt');
37 if (obj.view.name_prompt) {
38 obj.view.name_prompt.addEventListener('keypress',handle_keypress,false);
39 obj.view.name_prompt.focus();
42 obj.view.password_prompt = w.document.getElementById('password_prompt');
43 if (obj.view.password_prompt)
44 obj.view.password_prompt.addEventListener('keypress',handle_keypress,false);
46 obj.view.submit_button = w.document.getElementById('submit_button');
48 obj.view.progress_bar = w.document.getElementById('auth_meter');
50 function handle_keypress(ev) {
51 if (ev.keyCode && ev.keyCode == 13) {
55 obj.view.password_prompt.focus(); obj.view.password_prompt.select();
57 case obj.view.password_prompt:
59 obj.view.submit_button.focus();
67 if (typeof this.on_init == 'function') {
68 this.error.sdump('D_AUTH','auth.controller.on_init()\n');
75 'login' : function() {
77 this.error.sdump('D_AUTH','login with ' + this.view.name_prompt.value + ' and ' + this.view.password_prompt.value + '\n');
78 this.view.name_prompt.disabled = true;
79 this.view.password_prompt.disabled = true;
80 this.view.submit_button.disabled = true;
84 if (typeof this.on_login == 'function') {
85 this.error.sdump('D_AUTH','auth.controller.session.on_init = ' +
86 'auth.controller.on_login\n');
87 this.session.on_init = this.on_login;
93 var error = '!! ' + E + '\n';
94 this.error.sdump('D_ERROR',error);
98 if (typeof this.on_login_error == 'function') {
99 this.error.sdump('D_AUTH','auth.controller.on_login_error()\n');
100 this.on_login_error(E);
105 'logoff' : function() {
107 this.error.sdump('D_AUTH','logoff' + this.w + '\n');
108 this.view.progress_bar.value = 0; this.view.progress_bar.setAttribute('real','0.0');
109 this.view.submit_button.disabled = false;
110 this.view.password_prompt.disabled = false;
111 this.view.password_prompt.value = '';
112 this.view.name_prompt.disabled = false;
113 this.view.name_prompt.focus(); this.view.name_prompt.select();
115 this.session.close();
117 if (typeof this.on_logoff == 'function') {
118 this.error.sdump('D_AUTH','auth.controller.on_logoff()\n');
123 'close' : function() {
125 this.error.sdump('D_AUTH','close' + this.w + '\n');
127 for (var w in this.G.window.appshell_list) {
128 this.G.window.appshell_list[w].close();
130 this.w.close(); /* Probably won't go any further */
132 if (typeof this.on_close == 'function') {
133 this.error.sdump('D_AUTH','auth.controller.on_close()\n');
140 dump('exiting auth/controller.js\n');