b0f7c5fb48ea47322cdbbc1628fa2f41d488f551
[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                         dump('obj.controller.view.opac_browser.addProgressListener = ' 
40                                 + obj.controller.view.opac_browser.addProgressListener + '\n');
41                         obj.controller.view.opac_browser.addProgressListener(obj.progressListener,
42                                         Components.interfaces.nsIWebProgress.NOTIFY_ALL );
43
44                         obj.controller.view.opac_browser.setAttribute('src',obj.url);
45
46                 } catch(E) {
47                         this.error.sdump('D_ERROR','cat.opac.init: ' + E + '\n');
48                 }
49         },
50
51         'push_variables' : function() {
52
53                 try {
54                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
55                         this.controller.view.opac_browser.contentWindow.IAMXUL = true;
56                         if (window.xulG) this.controller.view.opac_browser.contentWindow.xulG = xulG;
57                 } catch(E) {
58                         this.error.sdump('D_ERROR','cat.opac.push_variables: ' + E + '\n');
59                 }
60         },
61         
62         'buildProgressListener' : function() {
63
64                 try {
65                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
66
67                         var obj = this;
68                         obj.progressListener = {
69                                 onProgressChange        : function(){},
70                                 onLocationChange        : function(){},
71                                 onStatusChange          : function(){},
72                                 onSecurityChange        : function(){},
73                                 onStateChange           : function ( webProgress, request, stateFlags, status) {
74                                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
75                                         var s = '';
76                                         const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
77                                         const nsIChannel = Components.interfaces.nsIChannel;
78                                         if (stateFlags == 65540 || stateFlags == 65537 || stateFlags == 65552) { return; }
79                                         s = ('onStateChange: stateFlags = ' + stateFlags + ' status = ' + status + '\n');
80                                         if (stateFlags & nsIWebProgressListener.STATE_IS_REQUEST) {
81                                                 s += ('\tSTATE_IS_REQUEST\n');
82                                         }
83                                         if (stateFlags & nsIWebProgressListener.STATE_IS_DOCUMENT) {
84                                                 s += ('\tSTATE_IS_DOCUMENT\n');
85                                                 if( stateFlags & nsIWebProgressListener.STATE_STOP ) obj.push_variables(); 
86                                         }
87                                         if (stateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
88                                                 s += ('\tSTATE_IS_NETWORK\n');
89                                         }
90                                         if (stateFlags & nsIWebProgressListener.STATE_IS_WINDOW) {
91                                                 s += ('\tSTATE_IS_WINDOW\n');
92                                         }
93                                         if (stateFlags & nsIWebProgressListener.STATE_START) {
94                                                 s += ('\tSTATE_START\n');
95                                         }
96                                         if (stateFlags & nsIWebProgressListener.STATE_REDIRECTING) {
97                                                 s += ('\tSTATE_REDIRECTING\n');
98                                         }
99                                         if (stateFlags & nsIWebProgressListener.STATE_TRANSFERING) {
100                                                 s += ('\tSTATE_TRANSFERING\n');
101                                         }
102                                         if (stateFlags & nsIWebProgressListener.STATE_NEGOTIATING) {
103                                                 s += ('\tSTATE_NEGOTIATING\n');
104                                         }
105                                         if (stateFlags & nsIWebProgressListener.STATE_STOP) {
106                                                 s += ('\tSTATE_STOP\n');
107                                         }
108                                         obj.error.sdump('D_OPAC',s);    
109                                 }
110                         }
111                         obj.progressListener.QueryInterface = function(){return this;};
112                 } catch(E) {
113                         this.error.sdump('D_ERROR','cat.opac.buildProgressListener: ' + E + '\n');
114                 }
115         },
116 }
117
118 dump('exiting cat.opac.js\n');