From 68bd76424ec4842013f1498b905b5b496028f0fc Mon Sep 17 00:00:00 2001 From: phasefx Date: Wed, 5 Oct 2005 14:44:00 +0000 Subject: [PATCH] some thinkos, offline fixes, remote xul testing git-svn-id: svn://svn.open-ils.org/ILS/trunk@1899 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/xul/staff_client/Makefile | 2 +- .../chrome/content/evergreen/OpenILS/data.js | 21 +++++++-- .../chrome/content/evergreen/auth/session.js | 6 ++- .../chrome/content/evergreen/main/main.js | 8 +++- .../chrome/content/evergreen/main/window.js | 45 ++++++++++++++++++- .../chrome/content/evergreen/util/error.js | 2 +- .../chrome/content/evergreen/util/file.js | 4 +- 7 files changed, 76 insertions(+), 12 deletions(-) diff --git a/Open-ILS/xul/staff_client/Makefile b/Open-ILS/xul/staff_client/Makefile index 87df089d52..1bf4b039ac 100644 --- a/Open-ILS/xul/staff_client/Makefile +++ b/Open-ILS/xul/staff_client/Makefile @@ -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/ diff --git a/Open-ILS/xul/staff_client/chrome/content/evergreen/OpenILS/data.js b/Open-ILS/xul/staff_client/chrome/content/evergreen/OpenILS/data.js index 161db0a732..c6dadb8759 100644 --- a/Open-ILS/xul/staff_client/chrome/content/evergreen/OpenILS/data.js +++ b/Open-ILS/xul/staff_client/chrome/content/evergreen/OpenILS/data.js @@ -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 ] ) ); diff --git a/Open-ILS/xul/staff_client/chrome/content/evergreen/auth/session.js b/Open-ILS/xul/staff_client/chrome/content/evergreen/auth/session.js index 5dfdebb450..ada09b5f74 100644 --- a/Open-ILS/xul/staff_client/chrome/content/evergreen/auth/session.js +++ b/Open-ILS/xul/staff_client/chrome/content/evergreen/auth/session.js @@ -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(); + } } }, diff --git a/Open-ILS/xul/staff_client/chrome/content/evergreen/main/main.js b/Open-ILS/xul/staff_client/chrome/content/evergreen/main/main.js index 4ebb91be95..9d249108e8 100644 --- a/Open-ILS/xul/staff_client/chrome/content/evergreen/main/main.js +++ b/Open-ILS/xul/staff_client/chrome/content/evergreen/main/main.js @@ -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(); } diff --git a/Open-ILS/xul/staff_client/chrome/content/evergreen/main/window.js b/Open-ILS/xul/staff_client/chrome/content/evergreen/main/window.js index dec70b6bff..8ce5d4db04 100644 --- a/Open-ILS/xul/staff_client/chrome/content/evergreen/main/window.js +++ b/Open-ILS/xul/staff_client/chrome/content/evergreen/main/window.js @@ -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: + // 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'); diff --git a/Open-ILS/xul/staff_client/chrome/content/evergreen/util/error.js b/Open-ILS/xul/staff_client/chrome/content/evergreen/util/error.js index bd14793ac3..13fd8b4cea 100644 --- a/Open-ILS/xul/staff_client/chrome/content/evergreen/util/error.js +++ b/Open-ILS/xul/staff_client/chrome/content/evergreen/util/error.js @@ -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) { diff --git a/Open-ILS/xul/staff_client/chrome/content/evergreen/util/file.js b/Open-ILS/xul/staff_client/chrome/content/evergreen/util/file.js index 97726571c1..9bfaf575d0 100644 --- a/Open-ILS/xul/staff_client/chrome/content/evergreen/util/file.js +++ b/Open-ILS/xul/staff_client/chrome/content/evergreen/util/file.js @@ -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) { -- 2.43.2