1 /* - Request ------------------------------------------------------------- */
3 /* define it again here for pages that don't load RemoteRequest */
4 function isXUL() { try { if(IAMXUL) return true;}catch(e){return false;}; }
7 var cookieManager = new HTTP.Cookies();
9 var __ilsEvent; /* the last event the occurred */
12 function Request(type) {
14 var s = type.split(":");
15 if(s[2] == "1" && isXUL()) s[1] += ".staff";
16 this.request = new RemoteRequest(s[0], s[1]);
20 if(!location.href.match(/^https:/))
21 this.request.setSecure(false);
25 if( G.user && G.user.session ) {
26 /* if the user is logged in, all activity resets the timeout
27 This is not entirely accurate in the sense that not all
28 requests will reset the server timeout - this should
29 get close enough, however.
31 var at = getAuthtime();
32 if(at) new AuthTimer(at).run();
36 for( var x = 1; x!= arguments.length; x++ ) {
38 this.request.addParam(arguments[x]);
43 for( var i = 0; i != p.length; i++ ) {
44 if( i > 0 ) str += ", "
47 _debug('request ' + s[0] + ' ' + s[1] + ' ' + str );
49 } else if( DEBUGSLIM ) {
50 _debug('request ' + s[1]);
54 Request.prototype.callback = function(cal) {this.request.setCompleteCallback(cal);}
55 Request.prototype.send = function(block){this.request.send(block);}
56 Request.prototype.result = function(){return this.request.getResultObject();}
58 function showCanvas() {
59 for( var x in G.ui.altcanvas ) {
60 hideMe(G.ui.altcanvas[x]);
62 hideMe(G.ui.common.loading);
63 unHideMe(G.ui.common.canvas_main);
64 try{G.ui.searchbar.text.focus();}catch(e){}
67 function swapCanvas(newNode) {
68 for( var x in G.ui.altcanvas )
69 hideMe(G.ui.altcanvas[x]);
71 hideMe(G.ui.common.loading);
72 hideMe(G.ui.common.canvas_main);
76 /* finds the name of the current page */
77 var currentPage = null;
78 function findCurrentPage() {
79 if(currentPage) return currentPage;
82 for( var p in config.page ) pages.push(config.page[p]);
83 pages = pages.sort( function(a,b){ return - (a.length - b.length); } );
85 var path = location.pathname;
86 if(!path.match(/.*\.xml$/))
87 path += "index.xml"; /* in case they go to / */
90 for( var p in pages ) {
91 if( path.indexOf(pages[p]) != -1)
95 for( var p in config.page ) {
96 if(config.page[p] == page) {
105 /* sets all of the params values ----------------------------- */
106 function initParams() {
109 /* handle the location var */
111 var loc = cgi.param(PARAM_LOCATION);
114 if(isNaN(loc)) org = findOrgUnitSN(loc);
117 if ( parseInt(loc) < 0 ) org = findOrgLasso( -1 * loc );
118 else org = findOrgUnit(loc);
122 LOCATION = org ? org.id() : null;
125 loc = cgi.param(PARAM_ORIGLOC);
127 org = findOrgUnit(loc);
128 if(!org) org = findOrgUnitSN(loc);
130 ORIGLOC = (org) ? org.id() : null;
133 DEPTH = parseInt(cgi.param(PARAM_DEPTH));
134 if(isNaN(DEPTH)) DEPTH = null;
137 TERM = cgi.param(PARAM_TERM);
138 STYPE = cgi.param(PARAM_STYPE);
139 FORM = cgi.param(PARAM_FORM);
140 //DEPTH = parseInt(cgi.param(PARAM_DEPTH));
141 OFFSET = parseInt(cgi.param(PARAM_OFFSET));
142 COUNT = parseInt(cgi.param(PARAM_COUNT));
143 HITCOUNT = parseInt(cgi.param(PARAM_HITCOUNT));
144 MRID = parseInt(cgi.param(PARAM_MRID));
145 RID = parseInt(cgi.param(PARAM_RID));
146 AUTHTIME = parseInt(cgi.param(PARAM_AUTHTIME));
147 ADVTERM = cgi.param(PARAM_ADVTERM);
148 ADVTYPE = cgi.param(PARAM_ADVTYPE);
149 RTYPE = cgi.param(PARAM_RTYPE);
150 SORT = cgi.param(PARAM_SORT);
151 SORT_DIR = cgi.param(PARAM_SORT_DIR);
152 DEBUG = cgi.param(PARAM_DEBUG);
153 CALLNUM = cgi.param(PARAM_CN);
154 LITFORM = cgi.param(PARAM_LITFORM);
155 ITEMFORM = cgi.param(PARAM_ITEMFORM);
156 ITEMTYPE = cgi.param(PARAM_ITEMTYPE);
157 BIBLEVEL = cgi.param(PARAM_BIBLEVEL);
158 AUDIENCE = cgi.param(PARAM_AUDIENCE);
159 SEARCHES = cgi.param(PARAM_SEARCHES);
160 LANGUAGE = cgi.param(PARAM_LANGUAGE);
161 TFORM = cgi.param(PARAM_TFORM);
162 RDEPTH = cgi.param(PARAM_RDEPTH);
163 AVAIL = cgi.param(PARAM_AVAIL);
165 /* set up some sane defaults */
166 //if(isNaN(DEPTH)) DEPTH = 0;
167 if(isNaN(RDEPTH)) RDEPTH = 0;
168 if(isNaN(OFFSET)) OFFSET = 0;
169 if(isNaN(COUNT)) COUNT = 10;
170 if(isNaN(HITCOUNT)) HITCOUNT = 0;
171 if(isNaN(MRID)) MRID = 0;
172 if(isNaN(RID)) RID = 0;
173 if(isNaN(ORIGLOC)) ORIGLOC = 0; /* so we know it hasn't been set */
174 if(isNaN(AUTHTIME)) AUTHTIME = 0;
175 if(ADVTERM==null) ADVTERM = "";
176 if(isNaN(AVAIL)) AVAIL = 0;
179 function clearSearchParams() {
206 function initCookies() {
207 FONTSIZE = "regular";
208 var font = cookieManager.read(COOKIE_FONT);
210 if(font) FONTSIZE = font;
211 SKIN = cookieManager.read(COOKIE_SKIN);
212 if(findCurrentPage() == HOME)
213 cookieManager.remove(COOKIE_SEARCH);
218 /* URL param accessors */
219 function getTerm(){return TERM;}
220 function getStype(){return STYPE;}
221 function getLocation(){return LOCATION;}
222 function getDepth(){return DEPTH;}
223 function getForm(){return FORM;}
224 function getTform(){return TFORM;}
225 function getOffset(){return OFFSET;}
226 function getDisplayCount(){return COUNT;}
227 function getHitCount(){return HITCOUNT;}
228 function getMrid(){return MRID;};
229 function getRid(){return RID;};
230 function getOrigLocation(){return ORIGLOC;}
231 function getAuthtime() { return AUTHTIME; }
232 function getSearchBarExtras(){return SBEXTRAS;}
233 function getFontSize(){return FONTSIZE;};
234 function getSkin(){return SKIN;};
235 function getAdvTerm(){return ADVTERM;}
236 function getAdvType(){return ADVTYPE;}
237 function getRtype(){return RTYPE;}
238 function getSort(){return SORT;}
239 function getSortDir(){return SORT_DIR;}
240 function getDebug(){return DEBUG;}
241 function getCallnumber() { return CALLNUM; }
242 function getLitForm() { return LITFORM; }
243 function getItemForm() { return ITEMFORM; }
244 function getItemType() { return ITEMTYPE; }
245 function getBibLevel() { return BIBLEVEL; }
246 function getAudience() { return AUDIENCE; }
247 function getSearches() { return SEARCHES; }
248 function getLanguage() { return LANGUAGE; }
249 function getRdepth() { return RDEPTH; }
250 function getAvail() { return AVAIL; }
253 function findBasePath() {
254 var path = location.pathname;
255 if(!path.match(/.*\.xml$/)) path += "index.xml";
256 var idx = path.indexOf(config.page[findCurrentPage()]);
257 return path.substring(0, idx);
260 function findBaseURL(ssl) {
261 var path = findBasePath();
262 var proto = (ssl) ? "https:" : "http:";
264 /* strip port numbers. This is necessary for browsers that
265 send an explicit <host>:80, 443 - explicit ports
266 break links that need to change ports (e.g. http -> https) */
267 var h = location.host.replace(/:.*/,'');
269 return proto + "//" + h + path;
273 function buildISBNSrc(isbn) {
274 return "http://" + location.host + "/jackets/" + isbn;
278 function buildImageLink(name, ssl) {
279 return findBaseURL(ssl) + "../../../../images/" + name;
282 function buildExtrasLink(name, ssl) {
283 return findBaseURL(ssl) + "../../../../extras/" + name;
287 function _debug(str) {
288 try { dump('dbg: ' + str + '\n'); } catch(e) {}
290 /* potentially useful, but usually just annoying */
293 if(!consoleService) {
295 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
296 this.consoleService = Components.classes['@mozilla.org/consoleservice;1']
297 .getService(Components.interfaces.nsIConsoleService);
303 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
304 consoleService.logStringMessage(str + '\n');
311 function buildOPACLink(args, slim, ssl) {
317 string = findBaseURL(ssl);
318 if(args.page) string += config.page[args.page];
319 else string += config.page[findCurrentPage()];
322 /* this may seem unnecessary.. safety precaution for now */
324 if( args[PARAM_DEPTH] == null )
325 args[PARAM_DEPTH] = getDepth();
330 for( var x in args ) {
332 if(x == "page" || v == null || v == undefined || v+'' == 'NaN' ) continue;
333 if(x == PARAM_OFFSET && v == 0) continue;
334 if(x == PARAM_COUNT && v == 10) continue;
335 if(x == PARAM_FORM && v == 'all' ) continue;
336 if( instanceOf(v, Array) && v.length ) {
337 for( var i = 0; i < v.length; i++ ) {
338 string += "&" + x + "=" + encodeURIComponent(v[i]);
341 string += "&" + x + "=" + encodeURIComponent(v);
346 string += _appendParam(DEBUG, PARAM_DEBUG, args, getDebug, string);
347 if(getOrigLocation() != 1)
348 string += _appendParam(ORIGLOC, PARAM_ORIGLOC, args, getOrigLocation, string);
350 string += _appendParam(TERM, PARAM_TERM, args, getTerm, string);
352 string += _appendParam(STYPE, PARAM_STYPE, args, getStype, string);
353 if(getLocation() != 1)
354 string += _appendParam(LOCATION, PARAM_LOCATION, args, getLocation, string);
355 if(getDepth() != null)
356 string += _appendParam(DEPTH, PARAM_DEPTH, args, getDepth, string);
357 if(getForm() && (getForm() != 'all') )
358 string += _appendParam(FORM, PARAM_FORM, args, getForm, string);
359 if(getTform() && (getTform() != 'all') )
360 string += _appendParam(TFORM, PARAM_TFORM, args, getTform, string);
362 string += _appendParam(OFFSET, PARAM_OFFSET, args, getOffset, string);
363 if(getDisplayCount() != 10)
364 string += _appendParam(COUNT, PARAM_COUNT, args, getDisplayCount, string);
366 string += _appendParam(HITCOUNT, PARAM_HITCOUNT, args, getHitCount, string);
368 string += _appendParam(MRID, PARAM_MRID, args, getMrid, string);
370 string += _appendParam(RID, PARAM_RID, args, getRid, string);
372 string += _appendParam(AUTHTIME, PARAM_AUTHTIME, args, getAuthtime, string);
374 string += _appendParam(ADVTERM, PARAM_ADVTERM, args, getAdvTerm, string);
376 string += _appendParam(ADVTYPE, PARAM_ADVTYPE, args, getAdvType, string);
378 string += _appendParam(RTYPE, PARAM_RTYPE, args, getRtype, string);
380 string += _appendParam(ITEMFORM, PARAM_ITEMFORM, args, getItemForm, string);
382 string += _appendParam(ITEMTYPE, PARAM_ITEMTYPE, args, getItemType, string);
384 string += _appendParam(BIBLEVEL, PARAM_BIBLEVEL, args, getBibLevel, string);
386 string += _appendParam(LITFORM, PARAM_LITFORM, args, getLitForm, string);
388 string += _appendParam(AUDIENCE, PARAM_AUDIENCE, args, getAudience, string);
390 string += _appendParam(SEARCHES, PARAM_SEARCHES, args, getSearches, string);
392 string += _appendParam(LANGUAGE, PARAM_LANGUAGE, args, getLanguage, string);
393 if(getRdepth() != null)
394 string += _appendParam(RDEPTH, PARAM_RDEPTH, args, getRdepth, string);
395 if(getSort() != null)
396 string += _appendParam(SORT, PARAM_SORT, args, getSort, string);
397 if(getSortDir() != null)
398 string += _appendParam(SORT_DIR, PARAM_SORT_DIR, args, getSortDir, string);
400 string += _appendParam(AVAIL, PARAM_AVAIL, args, getAvail, string);
402 return string.replace(/\&$/,'').replace(/\?\&/,"?");
406 function _appendParam( fieldVar, fieldName, overrideArgs, getFunc, string ) {
410 if( fieldVar != null &&
411 (fieldVar +'' != 'NaN') &&
412 overrideArgs[fieldName] == null &&
414 getFunc()+'' != '' ) {
416 ret = "&" + fieldName + "=" + encodeURIComponent(getFunc());
422 /* ----------------------------------------------------------------------- */
423 function cleanISBN(isbn) {
425 isbn = isbn.toString().replace(/^\s+/,"");
426 var idx = isbn.indexOf(" ");
427 if(idx > -1) { isbn = isbn.substring(0, idx); }
433 /* builds a link that goes to the title listings for a metarecord */
434 function buildTitleLink(rec, link) {
436 link.appendChild(text(normalize(truncate(rec.title(), 65))));
439 args[PARAM_OFFSET] = 0;
440 args[PARAM_MRID] = rec.doc_id();
441 args[PARAM_RTYPE] = RTYPE_MRID;
442 link.setAttribute("href", buildOPACLink(args));
445 function buildTitleDetailLink(rec, link) {
447 link.appendChild(text(normalize(truncate(rec.title(), 65))));
450 //args[PARAM_OFFSET] = 0;
451 args[PARAM_RID] = rec.doc_id();
452 link.setAttribute("href", buildOPACLink(args));
455 /* 'type' is one of STYPE_AUTHOR, STYPE_SUBJECT, ... found in config.js
456 'trunc' is the number of characters to show in the string, defaults to 65 */
457 function buildSearchLink(type, string, linknode, trunc) {
458 if(!trunc) trunc = 65;
460 if( SHOW_MR_DEFAULT) {
464 args[PARAM_RTYPE] = type;
466 args[PARAM_OFFSET] = 0;
467 args[PARAM_TERM] = string;
468 args[PARAM_STYPE] = type;
469 linknode.appendChild(text(normalize(truncate(string, trunc))));
470 linknode.setAttribute("href", buildOPACLink(args));
473 function setSessionCookie(ses) {
474 cookieManager.write(COOKIE_SES, ses, -1);
479 /* ----------------------------------------------------------------------- */
480 /* user session handling */
481 /* ----------------------------------------------------------------------- */
482 /* session is the login session. If no session is provided, we attempt
483 to find one in the cookies. If 'force' is true we retrieve the
484 user from the server even if there is already a global user present.
485 if ses != G.user.session, we also force a grab */
486 function grabUser(ses, force) {
488 if(!ses && isXUL()) {
489 stash = fetchXULStash();
490 ses = stash.session.key
491 _debug("stash auth token = " + ses);
495 ses = cookieManager.read(COOKIE_SES);
496 /* https cookies don't show up in http servers.. */
499 if(!ses) return false;
502 if(G.user && G.user.session == ses)
505 /* first make sure the session is valid */
506 var request = new Request(FETCH_SESSION, ses, 1 );
507 request.request.alertEvent = false;
509 var user = request.result();
513 return false; /* unable to grab the session */
516 if( !(typeof user == 'object' && user._isfieldmapper) ) {
522 G.user.fleshed = false;
523 G.user.session = ses;
524 setSessionCookie(ses);
527 if(G.user.prefs['opac.hits_per_page'])
528 COUNT = parseInt(G.user.prefs['opac.hits_per_page']);
530 if(G.user.prefs[PREF_DEF_FONT])
531 setFontSize(G.user.prefs[PREF_DEF_FONT]);
533 var at = getAuthtime();
534 //if(isXUL()) at = xulG['authtime'];
536 if(at && !isXUL()) new AuthTimer(at).run();
541 /* sets the 'prefs' field of the user object to their preferences
542 and returns the preferences */
543 function grabUserPrefs(user, force) {
544 if(user == null) user = G.user;
545 if(!force && user.prefs) return user.prefs;
546 var req = new Request(FETCH_USER_PREFS, user.session, user.id());
548 user.prefs = req.result();
552 function grabFleshedUser() {
554 if(!G.user || !G.user.session) {
556 if(!G.user || !G.user.session) return null;
559 if(G.user.fleshed) return G.user;
561 var req = new Request(FETCH_FLESHED_USER, G.user.session);
564 G.user = req.result();
566 if(!G.user || G.user.length == 0) {
567 G.user = null; return false;
568 cookieManager.write(COOKIE_SES,"");
571 G.user.session = ses;
572 G.user.fleshed = true;
574 setSessionCookie(ses);
578 function checkUserSkin(new_skin) {
580 return; /* XXX do some debugging with this... */
582 var user_skin = getSkin();
583 var cur_skin = grabSkinFromURL();
585 if(new_skin) user_skin = new_skin;
590 if(grabUserPrefs()) {
591 user_skin = G.user.prefs["opac.skin"];
592 cookieManager.write( COOKIE_SKIN, user_skin, '+1y' );
597 if(!user_skin) return;
599 if( cur_skin != user_skin ) {
600 var url = buildOPACLink();
601 goTo(url.replace(cur_skin, user_skin));
605 function updateUserSetting(setting, value, user) {
606 if(user == null) user = G.user;
609 var req = new Request( UPDATE_USER_PREFS, user.session, a );
614 function commitUserPrefs() {
615 var req = new Request(
616 UPDATE_USER_PREFS, G.user.session, null, G.user.prefs );
621 function grabSkinFromURL() {
622 var path = findBasePath();
623 path = path.replace("/xml/", "");
625 for( var i = path.length - 1; i >= 0; i-- ) {
626 var ch = path.charAt(i);
632 for( i = skin.length - 1; i >= 0; i--)
633 skin2 += skin.charAt(i);
639 /* returns a fleshed G.user on success, false on failure */
640 function doLogin(suppressEvents) {
644 var uname = G.ui.login.username.value;
645 var passwd = G.ui.login.password.value;
647 var init_request = new Request( LOGIN_INIT, uname );
648 init_request.send(true);
649 var seed = init_request.result();
651 if( ! seed || seed == '0') {
652 alert( "Error Communicating with Authentication Server" );
657 password : hex_md5(seed + hex_md5(passwd)),
659 org : getOrigLocation()
662 r = fetchOrgSettingDefault(globalOrgTree.id(), 'opac.barcode_regex');
663 if(r) REGEX_BARCODE = new RegExp(r);
665 if( uname.match(REGEX_BARCODE) ) args.barcode = uname;
666 else args.username = uname;
668 var auth_request = new Request( LOGIN_COMPLETE, args );
670 auth_request.request.alertEvent = false;
671 auth_request.send(true);
672 var auth_result = auth_request.result();
675 alertId('patron_login_failed');
679 if( checkILSEvent(auth_result) ) {
681 if( auth_result.textcode == 'PATRON_INACTIVE' ) {
682 alertId('patron_inactive_alert');
686 if( auth_result.textcode == 'PATRON_CARD_INACTIVE' ) {
687 alertId('patron_card_inactive_alert');
691 if( auth_result.textcode == 'LOGIN_FAILED' ||
692 auth_result.textcode == 'PERM_FAILURE' ) {
693 alertId('patron_login_failed');
699 AUTHTIME = parseInt(auth_result.payload.authtime);
700 var u = grabUser(auth_result.payload.authtoken, true);
701 if(u && ! suppressEvents)
702 runEvt( "common", "locationChanged", u.ws_ou(), findOrgDepth(u.ws_ou()) );
709 function doLogout(noredirect) {
711 /* cancel everything else */
714 /* be nice and delete the session from the server */
715 if(G.user && G.user.session) {
716 var req = new Request(LOGIN_DELETE, G.user.session);
718 try { req.result(); } catch(E){}
723 /* remove any cached data */
724 //cookieManager.remove(COOKIE_IDS);
725 //cookieManager.remove(COOKIE_SRIDS);
726 cookieManager.remove(COOKIE_RIDS);
727 cookieManager.remove(COOKIE_SES);
728 cookieManager.remove(COOKIE_SKIN);
729 cookieManager.remove(COOKIE_SEARCH);
731 checkUserSkin("default");
736 args[PARAM_TERM] = "";
737 args[PARAM_LOCATION] = getOrigLocation();
738 args[PARAM_DEPTH] = findOrgDepth(getOrigLocation());
743 try{ if(isFrontPage) nored = true; } catch(e){nored = false;}
744 if(!nored) goTo(buildOPACLink(args));
748 function hideMe(obj) { addCSSClass(obj, config.css.hide_me); }
749 function unHideMe(obj) { removeCSSClass(obj, config.css.hide_me); }
752 /* ----------------------------------------------------------------------- */
753 /* build the org tree */
754 /* ----------------------------------------------------------------------- */
755 function drawOrgTree() {
756 //setTimeout( 'buildOrgSelector(G.ui.common.org_tree, orgTreeSelector);', 10 );
757 setTimeout( 'buildOrgSelector(G.ui.common.org_tree, orgTreeSelector);', 1 );
761 function buildOrgSelector(node) {
762 var tree = new SlimTree(node,'orgTreeSelector');
763 orgTreeSelector = tree;
764 for( var i in orgArraySearcher ) {
765 var node = orgArraySearcher[i];
766 if( node == null ) continue;
767 if(!isXUL() && !isTrue(node.opac_visible())) continue;
768 if(node.parent_ou() == null)
769 tree.addNode(node.id(), -1, node.name(),
770 "javascript:orgSelect(" + node.id() + ");", node.name());
772 tree.addNode(node.id(), node.parent_ou(), node.name(),
773 "javascript:orgSelect(" + node.id() + ");", node.name());
776 hideMe($('org_loading_div'));
777 unHideMe($('org_selector_tip'));
781 function orgSelect(id) {
783 runEvt("common", "locationChanged", id, findOrgDepth(id) );
785 removeChildren(G.ui.common.now_searching);
786 G.ui.common.now_searching.appendChild(text(findOrgUnit(id).name()));
789 function setFontSize(size) {
791 cookieManager.write(COOKIE_FONT, size, '+1y');
794 var resourceFormats = [
797 "sound recording", "software, multimedia",
802 "three dimensional object" ];
805 function modsFormatToMARC(format) {
811 case "sound recording":
813 case "sound recording-nonmusical":
815 case "sound recording-musical":
817 case "software, multimedia":
823 case "mixed material":
825 case "notated music":
827 case "three dimensional object":
834 function MARCFormatToMods(format) {
840 return "moving image";
842 return "sound recording-nonmusical";
844 return "sound recording-musical";
846 return "software, multimedia";
848 return "still image";
851 return "cartographic";
854 return "mixed material";
857 return "notated music";
859 return "three dimensional object";
864 function MARCTypeToFriendly(format) {
865 var words = $('format_words');
868 case 't' : return $n(words, 'at').innerHTML;
870 var node = $n(words,format);
871 if( node ) return node.innerHTML;
876 function setResourcePic( img, resource ) {
877 img.setAttribute( "src", "../../../../images/tor/" + resource + ".jpg");
878 img.title = resource;
883 function msg( text ) {
884 try { alert( text ); } catch(e) {}
887 function findRecord(id,type) {
889 for( var i = 0; i != recordsCache.length; i++ ) {
890 var rec = recordsCache[i];
891 if( rec && rec.doc_id() == id ) return rec;
894 var meth = FETCH_RMODS
895 if(type == 'M') meth = FETCH_MRMODS;
896 var req = new Request(meth, id);
897 req.request.alertEvent = false;
899 var res = req.result();
900 if( checkILSEvent(res) ) return null;
904 function Timer(name, node){
909 Timer.prototype.start =
910 function(){_timerRun(this.name);}
911 Timer.prototype.stop =
912 function(){this.done = true;}
913 function _timerRun(tname) {
917 if(_t.count > 100) return;
919 if( (_t.count % 5) == 0 )
921 _t.node.appendChild(text(str));
922 setTimeout("_timerRun('"+tname+"');", 200);
926 function checkILSEvent(obj) {
927 if( obj && obj.ilsevent != null && obj.ilsevent != 0 )
928 return parseInt(obj.ilsevent);
933 function alertILSEvent(evt, msg) {
936 alert(msg +'\n' + evt.textcode + '\n' + evt.desc );
938 alert(evt.textcode + '\n' + evt.desc );
943 function AuthTimer(time) {
944 this.time = (time - LOGOUT_WARNING_TIME) * 1000;
946 try {clearTimeout(__authTimer.id)} catch(e){}
950 AuthTimer.prototype.run = function() {
951 this.id = setTimeout('_authTimerAlert()', this.time);
954 function _authTimerAlert() {
955 alert( $('auth_session_expiring').innerHTML );
956 if(!grabUser(null, true)) doLogout();
960 function grabUserByBarcode( authtoken, barcode ) {
961 var req = new Request( FETCH_USER_BYBARCODE, authtoken, barcode );
968 goTo(buildOPACLink({page:HOME}));
972 function buildOrgSel(selector, org, offset) {
973 insertSelectorVal( selector, -1,
974 org.name(), org.id(), null, findOrgDepth(org) - offset );
975 for( var c in org.children() )
976 buildOrgSel( selector, org.children()[c], offset);
980 function parseForm(form) {
983 var it = form.replace(/-\w+$/,"");
988 if(form.match(/-/)) itf = form.replace(/^\w+-/,"");
992 for( var i = 0; i < it.length; i++ )
993 item_type.push( it.charAt(i) );
998 for( var i = 0; i < itf.length; i++ )
999 item_form.push( itf.charAt(i) );
1002 return {item_type: item_type, item_form:item_form};
1006 function isTrue(x) { return ( x && x != "0" && !(x+'').match(/^f$/i) ); }
1008 function fetchPermOrgs() {
1009 var a = []; /* why does arguments come accross as an object and not an array? */
1010 for( var i = 0; i < arguments.length; i++ )
1011 a.push(arguments[i])
1013 var preq = new Request(FETCH_HIGHEST_PERM_ORG,
1014 G.user.session, G.user.id(), a );
1016 return preq.result();
1020 function print_tabs(t) {
1022 for (var j = 0; j < t; j++ ) { r = r + " "; }
1025 function formatJSON(s) {
1026 var r = ''; var t = 0;
1028 if (s[i] == '{' || s[i] == '[' ) {
1029 r = r + s[i] + "\n" + print_tabs(++t);
1030 } else if (s[i] == '}' || s[i] == ']') {
1031 t--; r = r + "\n" + print_tabs(t) + s[i];
1032 } else if (s[i] == ',') {
1033 r = r + s[i] + "\n" + print_tabs(t);