bug hunt
[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                 var pref = Components.classes["@mozilla.org/preferences-service;1"]
7                         .getService(Components.interfaces.nsIPrefBranch);
8                 if (pref) {
9                         pref.setCharPref("capability.principal.codebase.p0.granted", "UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead");
10                         pref.setCharPref("capability.principal.codebase.p0.id", urls.opac);
11                 }
12
13                 if (typeof JSAN == 'undefined') {
14                         throw(
15                                 "The JSAN library object is missing."
16                         );
17                 }
18                 /////////////////////////////////////////////////////////////////////////////
19
20                 JSAN.errorLevel = "die"; // none, warn, or die
21                 JSAN.addRepository('..');
22
23                 //JSAN.use('test.test'); test.test.hello_world();
24
25                 var mw = self;
26                 var G =  {};
27                 G.OpenILS = {};
28                 G.OpenSRF = {};
29
30                 JSAN.use('util.error');
31                 G.error = new util.error();
32                 G.error.sdump('D_ERROR','Testing');
33
34                 JSAN.use('main.window');
35                 G.window = new main.window();
36
37                 JSAN.use('auth.controller');
38                 G.auth = new auth.controller( { 'window' : mw } );
39
40                 JSAN.use('OpenILS.data');
41                 G.OpenILS.data = new OpenILS.data()
42                 G.OpenILS.data.on_error = G.auth.logoff;
43                 G.OpenILS.data.entities = entities;
44                 G.OpenILS.data.stash('entities');
45
46                 G.auth.on_login = function() {
47
48                         G.OpenILS.data.session = G.auth.session.key;
49                         G.OpenILS.data.on_complete = function () {
50                                 
51                                 G.OpenILS.data.stash('list','hash');
52                                 G.OpenILS.data._debug_stash();
53
54                         alert('authtime = ' + G.auth.session.authtime);
55                                 G.window.open(urls.opac + urls.remote_menu_frame 
56                                         + '?session='+mw.escape(G.auth.session.key)
57                                         + '&authtime='+mw.escape(G.auth.session.authtime),
58                                         'test','chrome');
59                         }
60                         G.OpenILS.data.init();
61                 }
62
63                 G.auth.init();
64
65                 /////////////////////////////////////////////////////////////////////////////
66
67         } catch(E) {
68                 var error = "!! This software has encountered an error.  Please tell your friendly " +
69                         "system administrator or software developer the following:\n" + E + '\n';
70                 try { G.error.sdump('D_ERROR',error); } catch(E) { dump(error); }
71                 alert(error);
72         }
73         dump('exiting main_init()\n');
74 }
75
76 dump('exiting main/main.js\n');