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