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 = getHitCount() / getDisplayCount();
11 if(pages % 1) pages = parseInt(pages) + 1;
13 G.ui.result.current_page.appendChild(text( (getOffset()/getDisplayCount()) + 1));
14 G.ui.result.num_pages.appendChild(text(pages + ")"));
18 if( !((o + getDisplayCount()) >= getHitCount()) ) {
21 args[PARAM_OFFSET] = o + getDisplayCount();
22 G.ui.result.next_link.setAttribute("href", buildOPACLink(args));
23 addCSSClass(G.ui.result.next_link, config.css.result.nav_active);
25 args[PARAM_OFFSET] = getHitCount() - (getHitCount() % getDisplayCount());
26 G.ui.result.end_link.setAttribute("href", buildOPACLink(args));
27 addCSSClass(G.ui.result.end_link, config.css.result.nav_active);
33 args[PARAM_OFFSET] = o - getDisplayCount();
34 G.ui.result.prev_link.setAttribute( "href", buildOPACLink(args));
35 addCSSClass(G.ui.result.prev_link, config.css.result.nav_active);
37 args[PARAM_OFFSET] = 0;
38 G.ui.result.home_link.setAttribute( "href", buildOPACLink(args));
39 addCSSClass(G.ui.result.home_link, config.css.result.nav_active);
42 G.ui.result.offset_start.appendChild(text(o + 1));
43 G.ui.result.offset_end.appendChild(text(c));
44 G.ui.result.result_count.appendChild(text(getHitCount()));
45 unHideMe(G.ui.result.info);
50 /* display the record info in the record display table */
51 function resultDisplayRecord(rec, rowtemplate, is_mr) {
53 if(rec == null) rec = new mvr(); /* so the page won't die */
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())));
63 var title_link = findNodeByName(r, config.names.result.item_title);
64 var author_link = findNodeByName(r, config.names.result.item_author);
66 if( is_mr ) buildTitleLink(rec, title_link);
67 else buildTitleDetailLink(rec, title_link);
68 buildAuthorLink(rec, author_link);
70 var countsrow = findNodeByName(r, config.names.result.counts_row);
72 /* adjust the width according to how many org counts are added */
73 findNodeByName(r, "result_table_title_cell").width =
74 resultAddCopyCounts(countsrow, rec) + "%";
81 /* -------------------------------------------------------------------- */
82 /* dynamically add the copy count rows based on the org type
83 'countsrow' is the row into which we will add TD's to hold
85 This code generates copy count cells with an id of
87 'copy_count_cell_<depth>_<record_id>' for later insertion
90 return the percent width left over after the each count is added.
91 if 3 counts are added, returns 100 - (cell.width * 3)
94 function resultAddCopyCounts(countsrow, rec) {
96 var ccell = findNodeByName(countsrow, config.names.result.count_cell);
99 var nodes = orgNodeTrail(findOrgUnit(getLocation()));
101 var type = findOrgType(node.ou_type());
102 ccell.id = "copy_count_cell_" + type.depth() + "_" + rec.doc_id();
103 ccell.title = type.opac_label();
104 addCSSClass(ccell, "copy_count_cell_even");
107 var lastcell = ccell;
112 var d = findOrgDepth(nodes[1]);
113 var d2 = findOrgDepth(nodes[nodes.length -1]);
115 for( var i = d; i <= d2 ; i++ ) {
117 ccell = ccell.cloneNode(true);
120 removeCSSClass(ccell, "copy_count_cell_even");
122 addCSSClass(ccell, "copy_count_cell_even");
124 var node = nodes[x++];
125 var type = findOrgType(node.ou_type());
127 ccell.id = "copy_count_cell_" + type.depth() + "_" + rec.doc_id();
128 ccell.title = type.opac_label();
129 countsrow.insertBefore(ccell, lastcell);
135 return 100 - (nodes.length * 8);
140 /* collect copy counts for a record using method 'methodName' */
141 function resultCollectCopyCounts(rec, methodName) {
142 if(rec == null || rec.doc_id() == null) return;
143 var req = new Request(methodName, getLocation(), rec.doc_id() );
144 req.callback(function(r){ resultDisplayCopyCounts(rec, r.getResultObject()); });
149 /* display the collected copy counts */
150 function resultDisplayCopyCounts(rec, copy_counts) {
151 if(copy_counts == null || rec == null) return;
153 while(copy_counts[i] != null) {
154 var cell = getId("copy_count_cell_" + i +"_" + rec.doc_id());
155 cell.appendChild(text(copy_counts[i].available + " / " + copy_counts[i].count));