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