some thinkos, offline fixes, remote xul testing
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 5 Oct 2005 14:44:00 +0000 (14:44 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 5 Oct 2005 14:44:00 +0000 (14:44 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@1899 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/Makefile
Open-ILS/xul/staff_client/chrome/content/evergreen/OpenILS/data.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/window.js
Open-ILS/xul/staff_client/chrome/content/evergreen/util/error.js
Open-ILS/xul/staff_client/chrome/content/evergreen/util/file.js

index 87df089..1bf4b03 100644 (file)
@@ -41,7 +41,7 @@ generated:
        #(cd chrome/content/evergreen/util ; ${RETRIEVE_FIELDMAPPER} );
        #(cd chrome/content/evergreen/util ; ${RETRIEVE_ORG_TREE} );
        (cd chrome/content/evergreen/conf ; ${RETRIEVE_CLIENT_CONFIG} );
-       (cd chrome/content/evergreen/OpenILS/util/ ; ${RETRIEVE_FM_ALL} );
+       #(cd chrome/content/evergreen/OpenILS/util/ ; ${RETRIEVE_FM_ALL} );
 
 open-ils:
        cp ../../../OpenSRF/src/javascript/*.js chrome/content/evergreen/OpenSRF/
index 161db0a..c6dadb8 100644 (file)
@@ -14,8 +14,8 @@ OpenILS.data = function (mw,G) {
        function gen_fm_retrieval_func(classname,data) {
                var app = data[0]; var method = data[1]; var params = data[2]; var cacheable = data[3];
                return function () {
-                       try {
-                               obj.list[classname] = obj.G.network.request( app, method, params);
+
+                       function convert() {
                                try {
                                        if (obj.list[classname].constructor.name == 'Array') {
                                                obj.hash[classname] = 
@@ -27,6 +27,12 @@ OpenILS.data = function (mw,G) {
 
                                        obj.G.error.sdump('D_ERROR',E + '\n');
                                }
+
+                       }
+
+                       try {
+                               obj.list[classname] = obj.G.network.request( app, method, params);
+                               convert();
                                // if cacheable, store an offline copy
                                if (cacheable) {
                                        var file = new util.file( obj.mw, obj.G, classname );
@@ -36,8 +42,15 @@ OpenILS.data = function (mw,G) {
                        } catch(E) {
                                // if cacheable, try offline
                                if (cacheable) {
+                                       try {
+                                               var file = new util.file( obj.mw, obj.G, classname );
+                                               obj.list[classname] = file.get_object();
+                                               convert();
+                                       } catch(E) {
+                                               throw(E);
+                                       }
                                }
-                               throw(E); // for now
+                               //throw(E); // for now
                        }
                }
        }
@@ -51,7 +64,7 @@ OpenILS.data = function (mw,G) {
                                'open-ils.search',
                                'open-ils.search.actor.user.session',
                                [ obj.G.auth.session.key ],
-                               false
+                               true
                        ]
                )
        );
index 5dfdebb..ada09b5 100644 (file)
@@ -65,7 +65,11 @@ auth.session.prototype = {
                                this.on_init_error(E);
                        }
 
-                       throw(E);
+                       //throw(E);
+                       if (typeof this.on_init == 'function') {
+                               this.G.error.sdump('D_AUTH','auth.session.on_init() despite error\n');
+                               this.on_init();
+                       }
                }
 
        },
index 4ebb91b..9d24910 100644 (file)
@@ -29,6 +29,12 @@ function main_init() {
                JSAN.use('main.network');
                G.network = new main.network( mw, G );
 
+               G.test_array = [ "a", "b", "c" ];
+               G.test_object = { "a" : "b", "c" : "d", "e" : "f" };
+               G.test = function(t) {
+                       dump(js2JSON( t ) + '\n');
+               }
+
                JSAN.use('auth.controller');
                G.auth = new auth.controller( mw, G );
 
@@ -38,7 +44,7 @@ function main_init() {
                        G.OpenILS.data = new OpenILS.data( mw, G );
                        G.OpenILS.data.on_complete = function () {
 
-                               alert('spawn app_shell');
+                               G.window.open('http://gapines.org/xul/test.xul','test','chrome');
                        }
                        G.OpenILS.data.init();
                }
index dec70b6..8ce5d4d 100644 (file)
@@ -2,7 +2,7 @@ dump('entering main/window.js\n');
 
 if (typeof main == 'undefined') main = {};
 main.window = function (mw,G) {
-       this.main_window = mw;
+       this.main_window = mw; this.mw = mw; this.G = G;
        return this;
 };
 
@@ -24,8 +24,49 @@ main.window.prototype = {
        'window_name_increment' : 0, 
 
        // This number gets put into the title bar for Top Level menu interface windows
-       'appshell_name_increment' : 0
+       'appshell_name_increment' : 0,
 
+       // From: Bryan White on netscape.public.mozilla.xpfe, Oct 13, 2004
+       // Message-ID: <ckjh7a$18q1@ripley.netscape.com>
+       // Modified by Jason for Evergreen
+       'SafeWindowOpen' : function (url,title,features) {
+               var w;
+
+               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+               const CI = Components.interfaces;
+               const PB = Components.classes["@mozilla.org/preferences-service;1"].getService(CI.nsIPrefBranch);
+
+               var blocked = false;
+               try {
+                       // pref 'dom.disable_open_during_load' is the main popup blocker preference
+                       blocked = PB.getBoolPref("dom.disable_open_during_load");
+                       if(blocked) PB.setBoolPref("dom.disable_open_during_load",false);
+
+                       w = window.open(url,title,features);
+               } catch(E) {
+                       this.G.error.sdump('D_ERROR','window.SafeWindowOpen: ' + E + '\n');
+                       throw(E);
+               }
+               if(blocked) PB.setBoolPref("dom.disable_open_during_load",true);
+
+               return w;
+       },
+
+       'open' : function(url,title,features) {
+               this.G.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() { 
+                               try { w.title = title; } catch(E) { dump('**'+E+'\n'); }
+                               try { w.document.title = title; } catch(E) { dump('**'+E+'\n'); }
+                       }, 0 
+               );
+               */
+               return w;
+       }
 }
 
 dump('exiting main/window.js\n');
