]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/dojo/openils/XUL.js
function to get the XUL build id
[working/Evergreen.git] / Open-ILS / web / js / dojo / openils / XUL.js
1 if(!dojo._hasResource["openils.XUL"]) {
2
3     dojo.provide("openils.XUL");
4     dojo.declare('openils.XUL', null, {});
5
6     openils.XUL.isXUL = function() {
7         return Boolean(window.IAMXUL);
8     }
9
10     openils.XUL.buildId = function() {
11         return window.XUL_BUILD_ID || '';
12     }
13     
14     openils.XUL.getStash = function() {
15         if(openils.XUL.isXUL()) {
16             try {
17                 if(openils.XUL.enableXPConnect()) {
18                                 var CacheClass = new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
19                                 return new CacheClass().wrappedJSObject.OpenILS.prototype.data;
20                 }
21             } catch(e) {
22                 console.log("Error loading XUL stash: " + e);
23             }
24         }
25
26         return {};
27     }
28
29     /** 
30      * This can be used by privileged Firefox in addition to XUL.
31      * To use use in Firefox directly, set signed.applets.codebase_principal_support to true in about:config
32      */ 
33     openils.XUL.enableXPConnect = function() {
34         try {
35             netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
36         } catch (E) {
37             if(dojo.isFF) {
38                 console.error("Unable to enable UniversalXPConnect privileges.  " +
39                     "Try setting 'signed.applets.codebase_principal_support' to true in about:config");
40             }
41             return false;
42         }
43         return true;
44     }
45 }
46
47