3 /* set the search result info, number of hits, which results we're
4 displaying, links to the next/prev pages, etc. */
5 function resultSetInfo() {
7 if( getDisplayCount() > (getHitCount() - getOffset())) c = getHitCount();
8 else c = getDisplayCount() + getOffset();
10 var pages = parseInt(getHitCount() / getDisplayCount()) + 1;
11 G.ui.result.current_page.appendChild(text( (getOffset()/getDisplayCount()) + 1));
12 G.ui.result.num_pages.appendChild(text(pages + ")"));
16 if( !((o + getDisplayCount()) >= getHitCount()) ) {
19 args[PARAM_OFFSET] = o + getDisplayCount();
20 G.ui.result.next_link.setAttribute("href", buildOPACLink(args));
21 addCSSClass(G.ui.result.next_link, config.css.result.nav_active);
23 args[PARAM_OFFSET] = getHitCount() - (getHitCount() % getDisplayCount());
24 G.ui.result.end_link.setAttribute("href", buildOPACLink(args));
25 addCSSClass(G.ui.result.end_link, config.css.result.nav_active);
31 args[PARAM_OFFSET] = o - getDisplayCount();
32 G.ui.result.prev_link.setAttribute( "href", buildOPACLink(args));
33 addCSSClass(G.ui.result.prev_link, config.css.result.nav_active);
35 args[PARAM_OFFSET] = 0;
36 G.ui.result.home_link.setAttribute( "href", buildOPACLink(args));
37 addCSSClass(G.ui.result.home_link, config.css.result.nav_active);
40 G.ui.result.offset_start.appendChild(text(o + 1));
41 G.ui.result.offset_end.appendChild(text(c));
42 G.ui.result.result_count.appendChild(text(getHitCount()));
43 unHideMe(G.ui.result.info);
48 /* display the record info in the record display table */
49 function resultDisplayRecord(rec, rowtemplate, is_mr) {
51 if(rec == null) rec = new mvr(); /* if we return we won't build some important UI components */
53 //alert("building record " + rec.title());
55 /* hide the 'now loading...' message */
56 hideMe(G.ui.common.loading);
58 var r = rowtemplate.cloneNode(true);
60 var pic = findNodeByName(r, config.names.result.item_jacket);
61 pic.setAttribute("src", buildISBNSrc(cleanISBN(rec.isbn())));
64 var title_link = findNodeByName(r, config.names.result.item_title);
65 var author_link = findNodeByName(r, config.names.result.item_author);
67 if( is_mr ) buildTitleLink(rec, title_link);
68 else buildTitleDetailLink(rec, title_link);
69 buildAuthorLink(rec, author_link);
71 var countsrow = findNodeByName(r, config.names.result.counts_row);
73 /* adjust the width according to how many org counts are added */
74 findNodeByName(r, "result_table_title_cell").width =
75 resultAddCopyCounts(countsrow, rec) + "%";
82 /* -------------------------------------------------------------------- */
83 /* dynamically add the copy count rows based on the org type
84 'countsrow' is the row into which we will add TD's to hold
86 This code generates copy count cells with an id of
88 'copy_count_cell_<depth>_<record_id>' for later insertion
91 return the percent width left over after the each count is added.
92 if 3 counts are added, returns 100 - (cell.width * 3)
95 function resultAddCopyCounts(countsrow, rec) {
97 var ccell = findNodeByName(countsrow, config.names.result.count_cell);
100 var nodes = orgNodeTrail(findOrgUnit(getLocation()));
102 var type = findOrgType(node.ou_type());
103 ccell.id = "copy_count_cell_" + type.depth() + "_" + rec.doc_id();
104 ccell.title = type.opac_label();
105 addCSSClass(ccell, "copy_count_cell_even");
108 var lastcell = ccell;
113 var d = findOrgDepth(nodes[1]);
114 var d2 = findOrgDepth(nodes[nodes.length -1]);
116 for( var i = d; i <= d2 ; i++ ) {
118 ccell = ccell.cloneNode(true);
121 removeCSSClass(ccell, "copy_count_cell_even");
123 addCSSClass(ccell, "copy_count_cell_even");
125 var node = nodes[x++];
126 var type = findOrgType(node.ou_type());
128 ccell.id = "copy_count_cell_" + type.depth() + "_" + rec.doc_id();
129 ccell.title = type.opac_label();
130 countsrow.insertBefore(ccell, lastcell);
136 return 100 - (nodes.length * 8);
141 /* collect copy counts for a record using method 'methodName' */
142 function resultCollectCopyCounts(rec, methodName) {
143 if(rec == null || rec.doc_id() == null) return;
144 var req = new Request(methodName, getLocation(), rec.doc_id() );
145 req.callback(function(r){ resultDisplayCopyCounts(rec, r.getResultObject()); });
150 /* display the collected copy counts */
151 function resultDisplayCopyCounts(rec, copy_counts) {
152 if(copy_counts == null || rec == null) return;
154 while(copy_counts[i] != null) {
155 var cell = getId("copy_count_cell_" + i +"_" + rec.doc_id());
156 cell.appendChild(text(copy_counts[i].available + " / " + copy_counts[i].count));