shortened URL param names to keep the URL's from getting so long
[Evergreen.git] / Evergreen / staff_client / chrome / content / evergreen / opac / opac.js
1 sdump('D_OPAC','Loading opac.js\n');
2
3 var OPAC_URL = "http://dev.gapines.org/"
4
5 /* listen for page changes */
6
7 function buildProgressListener(p) {
8         sdump('D_OPAC',arg_dump(arguments));
9         var progressListener = {
10                 onProgressChange        : function(){},
11                 onLocationChange        : function(){},
12                 onStatusChange          : function(){},
13                 onSecurityChange        : function(){},
14                 onStateChange           : function ( webProgress, request, stateFlags, status) {
15                         const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
16                         const nsIChannel = Components.interfaces.nsIChannel;
17                         if (stateFlags == 65540 || stateFlags == 65537 || stateFlags == 65552) { return; }
18                         dump('onStateChange: stateFlags = ' + stateFlags + ' status = ' + status + '\n');
19                         if (stateFlags & nsIWebProgressListener.STATE_IS_REQUEST) {
20                                 dump('\tSTATE_IS_REQUEST\n');
21                         }
22                         if (stateFlags & nsIWebProgressListener.STATE_IS_DOCUMENT) {
23                                 dump('\tSTATE_IS_DOCUMENT\n');
24                                 if( stateFlags & nsIWebProgressListener.STATE_STOP ) set_opac_vars(p); 
25                         }
26                         if (stateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
27                                 dump('\tSTATE_IS_NETWORK\n');
28                         }
29                         if (stateFlags & nsIWebProgressListener.STATE_IS_WINDOW) {
30                                 dump('\tSTATE_IS_WINDOW\n');
31                         }
32                         if (stateFlags & nsIWebProgressListener.STATE_START) {
33                                 dump('\tSTATE_START\n');
34                         }
35                         if (stateFlags & nsIWebProgressListener.STATE_REDIRECTING) {
36                                 dump('\tSTATE_REDIRECTING\n');
37                         }
38                         if (stateFlags & nsIWebProgressListener.STATE_TRANSFERING) {
39                                 dump('\tSTATE_TRANSFERING\n');
40                         }
41                         if (stateFlags & nsIWebProgressListener.STATE_NEGOTIATING) {
42                                 dump('\tSTATE_NEGOTIATING\n');
43                         }
44                         if (stateFlags & nsIWebProgressListener.STATE_STOP) {
45                                 dump('\tSTATE_STOP\n');
46                         }
47                 }
48         }
49         progressListener.QueryInterface = function(){return this;};
50         return progressListener;
51 }
52
53 /* init the opac */
54 function opac_init(p) {
55         sdump('D_OPAC',"Initing OPAC\n");
56
57         p.opac_progressListener = buildProgressListener(p);
58
59         p.opac_iframe = p.w.document.getElementById('opac_opac_iframe');
60         p.opac_iframe.addProgressListener(p.opac_progressListener, 
61                 Components.interfaces.nsIWebProgress.NOTIFY_ALL );
62         p.opac_iframe.setAttribute("src", OPAC_URL + '?l=' + mw.G.user.home_ou()) 
63 }
64
65 /* shoves data into the OPAC's space */
66 function set_opac_vars(p) {
67         sdump('D_OPAC',arg_dump(arguments));
68         p.opac_iframe.contentWindow.IAMXUL = true;
69         p.opac_iframe.contentWindow.xulG = mw.G;
70         p.opac_iframe.contentWindow.attachEvt("rdetail", "recordRetrieved", 
71                 function(id){opac_make_details_page(p,id)});
72         p.opac_iframe.removeProgressListener(p.opac_progressListener);
73         p.opac_iframe.addProgressListener(p.opac_progressListener, 
74                 Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT );
75
76 }
77
78 function opac_make_details_page(p, id) {
79         sdump('D_OPAC',arg_dump(arguments));
80         dump("OPAC doc id is " + id +'\n');
81         spawn_record_details(
82                 p.w.app_shell, 'new_tab', 'main_tabbox', {
83                         'find_this_id' : id
84                 }
85         ).find_this_id = id;
86 }
87
88 /* -------------------------------------------------------------------------- 
89         back-forward
90         -------------------------------------------------------------------------- */
91 function opac_build_navigation(p) {
92         p.webForward = function webForward() {
93                 try {
94                         if(p.opac_iframe.webNavigation.canGoForward)
95                                 p.opac_iframe.webNavigation.goForward();
96                 } catch(E) {
97                         sdump('D_OPAC','goForward error: ' + js2JSON(E) + '\n');
98                 }
99         }
100
101         p.webBack = function webBack() {
102                 try {
103                         if(p.opac_iframe.webNavigation.canGoBack)
104                                 p.opac_iframe.webNavigation.goBack();
105                 } catch(E) {
106                         sdump('D_OPAC','goBack error: ' + js2JSON(E) + '\n');
107                 }
108         }
109 }
110
111
112
113
114
115
116