added search interface for the advanced search, marc search, and isbn search
[Evergreen.git] / Open-ILS / web / opac / common / js / config.js
1 /* Export some constants  ----------------------------------------------------- */
2
3 /* URL param names */
4 var PARAM_TERM                  = "t";                  /* search term */
5 var PARAM_STYPE         = "tp";                 /* search type */
6 var PARAM_LOCATION      = "l";                  /* current location */
7 var PARAM_DEPTH         = "d";                  /* search depth */
8 var PARAM_FORM                  = "f";                  /* search format */
9 var PARAM_OFFSET                = "o";                  /* search offset */
10 var PARAM_COUNT         = "c";                  /* hits per page */
11 var PARAM_HITCOUNT      = "hc";                 /* hits per page */
12 var PARAM_MRID                  = "m";                  /* metarecord id */
13 var PARAM_RID                   = "r";                  /* record id */
14 var PARAM_ORIGLOC               = "ol";                 /* the original location */
15 var PARAM_TOPRANK               = "tr";                 /* this highest ranking rank */
16 var PARAM_AUTHTIME      = "at";                 /* inactivity timeout in seconds */
17 var PARAM_ADVTERM               = "adv";                        /* advanced search term */
18
19 /* URL param values (see comments above) */
20 var TERM;  
21 var STYPE;  
22 var LOCATION;  
23 var DEPTH;  
24 var FORM; 
25 var OFFSET;
26 var COUNT;  
27 var HITCOUNT;  
28 var RANKS; 
29 var FONTSIZE;
30 var ORIGLOC;
31 var TOPRANK;
32 var AUTHTIME;
33 var ADVTERM;
34
35 /* cookie values */
36 var SBEXTRAS; 
37 var SKIN;
38
39
40 /* cookies */
41 var COOKIE_SB = "sbe";
42 var COOKIE_SES = "ses";
43 var COOKIE_IDS  = "ids";
44 var COOKIE_FONT = "fnt";
45 var COOKIE_SKIN = "skin";
46
47 /* these are the actual param values - set on page load */
48
49 /* pages */
50 var MRESULT             = "mresult";
51 var RRESULT             = "rresult";
52 var RDETAIL             = "rdetail";
53 var MYOPAC              = "myopac";
54 var ADVANCED    = "advanced";
55 var HOME                        = "home";
56
57 /* search type (STYPE) options */
58 var STYPE_AUTHOR        = "author";
59 var STYPE_TITLE         = "title";
60 var STYPE_SUBJECT       = "subject";
61 var STYPE_SERIES        = "series";
62 var STYPE_KEYWORD       = "keyword";
63
64 var LOGOUT_WARNING_TIME = 30; /* "head up" for session timeout */
65
66
67 /* container for global variables shared accross pages */
68 var G           = {};
69 G.user  = null; /* global user object */
70 G.ui            = {} /* cache of UI components */
71
72
73 /* call me after page init and I will load references 
74         to all of the ui object id's defined below 
75         They will be stored in G.ui.<page>.<thingy>
76  */
77 function loadUIObjects() {
78         for( var p in config.ids ) {
79                 G.ui[p] = {};
80                 for( var o in config.ids[p] ) 
81                         G.ui[p][o] = getId(config.ids[p][o]);
82         }
83 }
84
85 /* try our best to free memory */
86 function clearUIObjects() {
87         for( var p in config.ids ) {
88                 for( var o in config.ids[p] ) {
89                         if(G.ui[p][o]) {
90                                 G.ui[p][o].onclick = null;
91                                 G.ui[p][o].onkeydown = null;
92                                 G.ui[p][o] = null;
93                         }
94                 }
95                 G.ui[p] = null;
96         }
97 }
98
99 /* ---------------------------------------------------------------------------- 
100         Set up ID's and CSS classes 
101         Any new ids, css, etc. may be added by giving the unique names and putting 
102         them into the correct scope 
103 /* ---------------------------------------------------------------------------- */
104
105 var config = {};
106
107 /* Set up the page names */
108 config.page = {};
109 config.page[HOME]                       = "index.xml";
110 config.page[ADVANCED]   = "advanced.xml";
111 config.page[MRESULT]            = "mresult.xml";
112 config.page[RRESULT]            = "rresult.xml";
113 config.page[MYOPAC]             = "myopac.xml";
114 config.page[RDETAIL]            = "rdetail.xml";
115
116 /* themes */
117 config.themes = {};
118
119 /* set up images  */
120 config.images = {};
121 config.images.logo = "main_logo.jpg";
122
123
124 /* set up ID's, CSS, and node names */
125 config.ids                              = {};
126 config.ids.result               = {};
127 config.ids.mresult      = {};
128 config.ids.advanced     = {};
129 config.ids.rresult      = {};
130 config.ids.myopac               = {};
131 config.ids.rdetail      = {};
132
133 config.css                              = {};
134 config.css.result               = {};
135 config.css.mresult      = {};
136 config.css.advanced     = {};
137 config.css.rresult      = {};
138 config.css.myopac               = {};
139 config.css.rdetail      = {};
140
141 config.names                    = {};
142 config.names.result     = {};
143 config.names.mresult = {};
144 config.names.advanced = {};
145 config.names.rresult = {};
146 config.names.myopac     = {};
147 config.names.rdetail = {};
148
149
150 /* id's shared accross skins. These *must* be defined */
151 config.ids.common = {};
152 config.ids.common.loading                       = "loading_div";                
153 config.ids.common.canvas                        = "canvas";                             
154 config.ids.common.canvas_main           = "canvas_main";                
155 config.ids.common.org_tree                      = "org_tree";                   
156 config.ids.common.org_container = "org_container";
157
158 config.ids.xul = {};
159
160
161 /* shared CSS */
162 config.css.hide_me = "hide_me";
163 config.css.dim = "dim";
164 config.css.dim2 = "dim2";
165
166
167 /* ---------------------------------------------------------------------------- */
168 /* These are pages that may replace the canvas */
169 /* ---------------------------------------------------------------------------- */
170 config.ids.altcanvas = {};
171
172
173
174 /* ---------------------------------------------------------------------------- */
175 /* Methods are defined as service:method 
176         An optional 3rd component is when a method is followed by a :1, such methods
177         have a staff counterpart and should have ".staff" appended to the method 
178         before the method is called when in XUL mode */
179
180 var FETCH_MRCOUNT                                       = "open-ils.search:open-ils.search.biblio.class.count:1";
181 var FETCH_MRIDS                                 = "open-ils.search:open-ils.search.biblio.class:1";
182 var FETCH_MRIDS_FULL                            = "open-ils.search:open-ils.search.biblio.class.full:1";
183 var FETCH_MRMODS                                        = "open-ils.search:open-ils.search.biblio.metarecord.mods_slim.retrieve";
184 var FETCH_MR_COPY_COUNTS                = "open-ils.search:open-ils.search.biblio.metarecord.copy_count:1";
185 var FETCH_RIDS                                          = "open-ils.search:open-ils.search.biblio.metarecord_to_records:1";
186 var FETCH_RMODS                                 = "open-ils.search:open-ils.search.biblio.record.mods_slim.retrieve";
187 var FETCH_R_COPY_COUNTS                 = "open-ils.search:open-ils.search.biblio.record.copy_count";
188 var FETCH_FLESHED_USER                  = "open-ils.actor:open-ils.actor.user.fleshed.retrieve";
189 var FETCH_SESSION                                       = "open-ils.auth:open-ils.auth.session.retrieve";
190 var LOGIN_INIT                                          = "open-ils.auth:open-ils.auth.authenticate.init";
191 var LOGIN_COMPLETE                              = "open-ils.auth:open-ils.auth.authenticate.complete";
192 var LOGIN_DELETE                                        = "open-ils.auth:open-ils.auth.session.delete";
193 var FETCH_USER_PREFS                            = "open-ils.actor:open-ils.actor.patron.settings.retrieve"; 
194 var UPDATE_USER_PREFS                   = "open-ils.actor:open-ils.actor.patron.settings.update"; 
195 var FETCH_COPY_STATUSES                 = "open-ils.search:open-ils.search.config.copy_status.retrieve.all";
196 var FETCH_COPY_COUNTS_SUMMARY   = "open-ils.search:open-ils.search.biblio.copy_counts.summary.retrieve";
197 var FETCH_MARC_HTML                             = "open-ils.search:open-ils.search.biblio.record.html";
198 var FETCH_CHECKED_OUT                   = "open-ils.circ:open-ils.circ.actor.user.checked_out";
199 var FETCH_HOLDS                                 = "open-ils.circ:open-ils.circ.holds.retrieve";
200 var FETCH_FINES_SUMMARY                 = "open-ils.actor:open-ils.actor.user.fines.summary";
201 var FETCH_TRANSACTIONS                  = "open-ils.actor:open-ils.actor.user.transactions.have_charge.fleshed";
202 var FETCH_CROSSREF                              = "open-ils.search:open-ils.search.authority.crossref";
203 var FETCH_CROSSREF_BATCH                = "open-ils.search:open-ils.search.authority.crossref.batch";
204 var CREATE_HOLD                                 = "open-ils.circ:open-ils.circ.holds.create";
205 var CANCEL_HOLD                                 = "open-ils.circ:open-ils.circ.hold.cancel";
206 var UPDATE_USERNAME                             = "open-ils.actor:open-ils.actor.user.username.update";
207 var UPDATE_PASSWORD                             = "open-ils.actor:open-ils.actor.user.password.update";
208 var UPDATE_EMAIL                                        = "open-ils.actor:open-ils.actor.user.email.update";
209 var RENEW_CIRC                                          = "open-ils.circ:open-ils.circ.renew";
210 var CHECK_SPELL                                 = "open-ils.search:open-ils.search.spell_check";
211 var FETCH_REVIEWS                                       = "open-ils.search:open-ils.search.added_content.review.retrieve.all";
212 var FETCH_TOC                                           = "open-ils.search:open-ils.search.added_content.toc.retrieve";
213 var FETCH_ACONT_SUMMARY                 = "open-ils.search:open-ils.search.added_content.summary.retrieve";
214 var FETCH_USER_BYBARCODE                = "open-ils.actor:open-ils.actor.user.fleshed.retrieve_by_barcode";
215 var FETCH_ADV_MRIDS                             = "open-ils.search:open-ils.search.biblio.multiclass:1";
216 /* ---------------------------------------------------------------------------- */
217
218
219
220 /* ---------------------------------------------------------------------------- */
221 /* event callback functions. Other functions may be appended to these vars to
222         for added functionality.  */
223
224 G.evt                           = {}; /* events container */
225
226 function runEvt(scope, name, a, b, c, d, e, f, g) {
227         var evt = G.evt[scope][name];
228         for( var i in evt ) {
229                 evt[i](a, b, c, d, e, f, g);    
230         }
231 }
232
233 /* creates a new event if it doesn't already exist */
234 function createEvt(scope, name) {
235         if(!G.evt[scope]) G.evt[scope] = {};
236         if(G.evt[scope][name] == null)
237                 G.evt[scope][name] = []; 
238 }
239
240 function attachEvt(scope, name, action) {
241         createEvt(scope, name);
242         G.evt[scope][name].push(action);
243 }
244
245 function detachAllEvt(scope, name) {
246         G.evt[scope][name] = [];
247 }
248
249
250 createEvt("common", "init");                                            /* f() : what happens on page init */
251 createEvt("common", "pageRendered");                    /* f() : what happens when the page is done (up to the skin to call this even)*/
252 createEvt("common", "unload");                                  /* f() : what happens on window unload (clean memory, etc.)*/
253 createEvt("common", "locationChanged");         /* f() : what happens when the location has changed */
254 createEvt("common", "locationUpdated");         /* f() : what happens when the location has updated by the code */
255
256 createEvt("common", "run");                                             /* f() : make the page do stuff */
257 createEvt("result", "idsReceived");                             /* f(ids) */
258 createEvt("rresult", "recordDrawn");                    /* f(recordid, linkDOMNode) : after record is drawn, allow others (xul) to plugin actions */
259 createEvt("result", "preCollectRecords");               /* f() we're about to go and grab the recs */
260
261 createEvt("result", "hitCountReceived");                /* f() : display hit info, pagination, etc. */
262 createEvt("result", "recordReceived");                  /* f(mvr, pagePosition, isMr) : display the record*/
263 createEvt("result", "recordDrawn");                             /* f(recordid, linkDOMNode) : after record is drawn, allow others (xul) to plugin actions */
264 createEvt("result", "copyCountsReceived");      /* f(mvr, pagePosition, copyCountInfo) : display copy counts*/
265 createEvt("result", "allRecordsReceived");      /* f(mvrsArray) : add other page stuff, sidebars, etc.*/
266
267 createEvt("rdetail", "recordDrawn");                    /* f() : the record has been drawn */
268
269 createEvt("common", "loggedIn");                                        /* f() : user has just logged in */
270 createEvt('result', 'zeroHits');
271 createEvt('result', 'lowHits');
272 createEvt('rdetail', 'recordRetrieved');                        /* we are about to draw the rdetail page */
273
274
275
276
277