1 config.ids.result = {};
2 config.css.result = {};
3 config.names.result = {};
4 config.ids.result.offset_start = "offset_start";
5 config.ids.result.offset_end = "offset_end";
6 config.ids.result.result_count = "result_count";
7 config.ids.result.next_link = 'next_link';
8 config.ids.result.prev_link = 'prev_link';
9 config.ids.result.home_link = 'search_home_link';
10 config.ids.result.end_link = 'end_link';
11 config.ids.result.main_table = 'result_table';
12 config.ids.result.row_template = 'result_table_template';
13 config.ids.result.num_pages = 'num_pages';
14 config.ids.result.current_page = 'current_page';
15 config.css.result.nav_active = "nav_link_active";
16 config.ids.result.top_div = "result_table_div";
17 config.ids.result.nav_links = "search_nav_links";
18 config.ids.result.info = "result_info_div";
19 config.css.result.cc_cell_even = "copy_count_cell_even";
20 config.names.result.item_jacket = "item_jacket";
21 config.names.result.item_title = "item_title";
22 config.names.result.item_author = "item_author";
23 config.names.result.counts_row = "counts_row";
24 config.names.result.count_cell = "copy_count_cell";
25 config.names.result.format_cell = 'result_table_format_cell';
26 config.names.result.format_link = 'resource_link'
27 config.names.result.format_pic = 'format_pic'
28 config.ids.result = {};
29 config.css.result = {};
30 config.names.result = {};
31 config.ids.result.offset_start = "offset_start";
32 config.ids.result.offset_end = "offset_end";
33 config.ids.result.result_count = "result_count";
34 config.ids.result.next_link = 'next_link';
35 config.ids.result.prev_link = 'prev_link';
36 config.ids.result.home_link = 'search_home_link';
37 config.ids.result.end_link = 'end_link';
38 config.ids.result.main_table = 'result_table';
39 config.ids.result.row_template = 'result_table_template';
40 config.ids.result.num_pages = 'num_pages';
41 config.ids.result.current_page = 'current_page';
42 config.css.result.nav_active = "nav_link_active";
43 config.ids.result.top_div = "result_table_div";
44 config.ids.result.nav_links = "search_nav_links";
45 config.ids.result.info = "result_info_div";
46 config.css.result.cc_cell_even = "copy_count_cell_even";
47 config.names.result.item_jacket = "item_jacket";
48 config.names.result.item_title = "item_title";
49 config.names.result.item_author = "item_author";
50 config.names.result.counts_row = "counts_row";
51 config.names.result.count_cell = "copy_count_cell";
52 config.names.result.format_cell = 'result_table_format_cell';
53 config.names.result.format_link = 'resource_link'
54 config.names.result.format_pic = 'format_pic'
56 var recordsHandled = 0;
57 var recordsCache = [];
60 var googleBooksLink = true;
61 attachEvt("common", "init", function() {
62 buildOrgSel($('holdsCacheSel'), globalOrgTree, 0);
65 var resultFetchAllRecords = false;
66 var resultCompiledSearch = null;
68 /* set up the event handlers */
69 if( findCurrentPage() == MRESULT || findCurrentPage() == RRESULT ) {
70 G.evt.result.hitCountReceived.push(resultSetHitInfo);
71 G.evt.result.recordReceived.push(resultDisplayRecord, resultAddCopyCounts);
72 G.evt.result.copyCountsReceived.push(resultDisplayCopyCounts);
73 G.evt.result.allRecordsReceived.push(function(){unHideMe($('tehSideBar'));},function(){unHideMe($('results_view_span'));},resultBuildCaches,
74 function(){unHideMe($('result_info_2'))}, fetchGoogleBooksLink, fetchChiliFreshReviews, postResultsCollect);
76 attachEvt('result','lowHits',resultLowHits);
77 attachEvt('result','zeroHits',resultZeroHits);
78 attachEvt( "common", "locationUpdated", resultSBSubmit );
79 /* do this after we have ID's so the rank for mr pages will be correct */
80 attachEvt("result", "preCollectRecords", resultPaginate);
83 function resultSBSubmit(){searchBarSubmit();}
85 /* returns the last 'index' postion ocurring in this page */
86 function resultFinalPageIndex() {
87 if(getHitCount() < (getOffset() + getDisplayCount()))
88 return getHitCount() - 1;
89 return getOffset() + getDisplayCount() - 1;
92 function plausible_ident(s) {
93 s = s.replace(/^\s*(.+)\s*$/, '$1');
94 s = s.replace(/^(\S+)\s.*$/, '$1');
99 /* generic search method */
100 function resultCollectSearchIds( type, method, handler ) {
102 var sort = (getSort() == SORT_TYPE_REL) ? null : getSort();
103 var sortdir = (sort) ? ((getSortDir()) ? getSortDir() : SORT_DIR_ASC) : null;
110 var form = parseForm(getForm());
111 item_type = form.item_type;
112 item_form = form.item_form;
115 item_type = (getItemType()) ? getItemType().split(/,/) : null;
116 item_form = (getItemForm()) ? getItemForm().split(/,/) : null;
121 var limit = (resultFetchAllRecords) ? 1000 : getDisplayCount();
123 if( getOffset() > 0 ) {
124 if( getHitCount() > 0 && (getOffset() + getDisplayCount()) > getHitCount() )
125 limit = getHitCount() - getOffset();
128 var lasso = getLasso();
130 if (lasso) args.org_unit = -lasso;
131 else args.org_unit = getLocation();
133 args.depth = getDepth();
135 args.offset = getOffset();
136 args.visibility_limit = 3000;
137 args.default_class = getStype();
139 if(sort) args.sort = sort;
140 if(sortdir) args.sort_dir = sortdir;
141 if(item_type) args.item_type = item_type;
142 if(item_form) args.item_form = item_form;
143 if(getAvail()) args.available = 1;
144 //args.format="marcxml";
146 if(getFacet()) args.facets = getFacet();
148 if(getAudience()) args.audience = getAudience().split(/,/);
149 if(getLitForm()) args.lit_form = getLitForm().split(/,/);
150 if(getLanguage()) args.language = getLanguage().split(/,/);
151 if(getBibLevel()) args.bib_level = getBibLevel().split(/,/);
152 if(getCopyLocs()) args.locations = getCopyLocs().split(/,/);
153 if(getPubdBefore()) args.before = getPubdBefore();
154 else if(getPubdAfter()) args.after = getPubdAfter();
155 else if(getPubdBetween()) args.between = getPubdBetween().split(/,/);
157 _debug('Search args: ' + js2JSON(args));
158 _debug('Raw query: ' + getTerm());
160 var req = new Request(method, args, getTerm(), 1);
161 req.callback(handler);
169 /* set the search result info, number of hits, which results we're
170 displaying, links to the next/prev pages, etc. */
171 function resultSetHitInfo() {
173 var lasso = getLasso();
175 /* tell the user where the results are coming from */
176 var baseorg = findOrgUnit(getLocation());
177 var depth = getDepth();
178 var mydepth = findOrgDepth(baseorg);
179 if( findOrgDepth(baseorg) != depth ) {
180 var tmporg = baseorg;
181 while( mydepth > depth ) {
183 tmporg = findOrgUnit(tmporg.parent_ou());
185 unHideMe($('including_results_for'));
186 try{$('including_results_location').appendChild(text(tmporg.name()));} catch(e){}
191 try{searchTimer.stop()}catch(e){}
193 //if( findCurrentPage() == MRESULT ) {
194 if( findCurrentPage() == MRESULT ||
196 (findCurrentPage() == RRESULT &&
198 getRtype() == RTYPE_TITLE ||
199 getRtype() == RTYPE_AUTHOR ||
200 getRtype() == RTYPE_SUBJECT ||
201 getRtype() == RTYPE_SERIES ||
202 getRtype() == RTYPE_KEYWORD
207 if(getHitCount() <= lowHitCount && getTerm())
208 runEvt('result', 'lowHits');
211 if(getHitCount() == 0) {
212 runEvt('result', 'zeroHits');
217 var pages = getHitCount() / getDisplayCount();
218 if(pages % 1) pages = parseInt(pages) + 1;
222 var cpage = (getOffset()/getDisplayCount()) + 1;
224 G.ui.result.current_page.appendChild(text(cpage));
225 G.ui.result.num_pages.appendChild(text(pages)); /* the ) is dumb */
227 $('current_page2').appendChild(text(cpage));
228 $('num_pages2').appendChild(text(pages + ")")); /* the ) is dumb */
230 /* set the offsets */
231 var offsetEnd = getDisplayCount() + getOffset();
232 if( getDisplayCount() > (getHitCount() - getOffset()))
233 offsetEnd = getHitCount();
235 G.ui.result.offset_end.appendChild(text(offsetEnd));
236 G.ui.result.offset_start.appendChild(text(getOffset() + 1));
238 $('offset_end2').appendChild(text(offsetEnd));
239 $('offset_start2').appendChild(text(getOffset() + 1));
241 G.ui.result.result_count.appendChild(text(getHitCount()));
242 unHideMe(G.ui.result.info);
243 unHideMe($('result_numbers1'));
245 $('result_count2').appendChild(text(getHitCount()));
246 unHideMe($('result_info_div2'));
249 function resultLowHits() {
251 unHideMe($('result_low_hits'));
252 if(getHitCount() > 0)
253 unHideMe($('result_low_hits_msg'));
256 for(var key in resultCompiledSearch.searches)
257 words.push(resultCompiledSearch.searches[key].term);
259 var sreq = new Request(CHECK_SPELL, words.join(' '));
260 sreq.callback(resultSuggestSpelling);
263 for(var key in resultCompiledSearch.searches) {
264 var areq = new Request(FETCH_CROSSREF, key, resultCompiledSearch.searches[key].term);
265 areq.callback(resultLowHitXRef);
269 if( !(getForm() == null || getForm() == 'all' || getForm() == "") ) {
271 a[PARAM_FORM] = "all";
272 $('low_hits_remove_format_link').setAttribute('href',buildOPACLink(a));
273 unHideMe($('low_hits_remove_format'));
276 resultSuggestSearchClass();
278 if(getTerm()) resultExpandSearch(); /* advanced search */
281 var lowHitsXRefSet = {};
283 var lowHitsXRefLinkParent;
284 function resultLowHitXRef(r) {
285 if(!lowHitsXRefLink){
286 lowHitsXRefLinkParent = $('low_hits_xref_link').parentNode;
287 lowHitsXRefLink = lowHitsXRefLinkParent.removeChild($('low_hits_xref_link'));
289 var res = r.getResultObject();
291 arr.concat(res.also);
292 if(arr && arr.length > 0) {
293 unHideMe($('low_hits_cross_ref'));
296 while( word = arr.shift() ) {
298 if (lowHitsXRefSet[word] == 1) continue;
299 lowHitsXRefSet[word] = 1;
303 a[PARAM_TERM] = word;
304 var template = lowHitsXRefLink.cloneNode(true);
305 template.setAttribute('href',buildOPACLink(a));
306 template.appendChild(text(word));
307 lowHitsXRefLinkParent.appendChild(template);
308 lowHitsXRefLinkParent.appendChild(text(' '));
313 function resultZeroHits() {
314 hideMe($('result_header'));
315 hideMe($('result_table_div'));
316 hideMe($('statusbar'));
317 $('rresults_page').style.width="690px";
318 unHideMe($('zero_search_hits'));
319 $('zero_hits_term').innerHTML = getTerm();
321 unHideMe($('result_low_hits'));
322 unHideMe($('result_zero_hits_msg'));
323 if(getTerm()) resultExpandSearch(); /* advanced search */
326 function resultExpandSearch() {
327 var top = findOrgDepth(globalOrgTree);
328 if(getDepth() == top) return;
329 unHideMe($('low_hits_expand_range'));
330 var par = $('low_hits_expand_link').parentNode;
331 var template = par.removeChild($('low_hits_expand_link'));
333 var bottom = getDepth();
334 while( top < bottom ) {
336 a[PARAM_DEPTH] = top;
337 var temp = template.cloneNode(true);
338 temp.appendChild(text(findOrgTypeFromDepth(top).opac_label()))
339 temp.setAttribute('href',buildOPACLink(a));
340 par.appendChild(temp);
345 function resultSuggestSearchClass() {
346 var stype = getStype();
347 if(stype == STYPE_KEYWORD) return;
349 unHideMe($('low_hits_search_type'));
350 if(stype != STYPE_TITLE) {
351 ref = $('low_hits_title_search');
353 a[PARAM_STYPE] = STYPE_TITLE;
354 ref.setAttribute('href',buildOPACLink(a));
356 if(stype != STYPE_AUTHOR) {
357 ref = $('low_hits_author_search');
359 a[PARAM_STYPE] = STYPE_AUTHOR;
360 ref.setAttribute('href',buildOPACLink(a));
362 if(stype != STYPE_SUBJECT) {
363 ref = $('low_hits_subject_search');
365 a[PARAM_STYPE] = STYPE_SUBJECT;
366 ref.setAttribute('href',buildOPACLink(a));
368 if(stype != STYPE_KEYWORD) {
369 ref = $('low_hits_keyword_search');
371 a[PARAM_STYPE] = STYPE_KEYWORD;
372 ref.setAttribute('href',buildOPACLink(a));
374 if(stype != STYPE_SERIES) {
375 ref = $('low_hits_series_search');
377 a[PARAM_STYPE] = STYPE_SERIES;
378 ref.setAttribute('href',buildOPACLink(a));
382 function resultSuggestSpelling(r) {
383 var res = r.getResultObject();
384 var phrase = getTerm();
385 var words = phrase.split(/ /);
389 for( var w = 0; w < words.length; w++ ) {
391 var blob = grep(res, function(i){return (i.word == word);});
392 if( blob ) blob = blob[0];
394 if( blob.word == word ) {
395 if( blob.suggestions && blob.suggestions[0] ) {
396 newterm += " " + blob.suggestions[0];
397 unHideMe($('did_you_mean'));
399 newterm += " " + word;
403 var cell = $('zero_hits_suggestions');
404 var s = res[0].suggestions;
407 if(i==10) break; //limit suggestions
408 cell.appendChild(elem('a',{href:buildOPACLink({t:s[i]})},s[i]));
409 cell.appendChild(elem('br'));
411 if(newterm.toLowerCase().trim()!=getTerm().toLowerCase().trim()) unHideMe($('zero_hits_label1'));
412 if(res[0].suggestions && res[0].suggestions.length>0) unHideMe($('zero_hits_label2'));
415 arg[PARAM_TERM] = newterm;
416 $('spell_check_link').setAttribute('href', buildOPACLink(arg));
417 $('spell_check_link').appendChild(text(newterm));
421 function resultPaginate() {
425 if( !( ((o) + getDisplayCount()) >= getHitCount()) ) {
427 args[PARAM_OFFSET] = o + getDisplayCount();
428 args[PARAM_SORT] = SORT;
429 args[PARAM_SORT_DIR] = SORT_DIR;
430 args[PARAM_RLIST] = new CGI().param(PARAM_RLIST);
432 G.ui.result.next_link.setAttribute("href", buildOPACLink(args));
433 addCSSClass(G.ui.result.next_link, config.css.result.nav_active);
435 $('next_link2').setAttribute("href", buildOPACLink(args));
436 addCSSClass($('next_link2'), config.css.result.nav_active);
438 args[PARAM_OFFSET] = getHitCount() - (getHitCount() % getDisplayCount());
440 /* when hit count is divisible by display count, we have to adjust */
441 if( getHitCount() % getDisplayCount() == 0 )
442 args[PARAM_OFFSET] -= getDisplayCount();
448 args[PARAM_SORT] = SORT;
449 args[PARAM_SORT_DIR] = SORT_DIR;
450 args[PARAM_RLIST] = new CGI().param(PARAM_RLIST);
452 args[PARAM_OFFSET] = o - getDisplayCount();
453 G.ui.result.prev_link.setAttribute( "href", buildOPACLink(args));
454 addCSSClass(G.ui.result.prev_link, config.css.result.nav_active);
456 $('prev_link2').setAttribute( "href", buildOPACLink(args));
457 addCSSClass($('prev_link2'), config.css.result.nav_active);
459 args[PARAM_OFFSET] = 0;
460 G.ui.result.home_link.setAttribute( "href", buildOPACLink(args));
461 addCSSClass(G.ui.result.home_link, config.css.result.nav_active);
464 // pagination - google style
465 var pages = getHitCount() / getDisplayCount();
466 var cpage = (getOffset()/getDisplayCount()) + 1;
468 pages = Math.floor(pages);
469 cpage = Math.floor(cpage);
470 var end = pages>9?8:pages;
472 // narrow our window of visible page numbers to 9 - sets start and end pages for the loop
475 end = cpage+3>pages?pages:cpage+3;
476 if(cpage+3>pages) { start = (cpage-5)-(cpage-pages+3); }
478 } // ugh... I hate math.
481 var span = $('nav_pages');
482 var span2 = $('nav_pages2');
483 for(var i=start; i<=end; i++) {
484 if(i==end && (getHitCount()%getDisplayCount())==0) break;
485 var temp = elem('span',{style:'padding:0px 3px;'});
486 temp.style.padding='0px 3px';
487 args[PARAM_OFFSET] = getDisplayCount()*i;
488 if(i==cpage-1) { var link = text(i+1); temp.style.color="red" }
489 else var link = elem('a',{href:buildOPACLink(args)},i+1);
490 temp.appendChild(link);
491 span.appendChild(temp);
492 span2.appendChild(temp.cloneNode(true));
497 if(getDisplayCount() < getHitCount()) {
498 unHideMe($('start_end_links_span'));
499 unHideMe($('start_end_links_span2'));
503 try{searchTimer.stop()}catch(e){}
506 function buildunAPISpan (span, type, id) {
507 if(!span || !type || !id) return;
511 addCSSClass(span,'unapi-id');
515 'tag:' + cgi.server_name + ',' +
517 ':' + type + '/' + id
521 function unhideGoogleBooksLink (data) {
522 for ( var i in data ) {
523 //if (data[i].preview == 'noview') continue;
525 var gbspan = $n(document.documentElement, 'googleBooksLink-' + i);
526 var gba = $n(gbspan, "googleBooks-link");
532 removeCSSClass( gbspan, 'hide_me' );
536 /* display the record info in the record display table 'pos' is the
537 zero based position the record should have in the display table */
538 function resultDisplayRecord(rec, pos, is_mr) {
539 //fieldmapper.IDL.load(['mvr']);
540 if(rec == null || rec.__c) rec = new mvr(); /* so the page won't die if there was an error */
542 recordsCache.push(rec);
544 var r = table.rows[pos + 1];
545 r.id += "_" + rec.doc_id();
546 var currentISBN = cleanISBN(rec.isbn());
548 if (googleBooksLink) {
549 var gbspan = $n(r, "googleBooksLink");
550 if (currentISBN && gbspan) {
551 gbspan.setAttribute('name', gbspan.getAttribute('name') + '-' + currentISBN );
552 if (isbnList) isbnList += ', ';
553 isbnList += currentISBN;
557 if (currentISBN && chilifresh && chilifresh != '(none)') {
558 var cfrow = $n(r, "chilifreshReview");
560 removeCSSClass( cfrow, 'hide_me' );
562 var cflink = $n(r, "chilifreshReviewLink");
566 'isbn_' + currentISBN
569 var cfdiv = $n(r, "chilifreshReviewResult");
573 'chili_review_' + currentISBN
578 var pic = $n(r, config.names.result.item_jacket);
579 if (!pic) pic = elem("img");
580 //pic.setAttribute("src", buildISBNSrc(currentISBN));
581 pic.setAttribute("width",55);
583 var title_link = $n(r, config.names.result.item_title);
584 var author_link = $n(r, config.names.result.item_author);
585 var row_count = $n(r,"results_row_count");
586 var myListLink = $n(r,"result_my_list_link");
587 var reviewsLink = $n(r, 'reviews_and_more');
589 reviewsLink.href="http://contentcafe2.btol.com/ContentCafeClient/ContentCafe.aspx?UserID=KC72927&Password=CC14647&ItemKey="+currentISBN+"&Options=Y";
593 var onlyrec = onlyrecord[ getOffset() + pos ];
595 buildunAPISpan($n(r,'unapi'), 'biblio-record_entry', onlyrec);
599 args[PARAM_OFFSET] = 0;
600 args[PARAM_RID] = onlyrec;
601 args[PARAM_MRID] = rec.doc_id();
602 pic.parentNode.setAttribute("href", buildOPACLink(args));
603 title_link.setAttribute("href", buildOPACLink(args));
604 title_link.appendChild(text(normalize(truncate(rec.title(), 65))));
607 buildunAPISpan($n(r,'unapi'), 'metabib-metarecord', rec.doc_id());
609 buildTitleLink(rec, title_link);
612 args[PARAM_OFFSET] = 0;
613 args[PARAM_MRID] = rec.doc_id();
614 pic.parentNode.setAttribute("href", buildOPACLink(args));
618 buildunAPISpan($n(r,'unapi'), 'biblio-record_entry', rec.doc_id());
620 //if(title_link) buildTitleDetailLink(rec, title_link);
622 title_link.appendChild(text(normalize(truncate(rec.title(), 1000))));
624 argss.page = RDETAIL;
625 argss[PARAM_RID] = rec.doc_id();
626 var linkText = title_link.innerHTML; // IE
627 title_link.setAttribute("href", buildOPACLink(argss));
628 title_link.innerHTML = linkText; // IE
632 args[PARAM_OFFSET] = 0;
633 args[PARAM_RID] = rec.doc_id();
634 pic.parentNode.setAttribute("href", buildOPACLink(args));
636 unHideMe($n(r,'place_hold_span'));
637 //$n(r,'place_hold_link').setAttribute('href','javascript:holdsDrawEditor({record:"'+rec.doc_id()+'",type:"T"});');
638 $n(r,'place_hold_link').onclick = function() { resultDrawHoldsWindow(rec.doc_id(), 'T'); }
641 //dojo.require('openils.BibTemplate'); // -- this causes redundant requests per record - put in js_common.xml instead
644 //new openils.BibTemplate({root : $n(r, 'bib_cn_list'), record : rec.doc_id()}).render();
645 new openils.BibTemplate({root : r, record : rec.doc_id()}).render();
651 if(row_count) row_count.innerHTML = (pos+1)+getOffset()+".";
652 if(myListLink) myListLink.setAttribute("href","javascript:addMyList("+rec.doc_id()+");")
653 title_link.setAttribute("title",rec.title());
654 buildSearchLink(STYPE_AUTHOR, rec.author(), author_link);
657 $n(r, "results_pub_date").innerHTML = (!rec.pubdate())?"":rec.pubdate();
658 $n(r, "results_pub").innerHTML = (!rec.publisher())?"":rec.publisher();
659 $n(r, "results_isbn").innerHTML = (!currentISBN)?"":currentISBN;
660 $n(r, "results_edition").innerHTML = (!rec.edition())?"":rec.edition();
661 $n(r, "results_phys_desc").innerHTML = (!rec.physical_description())?"":rec.physical_description();
662 if(isInAnonList(parseInt(rec.doc_id()))) {
663 $n(r, 'result_my_list_link').innerHTML = 'Remove from my list';
664 $n(r, 'result_my_list_link').title = 'Remove from my list';
665 //$n(r, 'result_my_list_link').appendChild(elem('img', {src:'/opac/skin/kcls/graphics/add_mylist_sel.gif'}, null));
668 if(!isNull(rec.edition())) {
669 unHideMe( $n(r, "result_table_extra_span"));
670 $n(r, "result_table_edition_span").appendChild( text( rec.edition()) );
672 if(!isNull(rec.pubdate())) {
673 unHideMe( $n(r, "result_table_extra_span"));
674 unHideMe($n(r, "result_table_pub_span"));
675 $n(r, "result_table_pub_span").appendChild( text( rec.pubdate() ));
677 if(!isNull(rec.publisher()) ) {
678 unHideMe( $n(r, "result_table_extra_span"));
679 unHideMe($n(r, "result_table_pub_span"));
680 $n(r, "result_table_pub_span").appendChild( text( " " + rec.publisher() ));
683 if(!isNull(rec.physical_description()) ) {
684 unHideMe( $n(r, "result_table_extra_span"));
685 var t = " " + rec.physical_description();
686 //$n(r, "result_table_phys_span").appendChild( text(t.replace(/:.*/g,'')));
687 $n(r, "result_table_phys_span").appendChild( text(t));
691 resultBuildFormatIcons( r, rec, is_mr );
693 runEvt("result", "recordDrawn", rec.doc_id(), title_link);
696 if(resultPageIsDone()) {
697 runEvt('result', 'allRecordsReceived', recordsCache);
701 function resultDrawHoldsWindow(hold_target, hold_type) {
702 var src = location.href;
703 if(forceLoginSSL && src.match(/^http:/)) {
704 src = src.replace(/^http:/, 'https:');
705 if(src.match(/&hold_target=/)) {
706 src.replace(/&hold_target=(\d+)/, hold_target);
708 src += '&hold_target=' + hold_target;
712 holdsDrawEditor({record:hold_target, type:hold_type});
717 function _resultFindRec(id) {
718 for( var i = 0; i != recordsCache.length; i++ ) {
719 var rec = recordsCache[i];
720 if( rec && rec.doc_id() == id )
727 function resultBuildFormatIcons( row, rec, is_mr ) {
729 var imgEl = $n(row, "result_mat_type");
732 ress = getMarcData(rec.doc_id(),"998","d");
733 if(setFormatIcon(imgEl, ress)) unHideMe(imgEl);
737 function fetchGoogleBooksLink () {
739 if (isbnList && googleBooksLink) {
740 var scriptElement = document.createElement("script");
741 scriptElement.setAttribute("id", "jsonScript");
742 scriptElement.setAttribute("src",
743 "https://books.google.com/books?bibkeys=" +
744 escape(isbnList) + "&jscmd=viewapi&callback=unhideGoogleBooksLink");
745 scriptElement.setAttribute("type", "text/javascript");
746 // make the request to Google Book Search
747 document.documentElement.firstChild.appendChild(scriptElement);
751 function resultPageIsDone(pos) {
753 return (recordsHandled == getDisplayCount()
754 || recordsHandled + getOffset() == getHitCount());
757 var resultCCHeaderApplied = false;
759 /* -------------------------------------------------------------------- */
760 /* dynamically add the copy count rows based on the org type 'countsrow'
761 is the row into which we will add TD's to hold the copy counts
762 This code generates copy count cells with an id of
763 'copy_count_cell_<depth>_<pagePosition>' */
764 function resultAddCopyCounts(rec, pagePosition) {
766 var r = table.rows[pagePosition + 1];
767 var countsrow = $n(r, config.names.result.counts_row );
768 var ccell = $n(countsrow, config.names.result.count_cell);
770 var nodes = orgNodeTrail(findOrgUnit(getLocation()));
772 var type = findOrgType(node.ou_type());
773 ccell.id = "copy_count_cell_" + type.depth() + "_" + pagePosition;
774 ccell.title = type.opac_label();
775 //addCSSClass(ccell, config.css.result.cc_cell_even);
777 var lastcell = ccell;
778 var lastheadcell = null;
781 var ccheadcell = null;
782 if(!resultCCHeaderApplied && !getLasso()) {
783 ccrow = $('result_thead_row');
784 ccheadcell = ccrow.removeChild($n(ccrow, "result_thead_ccell"));
785 var t = ccheadcell.cloneNode(true);
787 t.appendChild(text(type.opac_label()));
788 ccrow.appendChild(t);
789 resultCCHeaderApplied = true;
793 /* collect copy counts for a record using method 'methodName' */
794 function resultCollectCopyCounts(rec, pagePosition, methodName) {
795 if(rec == null || rec.doc_id() == null) return;
797 var loc = getLasso();
799 else loc= getLocation();
801 var req = new Request(methodName, loc, rec.doc_id(), getForm() );
802 req.request.userdata = [ rec, pagePosition ];
803 req.callback(resultHandleCopyCounts);
807 function resultHandleCopyCounts(r) {
808 runEvt('result', 'copyCountsReceived', r.userdata[0], r.userdata[1], r.getResultObject());
812 /* XXX Needs to understand Lasso copy counts... */
813 /* display the collected copy counts */
814 function resultDisplayCopyCounts(rec, pagePosition, copy_counts) {
815 if(copy_counts == null || rec == null) return;
816 var r = table.rows[pagePosition + 1];
817 var cnt_avail = $n(r, "copy_count_avail");
818 if(cnt_avail && copy_counts[0]) {
819 /*if(copy_counts[0].available)*/ cnt_avail.innerHTML = copy_counts[0].available+' cop'+(copy_counts[0].available==1?'y':'ies')+' available';
821 fieldmapper.standardRequest(['open-ils.circ','open-ils.circ.bre.holds.count'], {async:true, params:[rec.doc_id(), r.id], oncomplete: drawHoldsCount});
822 $n(r, 'copy_holds2').innerHTML = ' on first copy returned of '+copy_counts[0].count+' cop'+(copy_counts[0].count==1?'y':'ies');
827 function drawHoldsCount(r) {
828 if(!r.params[1]) return;
829 var row = $(r.params[1]);
831 var span = $n(row, 'copy_holds');
832 var resp = r.recv().content();
833 span.innerHTML = resp+' hold'+(resp==1?'':'s')+' ';
836 function showDetailedInfo(bool) {
838 var tbls = dojo.query('.results_info_table',$('result_table'));
840 tbls.forEach(function(node, index, arr){
841 unHideMe($n(node,'results_pub_tr'));
842 unHideMe($n(node,'results_isbn_tr'));
843 unHideMe($n(node,'results_edition_tr'));
844 unHideMe($n(node,'results_phys_desc_tr'));
847 tbls.forEach(function(node, index, arr){
848 hideMe($n(node,'results_pub_tr'));
849 hideMe($n(node,'results_isbn_tr'));
850 hideMe($n(node,'results_edition_tr'));
851 hideMe($n(node,'results_phys_desc_tr'));
856 function fetchChiliFreshReviews() {
857 if (chilifresh && chilifresh != '(none)') {
858 try { chili_init(); } catch(E) { dump(E + '\n'); }
862 function postResultsCollect() {
863 var it = getCacheValue('showHoldEditor');
865 setCacheValue('showHoldEditor', null);
866 holdsDrawEditor({record:it.record, type:it.type});