cdfb80563d956538e0270ab887f899d33df48d17
[Evergreen.git] / Open-ILS / xul / staff_client / server / cat / opac.js
1 dump('entering cat.opac.js\n');
2
3 if (typeof cat == 'undefined') cat = {};
4 cat.opac = function (params) {
5         try {
6                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
7                 JSAN.use('util.error'); this.error = new util.error();
8         } catch(E) {
9                 dump('cat.opac: ' + E + '\n');
10         }
11 }
12
13 cat.opac.prototype = {
14
15         'init' : function( params ) {
16
17                 try {
18                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
19
20                         var obj = this;
21
22                         obj.session = params['session'];
23                         obj.url = params['url'];
24
25                         JSAN.use('main.controller'); obj.controller = new main.controller();
26                         obj.controller.init(
27                                 {
28                                         control_map : {
29                                                 'cmd_broken' : [
30                                                         ['command'],
31                                                         function() { alert('Not Yet Implemented'); }
32                                                 ],
33                                         }
34                                 }
35                         );
36                         obj.controller.view.opac_browser = document.getElementById('opac_browser');
37
38                         obj.buildProgressListener();
39                         obj.controller.view.opac_browser.addProgressListener(obj.progressListener,
40                                         Components.interfaces.nsIWebProgress.NOTIFY_ALL );
41
42                         obj.controller.view.opac_browser.setAttribute('src',obj.url);
43
44                 } catch(E) {
45                         this.error.sdump('D_ERROR','cat.opac.init: ' + E + '\n');
46                 }
47         },
48
49         'push_variables' : function() {
50
51                 try {
52                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
53                         this.controller.view.opac_browser.contentWindow.IAMXUL = true;
54                         if (window.xulG) this.controller.view.opac_browser.contentWindow.xulG = xulG;
55                 } catch(E) {
56                         this.error.sdump('D_ERROR','cat.opac.push_variables: ' + E + '\n');
57                 }
58         },
59         
60         'buildProgressListener' : function() {
61
62                 try {
63                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
64
65                         var obj = this;
66                         obj.progressListener = {
67                                 onProgressChange        : function(){},
68                                 onLocationChange        : function(){},
69                                 onStatusChange          : function(){},
70                                 onSecurityChange        : function(){},
71                                 onStateChange           : function ( webProgress, request, stateFlags, status) {
72                                         var s = '';
73                                         const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
74                                         const nsIChannel = Components.interfaces.nsIChannel;
75                                         if (stateFlags == 65540 || stateFlags == 65537 || stateFlags == 65552) { return; }
76                                         s = ('onStateChange: stateFlags = ' + stateFlags + ' status = ' + status + '\n');
77                                         if (stateFlags & nsIWebProgressListener.STATE_IS_REQUEST) {
78                                                 s += ('\tSTATE_IS_REQUEST\n');
79                                         }
80                                         if (stateFlags & nsIWebProgressListener.STATE_IS_DOCUMENT) {
81                                                 s += ('\tSTATE_IS_DOCUMENT\n');
82                                                 if( stateFlags & nsIWebProgressListener.STATE_STOP ) obj.push_variables(); 
83                                         }
84                                         if (stateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
85                                                 s += ('\tSTATE_IS_NETWORK\n');
86                                         }
87                                         if (stateFlags & nsIWebProgressListener.STATE_IS_WINDOW) {
88                                                 s += ('\tSTATE_IS_WINDOW\n');
89                                         }
90                                         if (stateFlags & nsIWebProgressListener.STATE_START) {
91                                                 s += ('\tSTATE_START\n');
92                                         }
93                                         if (stateFlags & nsIWebProgressListener.STATE_REDIRECTING) {
94                                                 s += ('\tSTATE_REDIRECTING\n');
95                                         }
96                                         if (stateFlags & nsIWebProgressListener.STATE_TRANSFERING) {
97                                                 s += ('\tSTATE_TRANSFERING\n');
98                                         }
99                                         if (stateFlags & nsIWebProgressListener.STATE_NEGOTIATING) {
100                                                 s += ('\tSTATE_NEGOTIATING\n');
101                                         }
102                                         if (stateFlags & nsIWebProgressListener.STATE_STOP) {
103                                                 s += ('\tSTATE_STOP\n');
104                                         }
105                                         obj.error.sdump('D_OPAC',s);    
106                                 }
107                         }
108                         obj.progressListener.QueryInterface = function(){return this;};
109                 } catch(E) {
110                         this.error.sdump('D_ERROR','cat.opac.buildProgressListener: ' + E + '\n');
111                 }
112         },
113 }
114
115 dump('exiting cat.opac.js\n');