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