added url param that, if present, prevents search propogation to the advanced search...
[Evergreen.git] / Open-ILS / web / opac / common / js / config.js
1 /* Export some constants  ----------------------------------------------------- */
2
3 var SHOW_MR_DEFAULT = false; /* true if we show metarecords by default */
4
5 //var DO_AUTHORITY_LOOKUPS = false;
6 var DO_AUTHORITY_LOOKUPS = true;
7
8 /* URL param names */
9 var PARAM_TERM                  = "t";                  /* search term */
10 var PARAM_STYPE         = "tp";                 /* search type */
11 var PARAM_LOCATION      = "l";                  /* current location */
12 var PARAM_LASSO = "sg";                 /* current location */
13 var PARAM_DEPTH         = "d";                  /* search depth */
14 var PARAM_FORM                  = "f";                  /* search format */
15 var PARAM_OFFSET                = "o";                  /* search offset */
16 var PARAM_COUNT         = "c";                  /* hits per page */
17 var PARAM_HITCOUNT      = "hc";                 /* hits per page */
18 var PARAM_MRID                  = "m";                  /* metarecord id */
19 var PARAM_RID                   = "r";                  /* record id */
20 var PARAM_RLIST         = "rl";
21 var PARAM_ORIGLOC               = "ol";                 /* the original location */
22 var PARAM_AUTHTIME      = "at";                 /* inactivity timeout in seconds */
23 var PARAM_ADVTERM               = "adv";                        /* advanced search term */
24 var PARAM_ADVTYPE               = "adt";                        /* the advanced search type */
25 var PARAM_RTYPE         = "rt";
26 var PARAM_SORT                  = "s";
27 var PARAM_SORT_DIR      = "sd";
28 var PARAM_DEBUG         = "dbg";
29 var PARAM_CN                    = "cn";
30 var PARAM_LITFORM               = 'lf';
31 var PARAM_ITEMFORM      = 'if';
32 var PARAM_ITEMTYPE      = 'it';
33 var PARAM_BIBLEVEL      = 'bl';
34 var PARAM_AUDIENCE      = 'a';
35 var PARAM_SEARCHES      = 'ss';
36 var PARAM_LANGUAGE      = 'la';
37 var PARAM_TFORM         = 'tf'; /* temporary format for title result pages */
38 var PARAM_RDEPTH                = 'rd';
39 var PARAM_REDIR         = 're'; /* true if we have been redirected by IP (we're at a real lib) */
40 var PARAM_AVAIL     = 'av'; /* limit search results to available items */
41 var PARAM_COPYLOCS  = 'cl'; // copy (shelving) locations
42 var PARAM_PUBD_BEFORE = 'pdb';
43 var PARAM_PUBD_AFTER = 'pda';
44 var PARAM_PUBD_BETWEEN = 'pdt';
45 var PARAM_PUBD_DURING = 'pdd';
46 var PARAM_NOPERSIST_SEARCH = 'nps';
47
48 /* URL param values (see comments above) */
49 var TERM;  
50 var STYPE;  
51 var LOCATION;  
52 var LASSO;  
53 var DEPTH;  
54 var FORM; 
55 var OFFSET;
56 var COUNT;  
57 var HITCOUNT;  
58 var RANKS; 
59 var FONTSIZE;
60 var ORIGLOC;
61 var AUTHTIME;
62 var ADVTERM;
63 var ADVTYPE;
64 var MRID;
65 var RID;
66 var RTYPE;
67 var SORT;
68 var SORT_DIR;
69 var RLIST;
70 var DEBUG;
71 var CALLNUM;
72 var LITFORM;
73 var ITEMFORM;
74 var ITEMTYPE;
75 var BIBLEVEL;
76 var AUDIENCE;
77 var SEARCHES;
78 var LANGUAGE;
79 var TFORM;
80 var RDEPTH;
81 var AVAIL;
82 var COPYLOCS;
83 var PUBD_BEFORE;
84 var PUBD_AFTER;
85 var PUBD_BETWEEN;
86 var PUBD_DURING;
87
88 /* cookie values */
89 var SBEXTRAS; 
90 var SKIN;
91
92 /* cookies */
93 var COOKIE_SB           = "sbe";
94 var COOKIE_SES          = "ses";
95 //var COOKIE_IDS                = "ids"; /* list of mrecord ids */
96 //var COOKIE_SRIDS      = "srids"; /* record ids cached from a search */
97 var COOKIE_FONT = "fnt";
98 var COOKIE_SKIN = "skin";
99 var COOKIE_RIDS = "rids"; /* list of record ids */
100 var COOKIE_SEARCH = 'sr';
101
102 /* pages */
103 var MRESULT             = "mresult";
104 var RRESULT             = "rresult";
105 var RDETAIL             = "rdetail";
106 var MYOPAC              = "myopac";
107 var ADVANCED    = "advanced";
108 var HOME                        = "home";
109 var BBAGS               = "bbags";
110 var REQITEMS    = "reqitems";
111 var CNBROWSE    = "cnbrowse";
112
113 /* search type (STYPE) options */
114 var STYPE_AUTHOR        = "author";
115 var STYPE_TITLE = "title";
116 var STYPE_SUBJECT       = "subject";
117 var STYPE_SERIES        = "series";
118 var STYPE_KEYWORD       = "keyword";
119
120 /* record-level search types */
121 var RTYPE_MRID          = "mrid";
122 var RTYPE_COOKIE        = "cookie";
123 var RTYPE_AUTHOR        = STYPE_AUTHOR;
124 var RTYPE_SUBJECT       = STYPE_SUBJECT;
125 var RTYPE_TITLE = STYPE_TITLE;
126 var RTYPE_SERIES        = STYPE_SERIES;
127 var RTYPE_KEYWORD       = STYPE_KEYWORD;
128 var RTYPE_LIST          = "list";
129 var RTYPE_MULTI = 'multi';
130 var RTYPE_MARC          = 'marc';
131 var RTYPE_ISBN          = 'isbn';
132 var RTYPE_ISSN          = 'issn';
133 var RTYPE_TCN           = 'tcn';
134
135 var SORT_TYPE_REL                       = "rel";
136 var SORT_TYPE_AUTHOR            = STYPE_AUTHOR; 
137 var SORT_TYPE_TITLE             = STYPE_TITLE;
138 var SORT_TYPE_PUBDATE   = "pubdate";
139 var SORT_DIR_ASC                        = "asc";
140 var SORT_DIR_DESC                       = "desc";
141
142 /* types of advanced search */
143 var ADVTYPE_MULTI = 'ml';
144 var ADVTYPE_MARC        = 'ma';
145
146 /*
147 var ADVTYPE_ISBN        = 'isbn';
148 var ADVTYPE_ISSN        = 'issn';
149 */
150
151 var LOGOUT_WARNING_TIME = 30; /* "head up" for session timeout */
152
153 /* user preferences */
154 var PREF_HITS_PER               = 'opac.hits_per_page';
155 var PREF_DEF_FONT               = 'opac.default_font';
156 var PREF_HOLD_NOTIFY = 'opac.hold_notify';
157 var PREF_DEF_LOCATION = 'opac.default_search_location';
158 var PREF_DEF_DEPTH      = 'opac.default_search_depth';
159
160
161 /** If enabled, added content attribution links will be 
162     made visible where appropriate.  The added content vendor name 
163     and URL are defined in the entities in opac.dtd
164     */
165 var ENABLE_ADDED_CONTENT_ATTRIB_LINKS = false;
166
167
168 /* container for global variables shared accross pages */
169 var G           = {};
170 G.user  = null; /* global user object */
171 G.ui            = {} /* cache of UI components */
172
173
174 /* regexes */
175 var REGEX_BARCODE = /^\d+/; /* starts with a number */
176 var REGEX_PHONE = /^\d{3}-\d{3}-\d{4}$/; /* 111-222-3333 */
177
178
179 /* call me after page init and I will load references 
180         to all of the ui object id's defined below 
181         They will be stored in G.ui.<page>.<thingy>
182  */
183 function loadUIObjects() {
184         for( var p in config.ids ) {
185                 G.ui[p] = {};
186                 for( var o in config.ids[p] ) 
187                         G.ui[p][o] = getId(config.ids[p][o]);
188         }
189 }
190
191 /* try our best to free memory */
192 function clearUIObjects() {
193         for( var p in config.ids ) {
194                 for( var o in config.ids[p] ) {
195                         if(G.ui[p][o]) {
196                                 G.ui[p][o].onclick = null;
197                                 G.ui[p][o].onkeydown = null;
198                                 G.ui[p][o] = null;
199                         }
200                 }
201                 G.ui[p] = null;
202         }
203 }
204
205 /* ---------------------------------------------------------------------------- 
206         Set up ID's and CSS classes 
207         Any new ids, css, etc. may be added by giving the unique names and putting 
208         them into the correct scope 
209 /* ---------------------------------------------------------------------------- */
210
211 var config = {};
212
213 /* Set up the page names */
214 config.page = {};
215 config.page[HOME]                       = "index.xml";
216 config.page[ADVANCED]   = "advanced.xml";
217 config.page[MRESULT]            = "mresult.xml";
218 config.page[RRESULT]            = "rresult.xml";
219 config.page[MYOPAC]             = "myopac.xml";
220 config.page[RDETAIL]            = "rdetail.xml";
221 config.page[BBAGS]              = "bbags.xml";
222 config.page[REQITEMS]   = "reqitems.xml";
223 config.page[CNBROWSE]   = "cnbrowse.xml";
224
225 /* themes */
226 config.themes = {};
227
228 /* set up images  */
229 config.images = {};
230 config.images.logo = "main_logo.jpg";
231
232
233 /* set up ID's, CSS, and node names */
234 config.ids                              = {};
235 config.ids.result               = {};
236 config.ids.mresult      = {};
237 config.ids.advanced     = {};
238 config.ids.rresult      = {};
239 config.ids.myopac               = {};
240 config.ids.rdetail      = {};
241
242 config.css                              = {};
243 config.css.result               = {};
244 config.css.mresult      = {};
245 config.css.advanced     = {};
246 config.css.rresult      = {};
247 config.css.myopac               = {};
248 config.css.rdetail      = {};
249
250 config.names                    = {};
251 config.names.result     = {};
252 config.names.mresult = {};
253 config.names.advanced = {};
254 config.names.rresult = {};
255 config.names.myopac     = {};
256 config.names.rdetail = {};
257
258
259 /* id's shared accross skins. These *must* be defined */
260 config.ids.common = {};
261 config.ids.common.loading                       = "loading_div";                
262 config.ids.common.canvas                        = "canvas";                             
263 config.ids.common.canvas_main           = "canvas_main";                
264 config.ids.common.org_tree                      = "org_tree";                   
265 config.ids.common.org_container = "org_container";
266
267 config.ids.xul = {};
268
269
270 /* shared CSS */
271 config.css.hide_me = "hide_me";
272 config.css.dim = "dim";
273 config.css.dim2 = "dim2";
274
275
276 /* ---------------------------------------------------------------------------- */
277 /* These are pages that may replace the canvas */
278 /* ---------------------------------------------------------------------------- */
279 config.ids.altcanvas = {};
280
281
282
283 /* ---------------------------------------------------------------------------- */
284 /* Methods are defined as service:method 
285         An optional 3rd component is when a method is followed by a :1, such methods
286         have a staff counterpart and should have ".staff" appended to the method 
287         before the method is called when in XUL mode */
288
289 var SEARCH_MRS                                          = 'open-ils.search:open-ils.search.metabib.multiclass:1';
290 var SEARCH_RS                                           = 'open-ils.search:open-ils.search.biblio.multiclass:1';
291 var SEARCH_MRS_QUERY                    = 'open-ils.search:open-ils.search.metabib.multiclass.query:1';
292 var SEARCH_RS_QUERY             = 'open-ils.search:open-ils.search.biblio.multiclass.query:1';
293 var FETCH_SEARCH_RIDS                   = "open-ils.search:open-ils.search.biblio.record.class.search:1";
294 var FETCH_MRMODS                                        = "open-ils.search:open-ils.search.biblio.metarecord.mods_slim.retrieve";
295 var FETCH_MODS_FROM_COPY                = "open-ils.search:open-ils.search.biblio.mods_from_copy";
296 var FETCH_MR_COPY_COUNTS                = "open-ils.search:open-ils.search.biblio.metarecord.copy_count:1";
297 var FETCH_RIDS                                          = "open-ils.search:open-ils.search.biblio.metarecord_to_records:1";
298 var FETCH_RMODS                                 = "open-ils.search:open-ils.search.biblio.record.mods_slim.retrieve";
299 var FETCH_R_COPY_COUNTS                 = "open-ils.search:open-ils.search.biblio.record.copy_count:1";
300 var FETCH_FLESHED_USER                  = "open-ils.actor:open-ils.actor.user.fleshed.retrieve";
301 var FETCH_SESSION                                       = "open-ils.auth:open-ils.auth.session.retrieve";
302 var LOGIN_INIT                                          = "open-ils.auth:open-ils.auth.authenticate.init";
303 var LOGIN_COMPLETE                              = "open-ils.auth:open-ils.auth.authenticate.complete";
304 var LOGIN_DELETE                                        = "open-ils.auth:open-ils.auth.session.delete";
305 var FETCH_USER_PREFS                            = "open-ils.actor:open-ils.actor.patron.settings.retrieve"; 
306 var UPDATE_USER_PREFS                   = "open-ils.actor:open-ils.actor.patron.settings.update"; 
307 var FETCH_COPY_STATUSES                 = "open-ils.search:open-ils.search.config.copy_status.retrieve.all";
308 var FETCH_COPY_COUNTS_SUMMARY   = "open-ils.search:open-ils.search.biblio.copy_counts.summary.retrieve";
309 var FETCH_MARC_HTML                             = "open-ils.search:open-ils.search.biblio.record.html";
310 var FETCH_CHECKED_OUT_SUM               = "open-ils.actor:open-ils.actor.user.checked_out";
311 var FETCH_HOLDS                                 = "open-ils.circ:open-ils.circ.holds.retrieve";
312 var FETCH_FINES_SUMMARY                 = "open-ils.actor:open-ils.actor.user.fines.summary";
313 var FETCH_TRANSACTIONS                  = "open-ils.actor:open-ils.actor.user.transactions.have_charge.fleshed";
314 var FETCH_MONEY_BILLING                 = 'open-ils.circ:open-ils.circ.money.billing.retrieve.all';
315 var FETCH_CROSSREF                              = "open-ils.search:open-ils.search.authority.crossref";
316 var FETCH_CROSSREF_BATCH                = "open-ils.search:open-ils.search.authority.crossref.batch";
317 var CREATE_HOLD                                 = "open-ils.circ:open-ils.circ.holds.create";
318 var CREATE_HOLD_OVERRIDE                = "open-ils.circ:open-ils.circ.holds.create.override";
319 var CANCEL_HOLD                                 = "open-ils.circ:open-ils.circ.hold.cancel";
320 var UPDATE_USERNAME                             = "open-ils.actor:open-ils.actor.user.username.update";
321 var UPDATE_PASSWORD                             = "open-ils.actor:open-ils.actor.user.password.update";
322 var UPDATE_EMAIL                                        = "open-ils.actor:open-ils.actor.user.email.update";
323 var RENEW_CIRC                                          = "open-ils.circ:open-ils.circ.renew";
324 var CHECK_SPELL                                 = "open-ils.search:open-ils.search.spellcheck";
325 var FETCH_REVIEWS                                       = "open-ils.search:open-ils.search.added_content.review.retrieve.all";
326 var FETCH_TOC                                           = "open-ils.search:open-ils.search.added_content.toc.retrieve";
327 var FETCH_ACONT_SUMMARY                 = "open-ils.search:open-ils.search.added_content.summary.retrieve";
328 var FETCH_USER_BYBARCODE                = "open-ils.actor:open-ils.actor.user.fleshed.retrieve_by_barcode";
329 var FETCH_ADV_MARC_MRIDS                = "open-ils.search:open-ils.search.biblio.marc:1";
330 var FETCH_ADV_ISBN_RIDS                 = "open-ils.search:open-ils.search.biblio.isbn";
331 var FETCH_ADV_ISSN_RIDS                 = "open-ils.search:open-ils.search.biblio.issn";
332 var FETCH_ADV_TCN_RIDS                  = "open-ils.search:open-ils.search.biblio.tcn";
333 var FETCH_CNBROWSE                              = 'open-ils.search:open-ils.search.callnumber.browse';
334 var FETCH_CONTAINERS                            = 'open-ils.actor:open-ils.actor.container.retrieve_by_class';
335 var FETCH_CONTAINERS                            = 'open-ils.actor:open-ils.actor.container.retrieve_by_class';
336 var CREATE_CONTAINER                            = 'open-ils.actor:open-ils.actor.container.create';
337 var DELETE_CONTAINER                            = 'open-ils.actor:open-ils.actor.container.full_delete';
338 var CREATE_CONTAINER_ITEM               = 'open-ils.actor:open-ils.actor.container.item.create';
339 var DELETE_CONTAINER_ITEM               = 'open-ils.actor:open-ils.actor.container.item.delete';
340 var FLESH_CONTAINER                             = 'open-ils.actor:open-ils.actor.container.flesh';
341 var FLESH_PUBLIC_CONTAINER              = 'open-ils.actor:open-ils.actor.container.public.flesh';
342 var UPDATE_CONTAINER                            = 'open-ils.actor:open-ils.actor.container.update';
343 var FETCH_COPY                                          = 'open-ils.search:open-ils.search.asset.copy.retrieve';
344 var FETCH_FLESHED_COPY                  = 'open-ils.search:open-ils.search.asset.copy.fleshed2.retrieve';
345 var CHECK_HOLD_POSSIBLE                 = 'open-ils.circ:open-ils.circ.title_hold.is_possible';
346 var UPDATE_HOLD                                 = 'open-ils.circ:open-ils.circ.hold.update';
347 var FETCH_COPIES_FROM_VOLUME    = 'open-ils.search:open-ils.search.asset.copy.retrieve_by_cn_label:1';
348 var FETCH_VOLUME_BY_INFO                = 'open-ils.search:open-ils.search.call_number.retrieve_by_info'; /* XXX staff method? */
349 var FETCH_VOLUME                                        = 'open-ils.search:open-ils.search.asset.call_number.retrieve';
350 var FETCH_COPY_LOCATIONS                = 'open-ils.circ:open-ils.circ.copy_location.retrieve.all';
351 var FETCH_COPY_NOTES                            = 'open-ils.circ:open-ils.circ.copy_note.retrieve.all';
352 var FETCH_COPY_STAT_CATS                = 'open-ils.circ:open-ils.circ.asset.stat_cat_entries.fleshed.retrieve_by_copy';
353 var FETCH_LIT_FORMS                             = 'open-ils.search:open-ils.search.biblio.lit_form_map.retrieve.all';
354 var FETCH_ITEM_FORMS                            = 'open-ils.search:open-ils.search.biblio.item_form_map.retrieve.all';
355 var FETCH_ITEM_TYPES                            = 'open-ils.search:open-ils.search.biblio.item_type_map.retrieve.all';
356 var FETCH_BIB_LEVELS                            = 'open-ils.search:open-ils.search.biblio.bib_level_map.retrieve.all';
357 var FETCH_AUDIENCES                             = 'open-ils.search:open-ils.search.biblio.audience_map.retrieve.all';
358 var FETCH_HOLD_STATUS                   = 'open-ils.circ:open-ils.circ.hold.status.retrieve';
359 var FETCH_NON_CAT_CIRCS                 = 'open-ils.circ:open-ils.circ.open_non_cataloged_circulation.user';
360 var FETCH_NON_CAT_CIRC                  = 'open-ils.circ:open-ils.circ.non_cataloged_circulation.retrieve';
361 var FETCH_NON_CAT_TYPES                 = "open-ils.circ:open-ils.circ.non_cat_types.retrieve.all";
362 var FETCH_BRE                                           = 'open-ils.search:open-ils.search.biblio.record_entry.slim.retrieve';
363 var CHECK_USERNAME                              = 'open-ils.actor:open-ils.actor.username.exists';
364 var FETCH_CIRC_BY_ID                            = 'open-ils.circ:open-ils.circ.retrieve';
365 var FETCH_MR_DESCRIPTORS                = 'open-ils.search:open-ils.search.metabib.record_to_descriptors';
366 var FETCH_HIGHEST_PERM_ORG              = 'open-ils.actor:open-ils.actor.user.perm.highest_org.batch';
367 var FETCH_USER_NOTES                            = 'open-ils.actor:open-ils.actor.note.retrieve.all';
368 var FETCH_ORG_BY_SHORTNAME              = 'open-ils.actor:open-ils.actor.org_unit.retrieve_by_shorname';
369 var FETCH_BIB_ID_BY_BARCODE = 'open-ils.search:open-ils.search.bib_id.by_barcode';
370 var FETCH_ORG_SETTING = 'open-ils.actor:open-ils.actor.ou_setting.ancestor_default';
371
372 /* ---------------------------------------------------------------------------- */
373
374
375 /* ---------------------------------------------------------------------------- */
376 /* event callback functions. Other functions may be appended to these vars to
377         for added functionality.  */
378
379 G.evt                           = {}; /* events container */
380
381 function runEvt(scope, name, a, b, c, d, e, f, g) {
382         var evt = G.evt[scope][name];
383         for( var i in evt ) {
384                 evt[i](a, b, c, d, e, f, g);    
385         }
386 }
387
388 /* creates a new event if it doesn't already exist */
389 function createEvt(scope, name) {
390         if(!G.evt[scope]) G.evt[scope] = {};
391         if(G.evt[scope][name] == null)
392                 G.evt[scope][name] = []; 
393 }
394
395 function attachEvt(scope, name, action) {
396         createEvt(scope, name);
397         G.evt[scope][name].push(action);
398 }
399
400 function detachAllEvt(scope, name) {
401         G.evt[scope][name] = [];
402 }
403
404
405 createEvt("common", "init");                                            /* f() : what happens on page init */
406 createEvt("common", "pageRendered");                    /* f() : what happens when the page is done (up to the skin to call this even)*/
407 createEvt("common", "unload");                                  /* f() : what happens on window unload (clean memory, etc.)*/
408 createEvt("common", "locationChanged");         /* f() : what happens when the location has changed */
409 createEvt("common", "locationUpdated");         /* f() : what happens when the location has updated by the code */
410
411 createEvt("common", "run");                                             /* f() : make the page do stuff */
412 createEvt("result", "idsReceived");                             /* f(ids) */
413 createEvt("rresult", "recordDrawn");                    /* f(recordid, linkDOMNode) : after record is drawn, allow others (xul) to plugin actions */
414 createEvt("result", "preCollectRecords");               /* f() we're about to go and grab the recs */
415
416 createEvt("result", "hitCountReceived");                /* f() : display hit info, pagination, etc. */
417 createEvt("result", "recordReceived");                  /* f(mvr, pagePosition, isMr) : display the record*/
418 createEvt("result", "recordDrawn");                             /* f(recordid, linkDOMNode) : after record is drawn, allow others (xul) to plugin actions */
419 createEvt("result", "copyCountsReceived");      /* f(mvr, pagePosition, copyCountInfo) : display copy counts*/
420 createEvt("result", "allRecordsReceived");      /* f(mvrsArray) : add other page stuff, sidebars, etc.*/
421
422 createEvt("rdetail", "recordDrawn");                    /* f() : the record has been drawn */
423
424 createEvt("common", "loggedIn");                                        /* f() : user has just logged in */
425 createEvt('result', 'zeroHits');
426 createEvt('result', 'lowHits');
427 createEvt('rdetail', 'recordRetrieved');                        /* we are about to draw the rdetail page */
428 createEvt('common', 'depthChanged');
429 createEvt('common', 'holdUpdated'); 
430 createEvt('common', 'holdUpdateCanceled'); 
431
432 createEvt('rdetail', 'nextPrevDrawn');
433
434
435
436
437