1 dump('entering auth/controller.js\n');
3 if (typeof auth == 'undefined') auth = {};
4 auth.controller = function (params) {
5 JSAN.use('util.error'); this.error = new util.error();
6 this.w = params.window;
11 auth.controller.prototype = {
13 'init' : function () {
15 var obj = this; // so the 'this' in event handlers don't confuse us
19 JSAN.use('util.controller'); obj.controller = new util.controller();
35 'cmd_close_window' : [
51 function(e) { return function() {} }
55 function(e) { return function() {} }
60 obj.controller.view.name_prompt.focus();
62 function handle_keypress(ev) {
63 if (ev.keyCode && ev.keyCode == 13) {
65 case obj.controller.view.name_prompt:
67 obj.controller.view.password_prompt.focus(); obj.controller.view.password_prompt.select();
69 case obj.controller.view.password_prompt:
71 obj.controller.view.submit_button.focus();
79 // This talks to our ILS
80 JSAN.use('auth.session');
81 obj.session = new auth.session(obj.controller.view);
83 if (typeof this.on_init == 'function') {
84 this.error.sdump('D_AUTH','auth.controller.on_init()\n');
89 'login' : function() {
93 this.error.sdump('D_AUTH','login with '
94 + this.controller.view.name_prompt.value + ' and '
95 + this.controller.view.password_prompt.value + '\n'
97 this.controller.view.name_prompt.disabled = true;
98 this.controller.view.password_prompt.disabled = true;
99 this.controller.view.submit_button.disabled = true;
103 if (typeof this.on_login == 'function') {
104 this.error.sdump('D_AUTH','auth.controller.session.on_init = ' +
105 'auth.controller.on_login\n');
106 this.session.on_init = this.on_login;
107 this.session.on_error = function() { obj.logoff(); };
113 var error = '!! ' + E + '\n';
114 this.error.sdump('D_ERROR',error);
118 if (typeof this.on_login_error == 'function') {
119 this.error.sdump('D_AUTH','auth.controller.on_login_error()\n');
120 this.on_login_error(E);
125 'logoff' : function() {
127 this.error.sdump('D_AUTH','logoff' + this.w + '\n');
128 this.controller.view.progress_bar.value = 0;
129 this.controller.view.progress_bar.setAttribute('real','0.0');
130 this.controller.view.submit_button.disabled = false;
131 this.controller.view.password_prompt.disabled = false;
132 this.controller.view.password_prompt.value = '';
133 this.controller.view.name_prompt.disabled = false;
134 this.controller.view.name_prompt.focus();
135 this.controller.view.name_prompt.select();
137 this.session.close();
139 if (typeof this.on_logoff == 'function') {
140 this.error.sdump('D_AUTH','auth.controller.on_logoff()\n');
145 'close' : function() {
147 this.error.sdump('D_AUTH','close' + this.w + '\n');
149 //Basically, we want to close all the windows for this application (and in case we're running this as
150 //a firefox extension, we don't want to merely shutdown mozilla). I'll probably create an XPCOM for
151 //tracking the windows.
152 //for (var w in this.G.window.appshell_list) {
153 // this.G.window.appshell_list[w].close();
155 this.w.close(); /* Probably won't go any further */
157 if (typeof this.on_close == 'function') {
158 this.error.sdump('D_AUTH','auth.controller.on_close()\n');
165 dump('exiting auth/controller.js\n');