Don't feed big G to the objects hanging off of G if we don't have to. But can I...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 31 Oct 2005 22:01:04 +0000 (22:01 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 31 Oct 2005 22:01:04 +0000 (22:01 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@1927 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/evergreen/OpenILS/data.js
Open-ILS/xul/staff_client/chrome/content/evergreen/auth/controller.js
Open-ILS/xul/staff_client/chrome/content/evergreen/auth/session.js
Open-ILS/xul/staff_client/chrome/content/evergreen/main/main.js
Open-ILS/xul/staff_client/chrome/content/evergreen/main/network.js
Open-ILS/xul/staff_client/chrome/content/evergreen/main/window.js
Open-ILS/xul/staff_client/chrome/content/evergreen/util/error.js
Open-ILS/xul/staff_client/chrome/content/evergreen/util/file.js
Open-ILS/xul/staff_client/defaults/preferences/evergreen.js

index 60294b5..686c47f 100644 (file)
@@ -1,9 +1,12 @@
 dump('entering OpenILS/data.js\n');
 
 if (typeof OpenILS == 'undefined') OpenILS = {};
-OpenILS.data = function (mw,G) {
+OpenILS.data = function (auth) {
 
-       this.mw = mw; this.G = G;
+       this.auth = auth;
+
+       JSAN.use('util.error'); this.error = new util.error();
+       JSAN.use('main.network'); this.network = new main.network();
 
        var obj = this;
 
@@ -25,17 +28,17 @@ OpenILS.data = function (mw,G) {
                                        }
                                } catch(E) {
 
-                                       obj.G.error.sdump('D_ERROR',E + '\n');
+                                       obj.error.sdump('D_ERROR',E + '\n');
                                }
 
                        }
 
                        try {
-                               obj.list[classname] = obj.G.network.request( app, method, params);
+                               obj.list[classname] = obj.network.request( app, method, params);
                                convert();
                                // if cacheable, store an offline copy
                                if (cacheable) {
-                                       var file = new util.file( obj.mw, obj.G, classname );
+                                       var file = new util.file( classname );
                                        file.set_object( obj.list[classname] );
                                }
 
@@ -43,7 +46,7 @@ OpenILS.data = function (mw,G) {
                                // if cacheable, try offline
                                if (cacheable) {
                                        try {
-                                               var file = new util.file( obj.mw, obj.G, classname );
+                                               var file = new util.file( classname );
                                                obj.list[classname] = file.get_object();
                                                convert();
                                        } catch(E) {
@@ -65,7 +68,7 @@ OpenILS.data = function (mw,G) {
                                [
                                        'open-ils.search',
                                        'open-ils.search.actor.user.session',
-                                       [ obj.G.auth.session.key ],
+                                       [ obj.auth.session.key ],
                                        false
                                ]
                        );
@@ -79,7 +82,7 @@ OpenILS.data = function (mw,G) {
                }
        );
 
-       obj.G.error.sdump('D_DEBUG','_fm_objects = ' + js2JSON(this._fm_objects) + '\n');
+       obj.error.sdump('D_DEBUG','_fm_objects = ' + js2JSON(this._fm_objects) + '\n');
 
        for (var i in this._fm_objects) {
                this.chain.push( gen_fm_retrieval_func(i,this._fm_objects[i]) );
@@ -99,7 +102,7 @@ OpenILS.data = function (mw,G) {
                        [ 
                                'open-ils.actor', 
                                'open-ils.actor.org_unit.full_path.retrieve', 
-                               [ obj.G.auth.session.key ],
+                               [ obj.auth.session.key ],
                                true
                        ]
                )
@@ -114,7 +117,7 @@ OpenILS.data = function (mw,G) {
                                [ 
                                        'open-ils.circ', 
                                        'open-ils.circ.stat_cat.actor.retrieve.all', 
-                                       [ obj.G.auth.session.key, obj.list.au.home_ou() ],
+                                       [ obj.auth.session.key, obj.list.au.home_ou() ],
                                        true
                                ]
                        )();
index fedac66..72ae91b 100644 (file)
@@ -1,9 +1,9 @@
 dump('entering auth/controller.js\n');
 
 if (typeof auth == 'undefined') auth = {};
-auth.controller = function (mw,G) {
-
-       this.mw = mw; this.G = G;
+auth.controller = function (w) {
+       JSAN.use('util.error'); this.error = new util.error();
+       this.w = w;
 
        return this;
 };
@@ -13,40 +13,39 @@ auth.controller.prototype = {
        'init' : function () {
 
                var obj = this;  // so the 'this' in event handlers don't confuse us
-               var mw = obj.mw;
-               var G = obj.G;
+               var w = obj.w;
 
                // This talks to our ILS
                JSAN.use('auth.session');
-               obj.session = new auth.session(obj,mw,G);
+               obj.session = new auth.session(obj);
 
                // Attach this object to the XUL through event listeners
 
-               var cmd_login = mw.document.getElementById('cmd_login');
+               var cmd_login = w.document.getElementById('cmd_login');
                        if (cmd_login) 
                                cmd_login.addEventListener('command',function () { obj.login(); },false);
 
-               var cmd_logoff = mw.document.getElementById('cmd_logoff');
+               var cmd_logoff = w.document.getElementById('cmd_logoff');
                        if (cmd_logoff) 
                                cmd_logoff.addEventListener('command',function () { obj.logoff(); },false);
 
-               var cmd_close_window = mw.document.getElementById('cmd_close_window');
+               var cmd_close_window = w.document.getElementById('cmd_close_window');
                        if (cmd_close_window) 
                                cmd_close_window.addEventListener('command',function () { obj.close(); },false);
 
-               obj.view.name_prompt = mw.document.getElementById('name_prompt');
+               obj.view.name_prompt = w.document.getElementById('name_prompt');
                        if (obj.view.name_prompt) {
                                obj.view.name_prompt.addEventListener('keypress',handle_keypress,false);
                                obj.view.name_prompt.focus();
                        }
 
-               obj.view.password_prompt = mw.document.getElementById('password_prompt');
+               obj.view.password_prompt = w.document.getElementById('password_prompt');
                        if (obj.view.password_prompt)
                                obj.view.password_prompt.addEventListener('keypress',handle_keypress,false);
        
-               obj.view.submit_button = mw.document.getElementById('submit_button');
+               obj.view.submit_button = w.document.getElementById('submit_button');
        
-               obj.view.progress_bar = mw.document.getElementById('auth_meter');
+               obj.view.progress_bar = w.document.getElementById('auth_meter');
 
                function handle_keypress(ev) {
                        if (ev.keyCode && ev.keyCode == 13) {
@@ -66,7 +65,7 @@ auth.controller.prototype = {
                }
 
                if (typeof this.on_init == 'function') {
-                       this.G.error.sdump('D_AUTH','auth.controller.on_init()\n');
+                       this.error.sdump('D_AUTH','auth.controller.on_init()\n');
                        this.on_init();
                }
        },
@@ -75,7 +74,7 @@ auth.controller.prototype = {
 
        'login' : function() { 
 
-               this.G.error.sdump('D_AUTH','login with ' + this.view.name_prompt.value + ' and ' + this.view.password_prompt.value + '\n'); 
+               this.error.sdump('D_AUTH','login with ' + this.view.name_prompt.value + ' and ' + this.view.password_prompt.value + '\n'); 
                this.view.name_prompt.disabled = true;
                this.view.password_prompt.disabled = true;
                this.view.submit_button.disabled = true;
@@ -83,7 +82,7 @@ auth.controller.prototype = {
                try {
 
                        if (typeof this.on_login == 'function') {
-                               this.G.error.sdump('D_AUTH','auth.controller.session.on_init = ' +
+                               this.error.sdump('D_AUTH','auth.controller.session.on_init = ' +
                                        'auth.controller.on_login\n');
                                this.session.on_init = this.on_login;
                        }
@@ -92,12 +91,12 @@ auth.controller.prototype = {
 
                } catch(E) {
                        var error = '!! ' + E + '\n';
-                       this.G.error.sdump('D_ERROR',error); 
+                       this.error.sdump('D_ERROR',error); 
                        alert(error);
                        this.logoff();
 
                        if (typeof this.on_login_error == 'function') {
-                               this.G.error.sdump('D_AUTH','auth.controller.on_login_error()\n');
+                               this.error.sdump('D_AUTH','auth.controller.on_login_error()\n');
                                this.on_login_error(E);
                        }
                }
@@ -105,7 +104,7 @@ auth.controller.prototype = {
        },
        'logoff' : function() { 
        
-               this.G.error.sdump('D_AUTH','logoff' + this.mw + '\n'); 
+               this.error.sdump('D_AUTH','logoff' + this.w + '\n'); 
                this.view.progress_bar.value = 0; this.view.progress_bar.setAttribute('real','0.0');
                this.view.submit_button.disabled = false;
                this.view.password_prompt.disabled = false;
@@ -116,22 +115,22 @@ auth.controller.prototype = {
                this.session.close();
 
                if (typeof this.on_logoff == 'function') {
-                       this.G.error.sdump('D_AUTH','auth.controller.on_logoff()\n');
+                       this.error.sdump('D_AUTH','auth.controller.on_logoff()\n');
                        this.on_logoff();
                }
                
        },
        'close' : function() { 
        
-               this.G.error.sdump('D_AUTH','close' + this.mw + '\n');
+               this.error.sdump('D_AUTH','close' + this.w + '\n');
                this.logoff();
                for (var w in this.G.window.appshell_list) {
                        this.G.window.appshell_list[w].close();
                }
-               this.mw.close(); /* Probably won't go any further */
+               this.w.close(); /* Probably won't go any further */
 
                if (typeof this.on_close == 'function') {
-                       this.G.error.sdump('D_AUTH','auth.controller.on_close()\n');
+                       this.error.sdump('D_AUTH','auth.controller.on_close()\n');
                        this.on_close();
                }
                
index ada09b5..8904589 100644 (file)
@@ -1,9 +1,11 @@
 dump('entering auth/session.js\n');
 
 if (typeof auth == 'undefined') auth = {};
-auth.session = function (controller,mw,G) {
+auth.session = function (controller) {
 
-       this.mw = mw; this.G = G; this.controller = controller;
+       JSAN.use('util.error'); this.error = new util.error();
+       JSAN.use('main.network'); this.network = new main.network();
+       this.controller = controller;
 
        return this;
 };
@@ -13,7 +15,7 @@ auth.session.prototype = {
        'init' : function () {
 
                try {
-                       var init = this.G.network.request(
+                       var init = this.network.request(
                                'open-ils.auth',
                                'open-ils.auth.authenticate.init',
                                [ this.controller.view.name_prompt.value ]
@@ -21,7 +23,7 @@ auth.session.prototype = {
 
                        if (init) {
 
-                               this.key = this.G.network.request(
+                               this.key = this.network.request(
                                        'open-ils.auth',
                                        'open-ils.auth.authenticate.complete',
                                        [ 
@@ -35,7 +37,7 @@ auth.session.prototype = {
                                        ]
                                );
 
-                               this.G.error.sdump('D_AUTH','auth.session.key = ' + this.key + '\n');
+                               this.error.sdump('D_AUTH','auth.session.key = ' + this.key + '\n');
 
                                if (Number(this.key) == 0) {
                                        throw('Invalid name/password combination.');
@@ -44,30 +46,30 @@ auth.session.prototype = {
                                }
 
                                if (typeof this.on_init == 'function') {
-                                       this.G.error.sdump('D_AUTH','auth.session.on_init()\n');
+                                       this.error.sdump('D_AUTH','auth.session.on_init()\n');
                                        this.on_init();
                                }
 
                        } else {
 
                                var error = 'open-ils.auth.authenticate.init returned false\n';
-                               this.G.error.sdump('D_ERROR',error);
+                               this.error.sdump('D_ERROR',error);
                                this.controller.logoff();
                                throw(error);
                        }
 
                } catch(E) {
                        var error = 'Error on auth.session.init(): ' + E + '\n';
-                       this.G.error.sdump('D_ERROR',error); 
+                       this.error.sdump('D_ERROR',error); 
 
                        if (typeof this.on_init_error == 'function') {
-                               this.G.error.sdump('D_AUTH','auth.session.on_init_error()\n');
+                               this.error.sdump('D_AUTH','auth.session.on_init_error()\n');
                                this.on_init_error(E);
                        }
 
                        //throw(E);
                        if (typeof this.on_init == 'function') {
-                               this.G.error.sdump('D_AUTH','auth.session.on_init() despite error\n');
+                               this.error.sdump('D_AUTH','auth.session.on_init() despite error\n');
                                this.on_init();
                        }
                }
@@ -75,10 +77,10 @@ auth.session.prototype = {
        },
 
        'close' : function () { 
-               this.G.error.sdump('D_AUTH','auth.session.close()\n'); 
+               this.error.sdump('D_AUTH','auth.session.close()\n'); 
                this.key = null;
                if (typeof this.G.on_close == 'function') {
-                       this.G.error.sdump('D_AUTH','auth.session.on_close()\n');
+                       this.error.sdump('D_AUTH','auth.session.on_close()\n');
                        this.G.on_close();
                }
        }
index e4b8d4c..9790ed1 100644 (file)
@@ -21,15 +21,14 @@ function main_init() {
                G.OpenSRF = {};
 
                JSAN.use('util.error');
-               G.error = new util.error( mw, G );
+               G.error = new util.error();
                G.error.sdump('D_ERROR','Testing');
-               dump('direct dump\n');
 
                JSAN.use('main.window');
-               G.window = new main.window( mw, G );
+               G.window = new main.window();
 
                JSAN.use('main.network');
-               G.network = new main.network( mw, G );
+               G.network = new main.network();
 
                G.test_array = [ "a", "b", "c" ];
                G.test_object = { "a" : "b", "c" : "d", "e" : "f" };
@@ -38,16 +37,15 @@ function main_init() {
                }
 
                JSAN.use('auth.controller');
-               G.auth = new auth.controller( mw, G );
+               G.auth = new auth.controller( mw );
 
                G.auth.on_login = function() {
 
                        JSAN.use('OpenILS.data');
-                       G.OpenILS.data = new OpenILS.data( mw, G );
+                       G.OpenILS.data = new OpenILS.data( G.auth );
                        G.OpenILS.data.on_complete = function () {
 
-                               alert('test');
-                               //G.window.open('http://gapines.org/xul/server/test.xul','test','chrome');
+                               G.window.open('http://gapines.org/xul/server/test.xul','test','chrome');
                        }
                        G.OpenILS.data.init();
                }
index 36e5831..3573802 100644 (file)
@@ -1,10 +1,9 @@
 dump('entering main/network.js\n');
 
 if (typeof main == 'undefined') main = {};
-main.network = function (mw,G) {
-
-       this.mw = mw; this.G = G;
+main.network = function () {
 
+       JSAN.use('util.error'); this.error = new util.error();
        // Place a test here for network connectivity
        // this.offline = true;
 
@@ -20,7 +19,7 @@ main.network.prototype = {
 
                try {
 
-                       this.G.error.sdump('D_SES','=-=-=-=-= user_request("'+app+'","'+name+'",'+js2JSON(params)+')\n');
+                       this.error.sdump('D_SES','=-=-=-=-= user_request("'+app+'","'+name+'",'+js2JSON(params)+')\n');
                        var request = new RemoteRequest( app, name );
                        for(var index in params) {
                                request.addParam(params[index]);
@@ -29,12 +28,12 @@ main.network.prototype = {
                        if (f)  {
                                request.setCompleteCallback(f);
                                request.send(false);
-                               this.G.error.sdump('D_SES_RESULT','=-=-= result asynced\n');
+                               this.error.sdump('D_SES_RESULT','=-=-= result asynced\n');
                                return null;
                        } else {
                                request.send(true);
                                var result = request.getResultObject();
-                               this.G.error.sdump('D_SES_RESULT','=-=-= result = ' + js2JSON(result) + '\n');
+                               this.error.sdump('D_SES_RESULT','=-=-= result = ' + js2JSON(result) + '\n');
                                return result;
                        }
 
index 8ce5d4d..34fd48f 100644 (file)
@@ -1,16 +1,13 @@
 dump('entering main/window.js\n');
 
 if (typeof main == 'undefined') main = {};
-main.window = function (mw,G) {
-       this.main_window = mw; this.mw = mw; this.G = G;
+main.window = function () {
+       JSAN.use('util.error'); this.error = new util.error();
        return this;
 };
 
 main.window.prototype = {
        
-       // pointer to the auth window
-       'main_window' : null,   
-
        // list of open window references, used for debugging in shell
        'win_list' : [],        
 
@@ -44,7 +41,7 @@ main.window.prototype = {
 
                        w = window.open(url,title,features);
                } catch(E) {
-                       this.G.error.sdump('D_ERROR','window.SafeWindowOpen: ' + E + '\n');
+                       this.error.sdump('D_ERROR','window.SafeWindowOpen: ' + E + '\n');
                        throw(E);
                }
                if(blocked) PB.setBoolPref("dom.disable_open_during_load",true);
@@ -53,10 +50,9 @@ main.window.prototype = {
        },
 
        'open' : function(url,title,features) {
-               this.G.error.sdump('D_WIN',
+               this.error.sdump('D_WIN',
                        'opening ' + url + ', ' + title + ', ' + features + ' from ' + window + '\n');
                var w = this.SafeWindowOpen(url,title,features);
-               w.mw = this.mw; w.G = this.G;
                /*
                setTimeout( 
                        function() { 
index f336f30..9f30733 100644 (file)
@@ -1,7 +1,7 @@
 dump('entering util/error.js\n');
 
 if (typeof util == 'undefined') util = {};
-util.error = function (mw,G) {
+util.error = function () {
 
        this.consoleService = Components.classes['@mozilla.org/consoleservice;1']
                .getService(Components.interfaces.nsIConsoleService);
index 9bfaf57..7c6d333 100644 (file)
@@ -1,9 +1,9 @@
 dump('entering util/file.js\n');
 
 if (typeof util == 'undefined') util = {};
-util.file = function (mw,G,fname) {
+util.file = function (fname) {
 
-       this.mw = mw; this.G = G;
+       JSAN.use('util.error'); this.error = new util.error();
 
        this.dirService = Components.classes["@mozilla.org/file/directory_service;1"].
                getService( Components.interfaces.nsIProperties );
@@ -15,6 +15,8 @@ util.file = function (mw,G,fname) {
 
 util.file.prototype = {
 
+       'myPackageDir' : 'evergreen',
+
        'name' : '',
        '_file' : null,
        '_input_stream' : null,
@@ -26,17 +28,17 @@ util.file.prototype = {
                        if (!fname) throw('Must specify a filename.');
 
                        this._file = this.dirService.get( "AChrom",  Components.interfaces.nsIFile );
-                       this._file.append(this.mw.myPackageDir); 
+                       this._file.append(myPackageDir); 
                        this._file.append("content"); 
                        this._file.append("conf"); 
                        this._file.append(fname);
        
-                       this.G.error.sdump('D_FILE',this._file.path);
+                       this.error.sdump('D_FILE',this._file.path);
 
                        return this._file;
 
                } catch(E) {
-                       this.G.error.sdump('D_ERROR','util.file.get(): ' + E);
+                       this.error.sdump('D_ERROR','util.file.get(): ' + E);
                        throw(E);
                }
        },
@@ -48,7 +50,7 @@ util.file.prototype = {
                        if (this._output_stream) { this._output_stream.close(); this._output_stream = null; }
 
                } catch(E) {
-                       this.G.error.sdump('D_ERROR','util.file.close(): ' + E);
+                       this.error.sdump('D_ERROR','util.file.close(): ' + E);
                        throw(E);
                }
        },
@@ -67,7 +69,7 @@ util.file.prototype = {
                        this.close();
 
                } catch(E) {
-                       this.G.error.sdump('D_ERROR','util.file.set_object(): ' + E);
+                       this.error.sdump('D_ERROR','util.file.set_object(): ' + E);
                        throw(E);
                }
        },
@@ -87,7 +89,7 @@ util.file.prototype = {
                        return obj;
 
                } catch(E) {
-                       this.G.error.sdump('D_ERROR','util.file.get_object(): ' + E);
+                       this.error.sdump('D_ERROR','util.file.get_object(): ' + E);
                        throw(E);
                }
        },
@@ -111,7 +113,7 @@ util.file.prototype = {
                        }
 
                } catch(E) {
-                       this.G.error.sdump('D_ERROR','util.file._create_input_stream(): ' + E);
+                       this.error.sdump('D_ERROR','util.file._create_input_stream(): ' + E);
                        throw(E);
                }
        },
@@ -130,7 +132,7 @@ util.file.prototype = {
                        return this._output_stream;
 
                } catch(E) {
-                       this.G.error.sdump('D_ERROR','util.file._create_output_stream(): ' + E);
+                       this.error.sdump('D_ERROR','util.file._create_output_stream(): ' + E);
                        throw(E);
                }
        }
index 9df42fc..e23d78a 100644 (file)
@@ -13,7 +13,9 @@ pref("network.http.max-persistent-connections-per-server",8);
 pref("dom.max_script_run_time",60);
 
 pref("javascript.options.strict",false);
+pref("javascript.options.showInConsole",true);
 
 // This lets remote xul access link to local chrome
 pref("security.checkloaduri", false);
 pref("signed.applets.codebase_principal_support", true);
+