]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/chrome/content/evergreen/main/main.js
c54083cc23e4d7e1daae97637cfa35d8cd043045
[Evergreen.git] / Open-ILS / xul / staff_client / chrome / content / evergreen / main / main.js
1 dump('entering main/main.js\n');
2
3 function grant_perms(url) {
4         var pref = Components.classes["@mozilla.org/preferences-service;1"]
5                 .getService(Components.interfaces.nsIPrefBranch);
6         if (pref) {
7                 pref.setCharPref("capability.principal.codebase.p0.granted", "UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead");
8                 pref.setCharPref("capability.principal.codebase.p0.id", url);
9         }
10
11 }
12
13 function main_init() {
14         dump('entering main_init()\n');
15         try {
16                 if (typeof JSAN == 'undefined') {
17                         throw(
18                                 "The JSAN library object is missing."
19                         );
20                 }
21                 /////////////////////////////////////////////////////////////////////////////
22
23                 JSAN.errorLevel = "die"; // none, warn, or die
24                 JSAN.addRepository('..');
25
26                 //JSAN.use('test.test'); test.test.hello_world();
27
28                 var mw = self;
29                 var G =  {};
30                 G.OpenILS = {};
31                 G.OpenSRF = {};
32
33                 JSAN.use('util.error');
34                 G.error = new util.error();
35                 G.error.sdump('D_ERROR','Testing');
36
37                 JSAN.use('util.window');
38                 G.window = new util.window();
39
40                 G.window.open(urls.remote_debug_console,'testconsole','chrome,resizable');
41
42                 JSAN.use('auth.controller');
43                 G.auth = new auth.controller( { 'window' : mw } );
44
45                 JSAN.use('OpenILS.data');
46                 G.OpenILS.data = new OpenILS.data()
47                 G.OpenILS.data.on_error = G.auth.logoff;
48                 G.OpenILS.data.entities = entities;
49                 G.OpenILS.data.stash('entities');
50
51                 G.auth.on_login = function() {
52
53                         G.OpenILS.data.session = G.auth.session.key;
54                         G.OpenILS.data.on_complete = function () {
55
56                                 var url = G.auth.controller.view.server_prompt.value || urls.remote;
57                                 if (! url.match( '^http://' ) ) url = 'http://' + url;
58                                 grant_perms(url);
59                                 
60                                 G.OpenILS.data.stash('list','hash','temp');
61                                 G.OpenILS.data._debug_stash();
62
63                                 G.window.open(url + urls.remote_menu_frame 
64                                         + '?session='+mw.escape(G.auth.session.key)
65                                         + '&authtime='+mw.escape(G.auth.session.authtime),
66                                         'test','chrome,resizable');
67                         }
68                         G.OpenILS.data.init();
69                 }
70
71                 G.auth.init();
72                 // XML_HTTP_SERVER will get reset to G.auth.controller.view.server_prompt.value
73
74                 /////////////////////////////////////////////////////////////////////////////
75
76         } catch(E) {
77                 var error = "!! This software has encountered an error.  Please tell your friendly " +
78                         "system administrator or software developer the following:\n" + E + '\n';
79                 try { G.error.sdump('D_ERROR',error); } catch(E) { dump(error); }
80                 alert(error);
81         }
82         dump('exiting main_init()\n');
83 }
84
85 dump('exiting main/main.js\n');