]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/chrome/content/evergreen/main/main.js
global data object via xpcom
[Evergreen.git] / Open-ILS / xul / staff_client / chrome / content / evergreen / main / main.js
1 dump('entering main/main.js\n');
2
3 function test1() {
4                 const Simple=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
5                 var simple=new Simple( );
6                 for (var list in simple) { dump(list + '\n'); }
7                 simple.help();
8                 simple.wrappedJSObject.OpenILS.prototype.data = { 'hello' : 'world' };
9                 dump( 'simple.wrappedJSObject.OpenILS.prototype.data  : ' + js2JSON(simple.wrappedJSObject.OpenILS.prototype.data) + '\n');
10 }
11
12 function test2() {
13                 const Simple=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
14                 var simple=new Simple( );
15                 dump( 'simple.wrappedJSObject.OpenILS.prototype.data  : ' + js2JSON(simple.wrappedJSObject.OpenILS.prototype.data) + '\n');
16 }
17
18
19 function main_init() {
20         dump('entering main_init()\n');
21         try {
22                 test1(); test2();
23                 alert('pause');
24                 
25                 var pref = Components.classes["@mozilla.org/preferences-service;1"]
26                         .getService(Components.interfaces.nsIPrefBranch);
27                 if (pref) {
28                         pref.setCharPref("capability.principal.codebase.p0.granted", "UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead");
29                         pref.setCharPref("capability.principal.codebase.p0.id", "http://dev.gapines.org");
30                 }
31
32                 if (typeof JSAN == 'undefined') {
33                         throw(
34                                 "The JSAN library object is missing."
35                         );
36                 }
37                 /////////////////////////////////////////////////////////////////////////////
38
39                 JSAN.errorLevel = "die"; // none, warn, or die
40                 JSAN.addRepository('..');
41
42                 //JSAN.use('test.test'); test.test.hello_world();
43
44                 var mw = self;
45                 var G =  {};
46                 G.OpenILS = {};
47                 G.OpenSRF = {};
48
49                 JSAN.use('util.error');
50                 G.error = new util.error();
51                 G.error.sdump('D_ERROR','Testing');
52
53                 JSAN.use('main.window');
54                 G.window = new main.window();
55
56                 JSAN.use('auth.controller');
57                 G.auth = new auth.controller( mw );
58
59                 G.auth.on_login = function() {
60
61                         JSAN.use('OpenILS.data');
62                         G.OpenILS.data = new OpenILS.data( G.auth );
63                         G.OpenILS.data.on_complete = function () {
64
65                                 G.window.open('http://dev.gapines.org/xul/server/main/menu_frame.xul?session='+mw.escape(G.auth.session.key),'test','chrome');
66                         }
67                         G.OpenILS.data.init();
68                 }
69
70                 G.auth.init();
71
72                 /////////////////////////////////////////////////////////////////////////////
73
74         } catch(E) {
75                 var error = "!! This software has encountered an error.  Please tell your friendly " +
76                         "system administrator or software developer the following:\n" + E + '\n';
77                 try { G.error.sdump('D_ERROR',error); } catch(E) { dump(error); }
78                 alert(error);
79         }
80         dump('exiting main_init()\n');
81 }
82
83 dump('exiting main/main.js\n');