From 386e8b9f0d5eb8c3b29271cece11c581e62c99a7 Mon Sep 17 00:00:00 2001 From: phasefx Date: Fri, 2 Dec 2005 21:51:58 +0000 Subject: [PATCH] global stash for data git-svn-id: svn://svn.open-ils.org/ILS/trunk@2177 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../chrome/content/evergreen/OpenILS/data.js | 41 ++++++++++++++++--- .../chrome/content/evergreen/auth/session.js | 2 +- .../chrome/content/evergreen/main/main.js | 20 +-------- 3 files changed, 38 insertions(+), 25 deletions(-) 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 686c47f435..6e76dd3eac 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 @@ -132,15 +132,46 @@ OpenILS.data.prototype = { 'list' : {}, 'hash' : {}, - 'init' : function () { + 'init' : function (stash) { - if (typeof this.on_complete == 'function') { + if (stash) { - this.chain.push( this.on_complete ); + try { + const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS"); + var data_cache=new OpenILS( ); + this.list = data_cache.wrappedJSObject.OpenILS.prototype.data.list; + this.hash = data_cache.wrappedJSObject.OpenILS.prototype.data.hash; + } catch(E) { + this.error.sdump('D_ERROR','Error in OpenILS.data.init(true): ' + js2JSON(E) ); + } + + if (typeof this.on_complete == 'function') { + + this.on_complete(); + } + + } else { + if (typeof this.on_complete == 'function') { + + this.chain.push( this.on_complete ); + } + + JSAN.use('util.exec'); + util.exec.chain( this.chain ); } + }, - JSAN.use('util.exec'); - util.exec.chain( this.chain ); + 'stash' : function () { + try { + const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS"); + var data_cache=new OpenILS( ); + data_cache.wrappedJSObject.OpenILS.prototype.data = { + 'list' : js2JSON( JSON2js( this.list ) ), + 'hash' : js2JSON( JSON2js( this.hash ) ) + } + } catch(E) { + this.error.sdump('D_ERROR','Error in OpenILS.data.stash(): ' + js2JSON(E) ); + } }, '_fm_objects' : { 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 92e2848695..4651643734 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 @@ -70,7 +70,7 @@ auth.session.prototype = { this.on_init_error(E); } - throw(E); + //throw(E); /* This was for testing if (typeof this.on_init == 'function') { this.error.sdump('D_AUTH','auth.session.on_init() despite error\n'); 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 16acf597f0..6881d8f4b2 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 @@ -1,27 +1,8 @@ dump('entering main/main.js\n'); -function test1() { - const Simple=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS"); - var simple=new Simple( ); - for (var list in simple) { dump(list + '\n'); } - simple.help(); - simple.wrappedJSObject.OpenILS.prototype.data = { 'hello' : 'world' }; - dump( 'simple.wrappedJSObject.OpenILS.prototype.data : ' + js2JSON(simple.wrappedJSObject.OpenILS.prototype.data) + '\n'); -} - -function test2() { - const Simple=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS"); - var simple=new Simple( ); - dump( 'simple.wrappedJSObject.OpenILS.prototype.data : ' + js2JSON(simple.wrappedJSObject.OpenILS.prototype.data) + '\n'); -} - - function main_init() { dump('entering main_init()\n'); try { - test1(); test2(); - alert('pause'); - var pref = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch); if (pref) { @@ -65,6 +46,7 @@ function main_init() { G.window.open('http://dev.gapines.org/xul/server/main/menu_frame.xul?session='+mw.escape(G.auth.session.key),'test','chrome'); } G.OpenILS.data.init(); + G.OpenILS.data.stash(); } G.auth.init(); -- 2.43.2