4 detachAllEvt('common', 'run');
5 attachEvt("common", "run", rdetailDraw);
6 attachEvt("rdetail", "recordDrawn", rdetailBuildStatusColumns);
7 attachEvt("rdetail", "recordDrawn", rdetailBuildInfoRows);
8 attachEvt("rdetail", "recordDrawn", rdetailGetPageIds);
11 var cp_statuses = null;
12 var recordsCache = [];
14 var copyRowParent = null;
17 var numStatuses = null;
19 var callnumberCache = {};
20 var rdetailLocalOnly = true;
21 var globalCNCache = {};
24 var _statusPositions = {};
26 var rdetailShowLocal = true;
27 var rdetailShowCopyLocation = true;
28 var googleBookPreview = true;
29 var displaySerialHoldings = true;
32 var nextContainerIndex;
34 function rdetailReload() {
36 args[PARAM_LOCATION] = getNewSearchLocation();
37 args[PARAM_DEPTH] = depthSelGetDepth();
38 goTo(buildOPACLink(args));
44 var rdetailPrev = null;
45 var rdetailNext = null;
46 var rdetailStart = null;
47 var rdetailEnd = null;
51 /* looks to see if we have a next and/or previous record in the
52 record cache, if so, set up the nav links */
53 function rdetailSetPaging(ids) {
56 cachedRecords.ids = ids;
58 for( var i = 0; i < cachedRecords.ids.length; i++ ) {
59 var rec = cachedRecords.ids[i];
60 if( rec == getRid() ) {
61 if( i > 0 ) prevRecord = cachedRecords.ids[i-1];
62 if( i < cachedRecords.ids.length - 1 )
63 nextRecord = cachedRecords.ids[i+1];
68 $('np_offset').appendChild(text(i + 1));
69 $('np_count').appendChild(text(getHitCount()));
72 unHideMe($('np_table'));
73 unHideMe($('np_prev'));
74 unHideMe($('np_start'));
75 rdetailPrev = function() { _rdetailNav(prevRecord); };
76 rdetailStart = function() { _rdetailNav(cachedRecords.ids[0]); };
80 unHideMe($('np_table'));
81 unHideMe($('np_next'));
82 unHideMe($('np_end'));
83 rdetailNext = function() { _rdetailNav(nextRecord); };
84 rdetailEnd = function() { _rdetailNav(cachedRecords.ids[cachedRecords.ids.length-1]); };
87 runEvt('rdetail', 'nextPrevDrawn', i, cachedRecords.ids.length);
91 function _rdetailNav(id, offset) {
94 goTo(buildOPACLink(args));
97 function rdetailDraw() {
99 detachAllEvt('common','depthChanged');
100 detachAllEvt('common','locationUpdated');
101 attachEvt('common','depthChanged', rdetailReload);
102 attachEvt('common','locationUpdated', rdetailReload);
103 attachEvt('common','holdUpdated', rdetailReload);
104 attachEvt('common','holdUpdateCanceled', rdetailReload);
106 copyRowParent = G.ui.rdetail.cp_info_row.parentNode;
107 copyRow = copyRowParent.removeChild(G.ui.rdetail.cp_info_row);
108 statusRow = G.ui.rdetail.cp_status.parentNode;
109 statusRow.id = '__rdsrow';
111 G.ui.rdetail.cp_info_local.onclick = rdetailShowLocalCopies;
112 G.ui.rdetail.cp_info_all.onclick = rdetailShowAllCopies;
114 if(getLocation() == globalOrgTree.id())
115 hideMe(G.ui.rdetail.cp_info_all);
117 var req = new Request(FETCH_RMODS, getRid());
118 req.callback(_rdetailDraw);
121 if (displaySerialHoldings) {
122 var req = new Request(FETCH_MFHD_SUMMARY, getRid());
123 req.callback(_holdingsDraw);
127 detachAllEvt("result", "idsReceived");
128 G.evt.result.hitCountReceived = [];
129 G.evt.result.recordReceived = [];
130 G.evt.result.copyCountsReceived = [];
131 G.evt.result.allRecordsReceived = [];
134 function rdetailGetPageIds() {
135 attachEvt("result", "idsReceived", rdetailSetPaging );
136 resultFetchAllRecords = true;
137 rresultCollectIds(true);
141 function buildunAPISpan (span, type, id) {
145 addCSSClass(span,'unapi-id');
148 'title', 'tag:' + cgi.server_name + ',' +
149 d.getFullYear() + ':' + type + '/' + id
153 function rdetailViewMarc(r,id) {
154 hideMe($('rdetail_extras_loading'));
155 $('rdetail_view_marc_box').innerHTML = r.getResultObject();
157 var div = elem('div', { "class" : 'hide_me' });
158 var span = div.appendChild( elem('abbr') );
160 buildunAPISpan( span, 'biblio-record_entry', record.doc_id() );
162 $('rdetail_view_marc_box').insertBefore(span, $('rdetail_view_marc_box').firstChild);
166 function rdetailShowLocalCopies() {
167 rdetailShowLocal = true;
168 rdetailBuildInfoRows();
169 hideMe(G.ui.rdetail.cp_info_local);
170 unHideMe(G.ui.rdetail.cp_info_all);
171 hideMe(G.ui.rdetail.cp_info_none);
174 function rdetailShowAllCopies() {
176 rdetailShowLocal = false;
177 rdetailBuildInfoRows();
178 hideMe(G.ui.rdetail.cp_info_all);
179 unHideMe(G.ui.rdetail.cp_info_local);
180 hideMe(G.ui.rdetail.cp_info_none);
183 function OpenMarcEditWindow(pcrud, rec) {
185 To run in Firefox directly, must set signed.applets.codebase_principal_support
186 to true in about:config
188 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
189 win = window.open('/xul/server/cat/marcedit.xul'); // XXX version?
190 dojo.require('openils.PermaCrud');
193 record : {marc : rec.marc()},
196 func: function(xmlString) {
205 function loadMarcEditor(recId) {
206 var pcrud = new openils.PermaCrud({"authtoken": G.user.session});
207 var rec = pcrud.retrieve("sre", recId);
209 OpenMarcEditWindow(pcrud, rec);
214 * This function could be written much more intelligently
215 * Limited brain power means that I'm brute-forcing it for now
217 function _holdingsDraw(h) {
218 holdings = h.getResultObject();
219 if (!holdings) { return null; }
221 dojo.forEach(holdings, _holdingsDrawMFHD);
224 function _holdingsDrawMFHD(holdings, entryNum) {
225 if (!orgIsMine(findOrgUnit(holdings.owning_lib()), findOrgUnit(getLocation()))) {
228 var hh = holdings.holdings();
229 var hch = holdings.current_holdings();
230 var hs = holdings.supplements();
231 var hcs = holdings.current_supplements();
232 var hi = holdings.indexes();
233 var hci = holdings.current_indexes();
234 var ho = holdings.online();
235 var hm = holdings.missing();
236 var hinc = holdings.incomplete();
238 if ( hh.length == 0 && hch.length == 0 && hs.length == 0 &&
239 hcs.length == 0 && hi.length == 0 && hci.length == 0 &&
240 ho.length == 0 && hm.length == 0 && hinc.length == 0
245 dojo.place("<table><caption id='mfhdHoldingsCaption' class='rdetail_header color_1'>Holdings summary</caption><tbody id='rdetail_holdings_tbody_" + entryNum + "'></tbody></table>", "rdetail_details_table", "after");
246 if (hh.length > 0) { _holdingsDrawMFHDEntry(entryNum, 'Holdings', hh); }
247 if (hch.length > 0) { _holdingsDrawMFHDEntry(entryNum, 'Current holdings', hch); }
248 if (hs.length > 0) { _holdingsDrawMFHDEntry(entryNum, 'Supplements', hs); }
249 if (hcs.length > 0) { _holdingsDrawMFHDEntry(entryNum, 'Current supplements', hcs); }
250 if (hi.length > 0) { _holdingsDrawMFHDEntry(entryNum, 'Indexes', hi); }
251 if (hci.length > 0) { _holdingsDrawMFHDEntry(entryNum, 'Current indexes', hci); }
252 if (ho.length > 0) { _holdingsDrawMFHDEntry(entryNum, 'Online', ho); }
253 if (hm.length > 0) { _holdingsDrawMFHDEntry(entryNum, 'Missing volumes', hm); }
254 if (hinc.length > 0) { _holdingsDrawMFHDEntry(entryNum, 'Incomplete volumes', hm); }
257 dojo.require('openils.Event');
258 dojo.require('openils.PermaCrud');
259 dojo.place("<span> - </span><a class='classic_link' href='javascript:loadMarcEditor(" + holdings.id() + ")'> Edit</a>", "mfhdHoldingsCaption", "last");
263 function _holdingsDrawMFHDEntry(entryNum, entryName, entry) {
264 var flatEntry = entry.toString().replace(/,/g, ', ');
265 dojo.place("<tr><td> </td><td nowrap='nowrap' class='rdetail_desc'>" + entryName + "</td><td class='rdetail_item'>" + flatEntry + "</td></tr>", "rdetail_holdings_tbody_" + entryNum, "last");
268 function _rdetailDraw(r) {
269 record = r.getResultObject();
271 runEvt('rdetail', 'recordRetrieved', record.doc_id());
273 G.ui.rdetail.title.appendChild(text(record.title()));
274 buildSearchLink(STYPE_AUTHOR, record.author(), G.ui.rdetail.author);
275 G.ui.rdetail.isbn.appendChild(text(cleanISBN(record.isbn())));
276 G.ui.rdetail.edition.appendChild(text(record.edition()));
277 G.ui.rdetail.pubdate.appendChild(text(record.pubdate()));
278 G.ui.rdetail.publisher.appendChild(text(record.publisher()));
279 $('rdetail_physical_desc').appendChild(text(record.physical_description()));
280 r = record.types_of_resource();
282 G.ui.rdetail.tor.appendChild(text(r[0]));
283 setResourcePic( G.ui.rdetail.tor_pic, r[0]);
285 G.ui.rdetail.abstr.appendChild(text(record.synopsis()));
289 if(ENABLE_ADDED_CONTENT_ATTRIB_LINKS) {
290 unHideMe($('rdetail.jacket_attrib_div'));
291 var href = $('rdetail.jacket_attrib_link').getAttribute('href') +cleanISBN(record.isbn());
292 $('rdetail.jacket_attrib_link').setAttribute('href', href);
294 rdetailCheckForGBPreview();
297 hideMe($("rdetail.jacket_attrib_div"));
298 hideMe($("rdetail_img_link"));
303 // see if the record has any external links
304 var links = record.online_loc();
305 for( var i = 0; links && links.length > 0 && i < links.length; i = i + 3 ) {
307 // avoid matching "HTTP: The Complete Reference"
308 if( href.match(/https?:\/|ftps?:\/|mailto:/i) ) {
309 unHideMe($('rdetail_online_row'));
310 // MODS can contain a display label (used for the text of the link)
311 // as well as a note about the URL; many legacy systems conflate the
312 // two and generate MARC records that expect the note to be used as
313 // the text of the link, with no display label; here's the canonical
316 // 856 40 $uhttp://localhost$yDisplay label$zPublic note
318 // Note that the MARC21slim2MODS XSL concatenates $3 and $y together
319 // (as $y was defined later in MARC21's life as the display label)
320 var displayLabel = '' + links[i+1];
321 var note = '' + links[i+2];
322 if(!displayLabel || displayLabel.match(/https?:\/|ftps?:\/|mailto:/i)) {
323 if(!note || note.match(/https?:\/|ftps?:\/|mailto:/i)) {
329 $('rdetail_online').appendChild(elem('a', {href:href,'class':'classic_link'}, displayLabel));
330 if (!note && note != displayLabel) {
331 $('rdetail_online').appendChild(elem('span', {'class':'url_note'}, ' - ' + note));
333 $('rdetail_online').appendChild(elem('br'));
337 // Fill in our unAPI ID, if anyone cares
338 var abbrs = document.getElementsByTagName('abbr');
340 for (var i = 0; i < abbrs.length; i = i + 1) {
341 if (abbrs[i].getAttribute('name') == 'unapi') {
346 buildunAPISpan( span, 'biblio-record_entry', record.doc_id() );
348 $('rdetail_place_hold').setAttribute(
349 'href','javascript:holdsDrawEditor({record:"'+record.doc_id()+'",type:"T"});');
351 $('rdetail_img_link').setAttribute('href', buildISBNSrc(cleanISBN(record.isbn()), 'large'));
352 G.ui.rdetail.image.setAttribute("src", buildISBNSrc(cleanISBN(record.isbn())));
353 runEvt("rdetail", "recordDrawn");
354 recordsCache.push(record);
356 rdetailSetExtrasSelector();
358 var breq = new Request(FETCH_BRE, [getRid()]);
359 breq.callback( rdetailCheckDeleted );
362 resultBuildCaches( [ record ] );
363 resultDrawSubjects();
366 // grab added content
367 acCollectData(cleanISBN(record.isbn()), rdetailhandleAC);
372 function rdetailCheckDeleted(r) {
373 var br = r.getResultObject()[0];
374 if( isTrue(br.deleted()) ) {
375 hideMe($('rdetail_place_hold'));
376 $('rdetail_more_actions_selector').disabled = true;
377 unHideMe($('rdetail_deleted_exp'));
381 function rdetailSetExtrasSelector() {
382 if(!grabUser()) return;
383 unHideMe($('rdetail_more_actions'));
385 var req = new Request(
386 FETCH_CONTAINERS, G.user.session, G.user.id(), 'biblio', 'bookbag' );
387 req.callback(rdetailAddBookbags);
391 function rdetailAddBookbags(r) {
393 var containers = r.getResultObject();
394 var selector = $('rdetail_more_actions_selector');
397 doSelectorActions(selector);
399 for( var i = 0; i != containers.length; i++ ) {
401 var container = containers[i];
402 insertSelectorVal( selector, index++, container.name(),
403 "container_" + container.id(), rdetailAddToBookbag, 1 );
406 nextContainerIndex = index;
410 function rdetailNewBookbag() {
411 var name = prompt($('rdetail_bb_new').innerHTML,"");
415 if( id = containerCreate( name ) ) {
416 alert($('rdetail_bb_success').innerHTML);
417 var selector = $('rdetail_more_actions_selector');
418 insertSelectorVal( selector, nextContainerIndex++, name,
419 "container_" + id, rdetailAddToBookbag, 1 );
420 setSelector( selector, 'start' );
425 function rdetailAddToBookbag() {
426 var selector = $('rdetail_more_actions_selector');
427 var id = selector.options[selector.selectedIndex].value;
428 setSelector( selector, 'start' );
430 if( containerCreateItem( id.substring(10), record.doc_id() )) {
431 alert($('rdetail_bb_item_success').innerHTML);
436 var rdetailMarcFetched = false;
437 function rdetailShowExtra(type, args) {
439 hideMe($('rdetail_copy_info_div'));
440 hideMe($('rdetail_reviews_div'));
441 hideMe($('rdetail_toc_div'));
442 hideMe($('rdetail_anotes_div'));
443 hideMe($('rdetail_excerpt_div'));
444 hideMe($('rdetail_preview_div'));
445 hideMe($('rdetail_marc_div'));
446 hideMe($('cn_browse'));
447 hideMe($('rdetail_cn_browse_div'));
448 hideMe($('rdetail_notes_div'));
450 removeCSSClass($('rdetail_copy_info_link'), 'rdetail_extras_selected');
451 removeCSSClass($('rdetail_viewcn_link'), 'rdetail_extras_selected');
452 removeCSSClass($('rdetail_reviews_link'), 'rdetail_extras_selected');
453 removeCSSClass($('rdetail_toc_link'), 'rdetail_extras_selected');
454 removeCSSClass($('rdetail_excerpt_link'), 'rdetail_extras_selected');
455 removeCSSClass($('rdetail_preview_link'), 'rdetail_extras_selected');
456 removeCSSClass($('rdetail_anotes_link'), 'rdetail_extras_selected');
457 removeCSSClass($('rdetail_annotation_link'), 'rdetail_extras_selected');
458 removeCSSClass($('rdetail_viewmarc_link'), 'rdetail_extras_selected');
463 unHideMe($('rdetail_copy_info_div'));
464 addCSSClass($('rdetail_copy_info_link'), 'rdetail_extras_selected');
468 addCSSClass($('rdetail_reviews_link'), 'rdetail_extras_selected');
469 unHideMe($('rdetail_reviews_div'));
473 addCSSClass($('rdetail_excerpt_link'), 'rdetail_extras_selected');
474 unHideMe($('rdetail_excerpt_div'));
478 addCSSClass($('rdetail_preview_link'), 'rdetail_extras_selected');
479 unHideMe($('rdetail_preview_div'));
480 rdetailDisplayGBPreview();
484 addCSSClass($('rdetail_anotes_link'), 'rdetail_extras_selected');
485 unHideMe($('rdetail_anotes_div'));
489 addCSSClass($('rdetail_toc_link'), 'rdetail_extras_selected');
490 unHideMe($('rdetail_toc_div'));
494 addCSSClass($('rdetail_viewmarc_link'), 'rdetail_extras_selected');
495 unHideMe($('rdetail_marc_div'));
496 if(rdetailMarcFetched) return;
497 unHideMe($('rdetail_extras_loading'));
498 rdetailMarcFetched = true;
499 var req = new Request( FETCH_MARC_HTML, record.doc_id() );
500 req.callback(rdetailViewMarc);
505 addCSSClass($('rdetail_viewcn_link'), 'rdetail_extras_selected');
506 unHideMe($('rdetail_cn_browse_div'));
507 rdetailShowCNBrowse(defaultCN, getLocation(), null, true);
513 function rdetailVolumeDetails(args) {
514 var row = $(args.rowid);
515 var tbody = row.parentNode;
516 cpdBuild( tbody, row, record, args.cn, args.org, args.depth, args.copy_location );
520 function rdetailBuildCNList() {
522 var select = $('cn_browse_selector');
525 for( var cn in callnumberCache ) arr.push( cn );
528 if( arr.length == 0 ) {
529 hideMe($('rdetail_cn_browse_select_div'));
533 for( var i in arr ) {
535 var opt = new Option(cn);
536 select.options[index++] = opt;
538 select.onchange = rdetailGatherCN;
541 function rdetailGatherCN() {
542 var cn = getSelectorVal($('cn_browse_selector'));
543 rdetailShowCNBrowse( cn, getLocation(), getDepth(), true );
544 setSelector( $('cn_browse_selector'), cn );
548 function rdetailShowCNBrowse( cn, loc, depth, fromOnclick ) {
551 unHideMe($('cn_browse_none'));
552 hideMe($('rdetail_cn_browse_select_div'));
556 unHideMe($('rdetail_cn_browse_select_div'));
557 rdetailBuildCNList();
558 setSelector( $('cn_browse_selector'), cn );
559 hideMe($('rdetail_copy_info_div'));
560 hideMe($('rdetail_reviews_div'));
561 hideMe($('rdetail_toc_div'));
562 hideMe($('rdetail_marc_div'));
563 unHideMe($('rdetail_cn_browse_div'));
564 unHideMe($('cn_browse'));
565 if( !rdetailLocalOnly && ! fromOnclick ) depth = findOrgDepth(globalOrgTree);
566 cnBrowseGo(cn, loc, depth);
569 function rdetailhandleAC(data) {
571 if( data.reviews.html ) {
572 $('rdetail_review_container').innerHTML = data.reviews.html;
573 unHideMe($('rdetail_reviews_link'));
576 if( data.toc.html ) {
577 $('rdetail_toc_div').innerHTML = data.toc.html;
578 unHideMe($('rdetail_toc_link'));
581 if( data.excerpt.html ) {
582 $('rdetail_excerpt_div').innerHTML = data.excerpt.html;
583 unHideMe($('rdetail_excerpt_link'));
586 if( data.anotes.html ) {
587 $('rdetail_anotes_div').innerHTML = data.anotes.html;
588 unHideMe($('rdetail_anotes_link'));
592 function rdetailShowReviews(r) {
593 hideMe($('rdetail_extras_loading'));
594 var res = r.getResultObject();
595 var par = $('rdetail_reviews_div');
596 var template = par.removeChild($('rdetail_review_template'));
597 if( res && res.length > 0 ) {
598 unHideMe($('rdetail_reviews_link'));
599 for( var i = 0; i != res.length; i++ ) {
601 if( rev.text && rev.info ) {
602 var node = template.cloneNode(true);
603 $n(node, 'review_header').appendChild(text(rev.info));
604 $n(node, 'review_text').appendChild(text(rev.text));
605 par.appendChild(node);
612 function rdetailShowTOC(r) {
613 hideMe($('rdetail_extras_loading'));
614 var resp = r.getResultObject();
616 unHideMe($('rdetail_toc_link'));
617 $('rdetail_toc_div').innerHTML = resp;
621 function rdetailBuildInfoRows() {
623 var method = FETCH_COPY_COUNTS_SUMMARY;
624 if (rdetailShowCopyLocation)
625 method = FETCH_COPY_LOCATION_COUNTS_SUMMARY;
627 if( rdetailShowLocal )
628 req = new Request(method, record.doc_id(), getLocation(), getDepth())
630 req = new Request(method, record.doc_id());
631 req.callback(_rdetailBuildInfoRows);
635 function _rdetailRows(node) {
637 if( rdetailShowLocal && getLocation() != globalOrgTree.id() ) {
638 var loc = findOrgUnit(getLocation());
640 if( !orgIsMine(node, loc) && !orgIsMine(loc,node) ) return;
642 for( var i = 0; i < globalOrgTree.children().length; i++ ) {
643 var org = findOrgUnit(globalOrgTree.children()[i]);
644 if( orgIsMine(org, loc) ) {
652 if(!node && findOrgType(globalOrgTree.ou_type()).can_have_vols())
653 node = globalOrgTree;
656 /* don't show hidden orgs */
660 if(!isXUL() && !isTrue(node.opac_visible())) return;
662 var row = copyRow.cloneNode(true);
663 row.id = "cp_info_" + node.id();
665 var libtd = findNodeByName( row, config.names.rdetail.lib_cell );
666 var cntd = findNodeByName( row, config.names.rdetail.cn_cell );
667 var cpctd = findNodeByName( row, config.names.rdetail.cp_count_cell );
668 var actions = $n(row, 'rdetail_actions_cell');
670 var p = libtd.getElementsByTagName('a')[0];
671 libtd.insertBefore(text(node.name()), p);
672 libtd.setAttribute("style", "padding-left: " + ((findOrgDepth(node) - 1) * 9) + "px;");
674 if(!findOrgType(node.ou_type()).can_have_vols()) {
676 row.removeChild(cntd);
677 row.removeChild(cpctd);
678 row.removeChild(actions);
679 row.setAttribute('novols', '1');
681 libtd.setAttribute("colspan", numStatuses + 3 );
682 libtd.colSpan = numStatuses + 3;
683 addCSSClass(row, 'copy_info_region_row');
686 copyRowParent.appendChild(row);
688 } else { node = globalOrgTree; }
690 for( var c in node.children() )
691 _rdetailRows(node.children()[c]);
694 function rdetailCNPrint(orgid, cn) {
695 var div = cpdBuildPrintWindow( record, orgid);
696 var template = div.removeChild($n(div, 'cnrow'));
697 var rowNode = $("cp_info_" + orgid);
698 cpdStylePopupWindow(div);
699 openWindow(div.innerHTML);
702 var localCNFound = false;
704 function _rdetailBuildInfoRows(r) {
706 if (rdetailShowCopyLocation)
707 unHideMe( $n( $('rdetail_copy_info_table'), 'rdetail_copylocation_header' ) );
709 removeChildren(copyRowParent);
713 var summary = r.getResultObject();
717 for( var i = 0; i < summary.length; i++ ) {
719 var arr = summary[i];
720 globalCNCache[arr[1]] = 1;
721 var thisOrg = findOrgUnit(arr[0]);
722 var rowNode = $("cp_info_" + thisOrg.id());
723 if(!rowNode) continue;
725 if(rowNode.getAttribute("used")) {
727 if( rowNode.nextSibling ) {
728 sib = rowNode.nextSibling;
729 o ='cp_info_'+thisOrg.id()+'_';
730 /* push the new row on as the last row for this org unit */
731 while( sib && sib.id.match(o) ) {
732 sib = sib.nextSibling;
735 rowNode = copyRowParent.insertBefore(copyRow.cloneNode(true), sib);
737 rowNode = copyRowParent.appendChild(copyRow.cloneNode(true));
739 rowNode = copyRowParent.appendChild(copyRow.cloneNode(true));
742 var n = findNodeByName( rowNode, config.names.rdetail.lib_cell );
743 n.appendChild(text(thisOrg.name()));
744 n.setAttribute("style", "padding-left: " + ((findOrgDepth(thisOrg) - 1) * 9) + "px;");
745 rowNode.id = "cp_info_" + thisOrg.id() + '_' + (++ctr);
748 rowNode.setAttribute("used", "1");
751 var cpc_temp = rowNode.removeChild(
752 findNodeByName(rowNode, config.names.rdetail.cp_count_cell));
754 var statuses = arr[2];
756 if (rdetailShowCopyLocation) {
762 rdetailApplyStatuses(rowNode, cpc_temp, statuses);
765 if( orgIsMine( findOrgUnit(getLocation()), thisOrg ) ) {
774 //if(isLocal) unHideMe(rowNode);
777 rdetailSetPath( thisOrg, isLocal );
778 rdetailBuildBrowseInfo( rowNode, arr[1], isLocal, thisOrg, cl );
780 if( i == summary.length - 1 && !defaultCN) defaultCN = arr[1];
783 if(!found) unHideMe(G.ui.rdetail.cp_info_none);
786 function rdetailBuildBrowseInfo(row, cn, local, orgNode, cl) {
789 var cache = callnumberCache[cn];
790 if( cache ) cache.count++;
791 else callnumberCache[cn] = { count : 1 };
794 var depth = getDepth();
795 if( !local ) depth = findOrgDepth(globalOrgTree);
797 $n(row, 'rdetail_callnumber_cell').appendChild(text(cn));
799 if (rdetailShowCopyLocation) {
800 var cl_cell = $n(row, 'rdetail_copylocation_cell');
801 cl_cell.appendChild(text(cl));
805 _debug('setting action clicks for cn ' + cn);
807 var dHref = 'javascript:rdetailVolumeDetails('+
808 '{copy_location : "'+cl+'", rowid : "'+row.id+'", cn :"'+cn+'", depth:"'+depth+'", org:"'+orgNode.id()+'", local: '+local+'});';
810 var bHref = 'javascript:rdetailShowCNBrowse("' + cn + '", '+orgNode.id()+', "'+depth+'");';
812 unHideMe( $n(row, 'details') )
813 $n(row, 'details').setAttribute('href', dHref);
814 unHideMe( $n(row, 'browse') )
815 $n(row, 'browse').setAttribute('href', bHref);
818 unHideMe($n(row, 'hold_div'));
819 $n(row, 'hold').onclick = function() {
820 var req = new Request(FETCH_VOLUME_BY_INFO, cn, record.doc_id(), orgNode.id());
823 var vol = r.getResultObject();
824 holdsDrawEditor({type: 'V', volumeObject : vol});
832 // sets the path to org as 'active' and displays the path if it's local
833 function rdetailSetPath(org, local) {
834 if( findOrgDepth(org) == 0 ) return;
835 var row = $("cp_info_" + org.id());
836 row.setAttribute("hasinfo", "1");
838 rdetailSetPath(findOrgUnit(org.parent_ou()), local);
841 //Append all the statuses for a given summary to the
843 function rdetailApplyStatuses( row, template, statuses ) {
844 for( var j in _statusPositions ) {
845 var stat = _statusPositions[j];
846 var val = statuses[stat.id()];
847 var nn = template.cloneNode(true);
848 if(val) nn.appendChild(text(val));
849 else nn.appendChild(text(0));
854 //Add one td (creating a new column) to the copy summary
855 //table for each opac_visible copy status
856 function rdetailBuildStatusColumns() {
858 rdetailGrabCopyStatuses();
859 var parent = statusRow;
860 var template = parent.removeChild(G.ui.rdetail.cp_status);
863 for( i = 0; i < cp_statuses.length; i++ ) {
865 var c = cp_statuses[i];
866 if( c && isTrue(c.opac_visible()) ) {
868 _statusPositions[i] = c;
869 var node = template.cloneNode(true);
870 var data = findNodeByName( node, config.names.rdetail.cp_status);
872 data.appendChild(text(name));
873 parent.appendChild(node);
878 for(x in _statusPositions) numStatuses++;
881 function rdetailGrabCopyStatuses() {
882 if(cp_statuses) return cp_statuses;
883 var req = new Request(FETCH_COPY_STATUSES);
885 cp_statuses = req.result();
886 cp_statuses = cp_statuses.sort(_rdetailSortStatuses);
889 function _rdetailSortStatuses(a, b) {
890 return parseInt(a.id()) - parseInt(b.id());
894 * Check for a Google Book preview
896 function rdetailCheckForGBPreview() {
897 if (!googleBookPreview) return;
898 searchForGBPreview( cleanISBN(record.isbn()) );
903 * @param {DOM object} query The form element containing the
904 * input parameters "isbns"
906 function searchForGBPreview( isbn ) {
908 // Delete any previous Google Booksearch JSON queries.
909 var GBPJsonScript = document.getElementById("GBPJsonScript");
911 GBPJsonScript.parentNode.removeChild(GBPJsonScript);
914 // Add a script element with the src as the user's Google Booksearch query.
915 // JSON output is specified by including the alt=json-in-script argument
916 // and the callback function is also specified as a URI argument.
917 var GBPScriptElement = document.createElement("script");
919 GBPScriptElement.setAttribute("id", "GBPJsonScript");
920 GBPScriptElement.setAttribute("src",
921 "http://books.google.com/books?bibkeys=" +
922 isbn + "&jscmd=viewapi&callback=GBPreviewCallback");
923 GBPScriptElement.setAttribute("type", "text/javascript");
925 // make the request to Google booksearch
926 document.documentElement.firstChild.appendChild(GBPScriptElement);
930 * This function is the call-back function for the JSON scripts which
931 * executes a Google book search response.
933 * XXX I18N of text needed
935 * @param {JSON} booksInfo is the JSON object pulled from the Google books service.
937 function GBPreviewCallback(GBPBookInfo) {
938 var GBPreviewDiv = document.getElementById("rdetail_preview_div");
941 for ( i in GBPBookInfo ) {
942 GBPBook = GBPBookInfo[i];
949 if ( GBPBook.preview != "noview" ) {
950 if ( GBPBook.preview == 'full' ) {
951 setText( $('rdetail_preview_link'), $('rdetail_preview_full_text').innerHTML );
952 $('rdetail_preview_link_a').title = $('rdetail_preview_title').innerHTML;
955 // Add a button below the book cover image to load the preview.
956 GBPBadge = document.createElement( 'img' );
957 GBPBadge.src = 'http://books.google.com/intl/en/googlebooks/images/gbs_preview_button1.gif';
958 GBPBadge.title = $('rdetail_preview_badge').innerHTML;
959 GBPBadge.style.border = 0;
960 GBPBadgelink = document.createElement( 'a' );
961 GBPBadgelink.href = 'javascript:rdetailShowExtra("preview");';
962 GBPBadgelink.appendChild( GBPBadge );
963 $('rdetail_image_cell').appendChild( GBPBadgelink );
964 $('rdetail_preview_div').style.height = 600;
966 /* Display the "Preview" tab in the Extras section */
967 unHideMe( $('rdetail_preview_link' ) );
972 * This is called when the user clicks on the 'Preview' link. We assume
973 * a preview is available from Google if this link was made visible.
975 * XXX I18N of Google Book Preview language attribute needed
977 function rdetailDisplayGBPreview() {
978 unHideMe($('rdetail_extras_loading'));
979 GBPreviewPane = $('rdetail_preview_div');
980 if ( GBPreviewPane.getAttribute('loaded') == null ||
981 GBPreviewPane.getAttribute('loaded') == "false" ) {
982 google.load("books", "0", {"callback" : rdetailGBPViewerLoadCallback, "language": "en"} );
983 GBPreviewPane.setAttribute('loaded', 'true');
987 function rdetailGBPViewerLoadCallback() {
988 hideMe($('rdetail_extras_loading'));
989 var GBPViewer = new google.books.DefaultViewer(document.getElementById('rdetail_preview_div'));
990 GBPViewer.load('ISBN:' + cleanISBN(record.isbn()) );