This is how we can grant priviledges to remote js without needing signed code, or...
[Evergreen.git] / Open-ILS / xul / staff_client / chrome / content / evergreen / main / main.js
1 dump('entering main/main.js\n');
2
3 function main_init() {
4         dump('entering main_init()\n');
5         try {
6
7                 var pref = Components.classes["@mozilla.org/preferences-service;1"]
8                         .getService(Components.interfaces.nsIPrefBranch);
9                 if (pref) {
10                         pref.setCharPref("capability.principal.codebase.p0.granted", "UniversalXPConnect");
11                         pref.setCharPref("capability.principal.codebase.p0.id", "http://gapines.org");
12                 }
13
14                 if (typeof JSAN == 'undefined') {
15                         throw(
16                                 "The JSAN library object is missing."
17                         );
18                 }
19                 /////////////////////////////////////////////////////////////////////////////
20
21                 JSAN.errorLevel = "die"; // none, warn, or die
22                 JSAN.addRepository('..');
23
24                 //JSAN.use('test.test'); test.test.hello_world();
25
26                 var mw = self;
27                 var G =  {};
28                 G.OpenILS = {};
29                 G.OpenSRF = {};
30
31                 JSAN.use('util.error');
32                 G.error = new util.error();
33                 G.error.sdump('D_ERROR','Testing');
34
35                 JSAN.use('main.window');
36                 G.window = new main.window();
37
38                 JSAN.use('main.network');
39                 G.network = new main.network();
40
41                 G.test_array = [ "a", "b", "c" ];
42                 G.test_object = { "a" : "b", "c" : "d", "e" : "f" };
43                 G.test = function(t) {
44                         dump(js2JSON( t ) + '\n');
45                 }
46
47                 JSAN.use('auth.controller');
48                 G.auth = new auth.controller( mw );
49
50                 G.auth.on_login = function() {
51
52                         JSAN.use('OpenILS.data');
53                         G.OpenILS.data = new OpenILS.data( G.auth );
54                         G.OpenILS.data.on_complete = function () {
55
56                                 G.window.open('http://gapines.org/xul/server/test.xul','test','chrome');
57                         }
58                         G.OpenILS.data.init();
59                 }
60
61                 G.auth.init();
62
63                 /////////////////////////////////////////////////////////////////////////////
64
65         } catch(E) {
66                 var error = "!! This software has encountered an error.  Please tell your friendly " +
67                         "system administrator or software developer the following:\n" + E + '\n';
68                 try { G.error.sdump('D_ERROR',error); } catch(E) { dump(error); }
69                 alert(error);
70         }
71         dump('exiting main_init()\n');
72 }
73
74 dump('exiting main/main.js\n');