index bd14793..13fd8b4 100644 (file)
@@ -49,7 +49,7 @@ util.error.prototype = {
 
                'D_FILE' : true, 'D_EXPLODE' : false, 'D_FM_UTILS' : false, 'D_PRINT' : false, 'D_SES' : true,
                'D_SES_FUNC' : false, 'D_SES_RESULT' : true, 'D_SPAWN' : false, 'D_STRING' : false,
-               'D_UTIL' : false, 'D_WIN' : false, 'D_WIDGETS' : false
+               'D_UTIL' : false, 'D_WIN' : true, 'D_WIDGETS' : false
        },
 
        'filter_console_init' : function (p) {
index 9772657..9bfaf57 100644 (file)
@@ -79,7 +79,7 @@ util.file.prototype = {
                        if (this._input_stream || this._output_stream) throw('Must .close() first.');
                        
                        this._create_input_stream();
-                       var data = this._input_stream(-1);
+                       var data = this._input_stream.read(-1);
                        this.close();
        
                        var obj; try { obj = JSON2js( data ); } catch(E) { throw('Could not js-ify the JSON: '+E); }
@@ -100,7 +100,7 @@ util.file.prototype = {
        
                        var f = Components.classes["@mozilla.org/network/file-input-stream;1"]
                                .createInstance(Components.interfaces.nsIFileInputStream);
-                       f.init(file, 0x01, 0, 0);
+                       f.init(this._file, 0x01, 0, 0);
                        this._input_stream = Components.classes["@mozilla.org/scriptableinputstream;1"]
                                .createInstance(Components.interfaces.nsIScriptableInputStream);
                        if (f) {