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;
31 var nextContainerIndex;
33 function rdetailReload() {
35 args[PARAM_LOCATION] = getNewSearchLocation();
36 args[PARAM_DEPTH] = depthSelGetDepth();
37 goTo(buildOPACLink(args));
43 var rdetailPrev = null;
44 var rdetailNext = null;
45 var rdetailStart = null;
46 var rdetailEnd = null;
50 /* looks to see if we have a next and/or previous record in the
51 record cache, if so, set up the nav links */
52 function rdetailSetPaging(ids) {
55 cachedRecords.ids = ids;
57 for( var i = 0; i < cachedRecords.ids.length; i++ ) {
58 var rec = cachedRecords.ids[i];
59 if( rec == getRid() ) {
60 if( i > 0 ) prevRecord = cachedRecords.ids[i-1];
61 if( i < cachedRecords.ids.length - 1 )
62 nextRecord = cachedRecords.ids[i+1];
67 $('np_offset').appendChild(text(i + 1));
68 $('np_count').appendChild(text(getHitCount()));
71 unHideMe($('np_table'));
72 unHideMe($('np_prev'));
73 unHideMe($('np_start'));
74 rdetailPrev = function() { _rdetailNav(prevRecord); };
75 rdetailStart = function() { _rdetailNav(cachedRecords.ids[0]); };
79 unHideMe($('np_table'));
80 unHideMe($('np_next'));
81 unHideMe($('np_end'));
82 rdetailNext = function() { _rdetailNav(nextRecord); };
83 rdetailEnd = function() { _rdetailNav(cachedRecords.ids[cachedRecords.ids.length-1]); };
86 runEvt('rdetail', 'nextPrevDrawn', i, cachedRecords.ids.length);
90 function _rdetailNav(id, offset) {
93 goTo(buildOPACLink(args));
96 function rdetailDraw() {
98 detachAllEvt('common','depthChanged');
99 detachAllEvt('common','locationUpdated');
100 attachEvt('common','depthChanged', rdetailReload);
101 attachEvt('common','locationUpdated', rdetailReload);
102 attachEvt('common','holdUpdated', rdetailReload);
103 attachEvt('common','holdUpdateCanceled', rdetailReload);
105 copyRowParent = G.ui.rdetail.cp_info_row.parentNode;
106 copyRow = copyRowParent.removeChild(G.ui.rdetail.cp_info_row);
107 statusRow = G.ui.rdetail.cp_status.parentNode;
108 statusRow.id = '__rdsrow';
110 G.ui.rdetail.cp_info_local.onclick = rdetailShowLocalCopies;
111 G.ui.rdetail.cp_info_all.onclick = rdetailShowAllCopies;
113 if(getLocation() == globalOrgTree.id())
114 hideMe(G.ui.rdetail.cp_info_all);
116 var req = new Request(FETCH_RMODS, getRid());
117 req.callback(_rdetailDraw);
120 detachAllEvt("result", "idsReceived");
121 G.evt.result.hitCountReceived = [];
122 G.evt.result.recordReceived = [];
123 G.evt.result.copyCountsReceived = [];
124 G.evt.result.allRecordsReceived = [];
127 function rdetailGetPageIds() {
128 attachEvt("result", "idsReceived", rdetailSetPaging );
129 resultFetchAllRecords = true;
130 rresultCollectIds(true);
134 function buildunAPISpan (span, type, id) {
138 addCSSClass(span,'unapi-id');
141 'title', 'tag:' + cgi.server_name + ',' +
142 d.getFullYear() + ':' + type + '/' + id
146 function rdetailViewMarc(r,id) {
147 hideMe($('rdetail_extras_loading'));
148 $('rdetail_view_marc_box').innerHTML = r.getResultObject();
150 var div = elem('div', { "class" : 'hide_me' });
151 var span = div.appendChild( elem('abbr') );
153 buildunAPISpan( span, 'biblio-record_entry', record.doc_id() );
155 $('rdetail_view_marc_box').insertBefore(span, $('rdetail_view_marc_box').firstChild);
159 function rdetailShowLocalCopies() {
160 rdetailShowLocal = true;
161 rdetailBuildInfoRows();
162 hideMe(G.ui.rdetail.cp_info_local);
163 unHideMe(G.ui.rdetail.cp_info_all);
164 hideMe(G.ui.rdetail.cp_info_none);
167 function rdetailShowAllCopies() {
169 rdetailShowLocal = false;
170 rdetailBuildInfoRows();
171 hideMe(G.ui.rdetail.cp_info_all);
172 unHideMe(G.ui.rdetail.cp_info_local);
173 hideMe(G.ui.rdetail.cp_info_none);
177 function _rdetailDraw(r) {
178 record = r.getResultObject();
180 runEvt('rdetail', 'recordRetrieved', record.doc_id());
182 G.ui.rdetail.title.appendChild(text(record.title()));
183 buildSearchLink(STYPE_AUTHOR, record.author(), G.ui.rdetail.author);
184 G.ui.rdetail.isbn.appendChild(text(cleanISBN(record.isbn())));
185 G.ui.rdetail.edition.appendChild(text(record.edition()));
186 G.ui.rdetail.pubdate.appendChild(text(record.pubdate()));
187 G.ui.rdetail.publisher.appendChild(text(record.publisher()));
188 $('rdetail_physical_desc').appendChild(text(record.physical_description()));
189 r = record.types_of_resource();
191 G.ui.rdetail.tor.appendChild(text(r[0]));
192 setResourcePic( G.ui.rdetail.tor_pic, r[0]);
194 G.ui.rdetail.abstr.appendChild(text(record.synopsis()));
198 if(ENABLE_ADDED_CONTENT_ATTRIB_LINKS) {
199 unHideMe($('rdetail.jacket_attrib_div'));
200 var href = $('rdetail.jacket_attrib_link').getAttribute('href') +cleanISBN(record.isbn());
201 $('rdetail.jacket_attrib_link').setAttribute('href', href);
203 rdetailCheckForGBPreview();
206 hideMe($("rdetail.jacket_attrib_div"));
207 hideMe($("rdetail_img_link"));
212 // see if the record has any external links
213 var links = record.online_loc();
214 for( var i = 0; links && links.length > 0 && i < links.length; i = i + 3 ) {
216 // avoid matching "HTTP: The Complete Reference"
217 if( href.match(/https?:\/|ftps?:\/|mailto:/i) ) {
218 unHideMe($('rdetail_online_row'));
219 // MODS can contain a display label (used for the text of the link)
220 // as well as a note about the URL; many legacy systems conflate the
221 // two and generate MARC records that expect the note to be used as
222 // the text of the link, with no display label; here's the canonical
225 // 856 40 $uhttp://localhost$yDisplay label$zPublic note
227 // Note that the MARC21slim2MODS XSL concatenates $3 and $y together
228 // (as $y was defined later in MARC21's life as the display label)
229 var displayLabel = '' + links[i+1];
230 var note = '' + links[i+2];
231 if(!displayLabel || displayLabel.match(/https?:\/|ftps?:\/|mailto:/i)) {
232 if(!note || note.match(/https?:\/|ftps?:\/|mailto:/i)) {
238 $('rdetail_online').appendChild(elem('a', {href:href,'class':'classic_link'}, displayLabel));
239 if (!note && note != displayLabel) {
240 $('rdetail_online').appendChild(elem('span', {'class':'url_note'}, ' - ' + note));
242 $('rdetail_online').appendChild(elem('br'));
246 // Fill in our unAPI ID, if anyone cares
247 var abbrs = document.getElementsByTagName('abbr');
249 for (var i = 0; i < abbrs.length; i = i + 1) {
250 if (abbrs[i].getAttribute('name') == 'unapi') {
255 buildunAPISpan( span, 'biblio-record_entry', record.doc_id() );
257 $('rdetail_place_hold').setAttribute(
258 'href','javascript:holdsDrawEditor({record:"'+record.doc_id()+'",type:"T"});');
260 $('rdetail_img_link').setAttribute('href', buildISBNSrc(cleanISBN(record.isbn()), 'large'));
261 G.ui.rdetail.image.setAttribute("src", buildISBNSrc(cleanISBN(record.isbn())));
262 runEvt("rdetail", "recordDrawn");
263 recordsCache.push(record);
265 rdetailSetExtrasSelector();
267 var breq = new Request(FETCH_BRE, [getRid()]);
268 breq.callback( rdetailCheckDeleted );
271 resultBuildCaches( [ record ] );
272 resultDrawSubjects();
275 // grab added content
276 acCollectData(cleanISBN(record.isbn()), rdetailhandleAC);
281 function rdetailCheckDeleted(r) {
282 var br = r.getResultObject()[0];
283 if( isTrue(br.deleted()) ) {
284 hideMe($('rdetail_place_hold'));
285 $('rdetail_more_actions_selector').disabled = true;
286 unHideMe($('rdetail_deleted_exp'));
290 function rdetailSetExtrasSelector() {
291 if(!grabUser()) return;
292 unHideMe($('rdetail_more_actions'));
294 var req = new Request(
295 FETCH_CONTAINERS, G.user.session, G.user.id(), 'biblio', 'bookbag' );
296 req.callback(rdetailAddBookbags);
300 function rdetailAddBookbags(r) {
302 var containers = r.getResultObject();
303 var selector = $('rdetail_more_actions_selector');
306 doSelectorActions(selector);
308 for( var i = 0; i != containers.length; i++ ) {
310 var container = containers[i];
311 insertSelectorVal( selector, index++, container.name(),
312 "container_" + container.id(), rdetailAddToBookbag, 1 );
315 nextContainerIndex = index;
319 function rdetailNewBookbag() {
320 var name = prompt($('rdetail_bb_new').innerHTML,"");
324 if( id = containerCreate( name ) ) {
325 alert($('rdetail_bb_success').innerHTML);
326 var selector = $('rdetail_more_actions_selector');
327 insertSelectorVal( selector, nextContainerIndex++, name,
328 "container_" + id, rdetailAddToBookbag, 1 );
329 setSelector( selector, 'start' );
334 function rdetailAddToBookbag() {
335 var selector = $('rdetail_more_actions_selector');
336 var id = selector.options[selector.selectedIndex].value;
337 setSelector( selector, 'start' );
339 if( containerCreateItem( id.substring(10), record.doc_id() )) {
340 alert($('rdetail_bb_item_success').innerHTML);
345 var rdetailMarcFetched = false;
346 function rdetailShowExtra(type, args) {
348 hideMe($('rdetail_copy_info_div'));
349 hideMe($('rdetail_reviews_div'));
350 hideMe($('rdetail_toc_div'));
351 hideMe($('rdetail_anotes_div'));
352 hideMe($('rdetail_performer_notes_div'));
353 hideMe($('rdetail_excerpt_div'));
354 hideMe($('rdetail_preview_div'));
355 hideMe($('rdetail_marc_div'));
356 hideMe($('cn_browse'));
357 hideMe($('rdetail_cn_browse_div'));
358 hideMe($('rdetail_notes_div'));
360 removeCSSClass($('rdetail_copy_info_link'), 'rdetail_extras_selected');
361 removeCSSClass($('rdetail_viewcn_link'), 'rdetail_extras_selected');
362 removeCSSClass($('rdetail_reviews_link'), 'rdetail_extras_selected');
363 removeCSSClass($('rdetail_toc_link'), 'rdetail_extras_selected');
364 removeCSSClass($('rdetail_excerpt_link'), 'rdetail_extras_selected');
365 removeCSSClass($('rdetail_preview_link'), 'rdetail_extras_selected');
366 removeCSSClass($('rdetail_anotes_link'), 'rdetail_extras_selected');
367 removeCSSClass($('rdetail_performer_notes_link'), 'rdetail_extras_selected');
368 removeCSSClass($('rdetail_annotation_link'), 'rdetail_extras_selected');
369 removeCSSClass($('rdetail_viewmarc_link'), 'rdetail_extras_selected');
374 unHideMe($('rdetail_copy_info_div'));
375 addCSSClass($('rdetail_copy_info_link'), 'rdetail_extras_selected');
379 addCSSClass($('rdetail_reviews_link'), 'rdetail_extras_selected');
380 unHideMe($('rdetail_reviews_div'));
384 addCSSClass($('rdetail_excerpt_link'), 'rdetail_extras_selected');
385 unHideMe($('rdetail_excerpt_div'));
389 addCSSClass($('rdetail_preview_link'), 'rdetail_extras_selected');
390 unHideMe($('rdetail_preview_div'));
391 rdetailDisplayGBPreview();
395 addCSSClass($('rdetail_anotes_link'), 'rdetail_extras_selected');
396 unHideMe($('rdetail_anotes_div'));
399 case "performer_notes":
400 addCSSClass($('rdetail_performer_notes_link'), 'rdetail_extras_selected');
401 unHideMe($('rdetail_performer_notes_div'));
405 addCSSClass($('rdetail_toc_link'), 'rdetail_extras_selected');
406 unHideMe($('rdetail_toc_div'));
410 addCSSClass($('rdetail_viewmarc_link'), 'rdetail_extras_selected');
411 unHideMe($('rdetail_marc_div'));
412 if(rdetailMarcFetched) return;
413 unHideMe($('rdetail_extras_loading'));
414 rdetailMarcFetched = true;
415 var req = new Request( FETCH_MARC_HTML, record.doc_id() );
416 req.callback(rdetailViewMarc);
421 addCSSClass($('rdetail_viewcn_link'), 'rdetail_extras_selected');
422 unHideMe($('rdetail_cn_browse_div'));
423 rdetailShowCNBrowse(defaultCN, getLocation(), null, true);
429 function rdetailVolumeDetails(args) {
430 var row = $(args.rowid);
431 var tbody = row.parentNode;
432 cpdBuild( tbody, row, record, args.cn, args.org, args.depth, args.copy_location );
436 function rdetailBuildCNList() {
438 var select = $('cn_browse_selector');
441 for( var cn in callnumberCache ) arr.push( cn );
444 if( arr.length == 0 ) {
445 hideMe($('rdetail_cn_browse_select_div'));
449 for( var i in arr ) {
451 var opt = new Option(cn);
452 select.options[index++] = opt;
454 select.onchange = rdetailGatherCN;
457 function rdetailGatherCN() {
458 var cn = getSelectorVal($('cn_browse_selector'));
459 rdetailShowCNBrowse( cn, getLocation(), getDepth(), true );
460 setSelector( $('cn_browse_selector'), cn );
464 function rdetailShowCNBrowse( cn, loc, depth, fromOnclick ) {
467 unHideMe($('cn_browse_none'));
468 hideMe($('rdetail_cn_browse_select_div'));
472 unHideMe($('rdetail_cn_browse_select_div'));
473 rdetailBuildCNList();
474 setSelector( $('cn_browse_selector'), cn );
475 hideMe($('rdetail_copy_info_div'));
476 hideMe($('rdetail_reviews_div'));
477 hideMe($('rdetail_toc_div'));
478 hideMe($('rdetail_marc_div'));
479 unHideMe($('rdetail_cn_browse_div'));
480 unHideMe($('cn_browse'));
481 if( !rdetailLocalOnly && ! fromOnclick ) depth = findOrgDepth(globalOrgTree);
482 cnBrowseGo(cn, loc, depth);
485 function rdetailhandleAC(data) {
487 if( data.reviews.html ) {
488 $('rdetail_review_container').innerHTML = data.reviews.html;
489 unHideMe($('rdetail_reviews_link'));
492 if( data.toc.html ) {
493 $('rdetail_toc_div').innerHTML = data.toc.html;
494 unHideMe($('rdetail_toc_link'));
495 } else if( record.toc() ) {
496 $('rdetail_toc_div').innerHTML = record.toc();
497 unHideMe($('rdetail_toc_link'));
500 if( data.excerpt.html ) {
501 $('rdetail_excerpt_div').innerHTML = data.excerpt.html;
502 unHideMe($('rdetail_excerpt_link'));
505 if( data.anotes.html ) {
506 $('rdetail_anotes_div').innerHTML = data.anotes.html;
507 unHideMe($('rdetail_anotes_link'));
510 if( record.performer_notes() ) {
511 $('rdetail_performer_notes_div').innerHTML = record.performer_notes();
512 unHideMe($('rdetail_performer_notes_link'));
516 function rdetailShowReviews(r) {
517 hideMe($('rdetail_extras_loading'));
518 var res = r.getResultObject();
519 var par = $('rdetail_reviews_div');
520 var template = par.removeChild($('rdetail_review_template'));
521 if( res && res.length > 0 ) {
522 unHideMe($('rdetail_reviews_link'));
523 for( var i = 0; i != res.length; i++ ) {
525 if( rev.text && rev.info ) {
526 var node = template.cloneNode(true);
527 $n(node, 'review_header').appendChild(text(rev.info));
528 $n(node, 'review_text').appendChild(text(rev.text));
529 par.appendChild(node);
536 function rdetailShowTOC(r) {
537 hideMe($('rdetail_extras_loading'));
538 var resp = r.getResultObject();
540 unHideMe($('rdetail_toc_link'));
541 $('rdetail_toc_div').innerHTML = resp;
545 function rdetailBuildInfoRows() {
547 var method = FETCH_COPY_COUNTS_SUMMARY;
548 if (rdetailShowCopyLocation)
549 method = FETCH_COPY_LOCATION_COUNTS_SUMMARY;
551 if( rdetailShowLocal )
552 req = new Request(method, record.doc_id(), getLocation(), getDepth())
554 req = new Request(method, record.doc_id());
555 req.callback(_rdetailBuildInfoRows);
559 function _rdetailRows(node) {
561 if( rdetailShowLocal && getLocation() != globalOrgTree.id() ) {
562 var loc = findOrgUnit(getLocation());
564 if( !orgIsMine(node, loc) ) return;
566 for( var i = 0; i < globalOrgTree.children().length; i++ ) {
567 var org = findOrgUnit(globalOrgTree.children()[i]);
568 if( orgIsMine(org, loc) ) {
576 if(!node && findOrgType(globalOrgTree.ou_type()).can_have_vols())
577 node = globalOrgTree;
580 /* don't show hidden orgs */
584 if(!isXUL() && !isTrue(node.opac_visible())) return;
586 var row = copyRow.cloneNode(true);
587 row.id = "cp_info_" + node.id();
589 var libtd = findNodeByName( row, config.names.rdetail.lib_cell );
590 var cntd = findNodeByName( row, config.names.rdetail.cn_cell );
591 var cpctd = findNodeByName( row, config.names.rdetail.cp_count_cell );
592 var actions = $n(row, 'rdetail_actions_cell');
594 var p = libtd.getElementsByTagName('a')[0];
595 libtd.insertBefore(text(node.name()), p);
596 libtd.setAttribute("style", "padding-left: " + ((findOrgDepth(node) - 1) * 9) + "px;");
598 if(!findOrgType(node.ou_type()).can_have_vols()) {
600 row.removeChild(cntd);
601 row.removeChild(cpctd);
602 row.removeChild(actions);
603 row.setAttribute('novols', '1');
605 libtd.setAttribute("colspan", numStatuses + 3 );
606 libtd.colSpan = numStatuses + 3;
607 addCSSClass(row, 'copy_info_region_row');
610 copyRowParent.appendChild(row);
612 } else { node = globalOrgTree; }
614 for( var c in node.children() )
615 _rdetailRows(node.children()[c]);
618 function rdetailCNPrint(orgid, cn) {
619 var div = cpdBuildPrintWindow( record, orgid);
620 var template = div.removeChild($n(div, 'cnrow'));
621 var rowNode = $("cp_info_" + orgid);
622 cpdStylePopupWindow(div);
623 openWindow(div.innerHTML);
626 var localCNFound = false;
628 function _rdetailBuildInfoRows(r) {
630 if (rdetailShowCopyLocation)
631 unHideMe( $n( $('rdetail_copy_info_table'), 'rdetail_copylocation_header' ) );
633 removeChildren(copyRowParent);
637 var summary = r.getResultObject();
641 for( var i = 0; i < summary.length; i++ ) {
643 var arr = summary[i];
644 globalCNCache[arr[1]] = 1;
645 var thisOrg = findOrgUnit(arr[0]);
646 var rowNode = $("cp_info_" + thisOrg.id());
647 if(!rowNode) continue;
649 if(rowNode.getAttribute("used")) {
651 if( rowNode.nextSibling ) {
652 sib = rowNode.nextSibling;
653 o ='cp_info_'+thisOrg.id()+'_';
654 /* push the new row on as the last row for this org unit */
655 while( sib && sib.id.match(o) ) {
656 sib = sib.nextSibling;
659 rowNode = copyRowParent.insertBefore(copyRow.cloneNode(true), sib);
661 rowNode = copyRowParent.appendChild(copyRow.cloneNode(true));
663 rowNode = copyRowParent.appendChild(copyRow.cloneNode(true));
666 var n = findNodeByName( rowNode, config.names.rdetail.lib_cell );
667 n.appendChild(text(thisOrg.name()));
668 n.setAttribute("style", "padding-left: " + ((findOrgDepth(thisOrg) - 1) * 9) + "px;");
669 rowNode.id = "cp_info_" + thisOrg.id() + '_' + (++ctr);
672 rowNode.setAttribute("used", "1");
675 var cpc_temp = rowNode.removeChild(
676 findNodeByName(rowNode, config.names.rdetail.cp_count_cell));
678 var statuses = arr[2];
680 if (rdetailShowCopyLocation) {
686 rdetailApplyStatuses(rowNode, cpc_temp, statuses);
689 if( orgIsMine( findOrgUnit(getLocation()), thisOrg ) ) {
698 //if(isLocal) unHideMe(rowNode);
701 rdetailSetPath( thisOrg, isLocal );
702 rdetailBuildBrowseInfo( rowNode, arr[1], isLocal, thisOrg, cl );
704 if( i == summary.length - 1 && !defaultCN) defaultCN = arr[1];
707 if(!found) unHideMe(G.ui.rdetail.cp_info_none);
710 function rdetailBuildBrowseInfo(row, cn, local, orgNode, cl) {
713 var cache = callnumberCache[cn];
714 if( cache ) cache.count++;
715 else callnumberCache[cn] = { count : 1 };
718 var depth = getDepth();
719 if( !local ) depth = findOrgDepth(globalOrgTree);
721 $n(row, 'rdetail_callnumber_cell').appendChild(text(cn));
723 if (rdetailShowCopyLocation) {
724 var cl_cell = $n(row, 'rdetail_copylocation_cell');
725 cl_cell.appendChild(text(cl));
729 _debug('setting action clicks for cn ' + cn);
731 var dHref = 'javascript:rdetailVolumeDetails('+
732 '{copy_location : "'+cl+'", rowid : "'+row.id+'", cn :"'+cn+'", depth:"'+depth+'", org:"'+orgNode.id()+'", local: '+local+'});';
734 var bHref = 'javascript:rdetailShowCNBrowse("' + cn + '", '+orgNode.id()+', "'+depth+'");';
736 unHideMe( $n(row, 'details') )
737 $n(row, 'details').setAttribute('href', dHref);
738 unHideMe( $n(row, 'browse') )
739 $n(row, 'browse').setAttribute('href', bHref);
742 unHideMe($n(row, 'hold_div'));
743 $n(row, 'hold').onclick = function() {
744 var req = new Request(FETCH_VOLUME_BY_INFO, cn, record.doc_id(), orgNode.id());
747 var vol = r.getResultObject();
748 holdsDrawEditor({type: 'V', volumeObject : vol});
756 // sets the path to org as 'active' and displays the path if it's local
757 function rdetailSetPath(org, local) {
758 if( findOrgDepth(org) == 0 ) return;
759 var row = $("cp_info_" + org.id());
760 row.setAttribute("hasinfo", "1");
762 rdetailSetPath(findOrgUnit(org.parent_ou()), local);
765 //Append all the statuses for a given summary to the
767 function rdetailApplyStatuses( row, template, statuses ) {
768 for( var j in _statusPositions ) {
769 var stat = _statusPositions[j];
770 var val = statuses[stat.id()];
771 var nn = template.cloneNode(true);
772 if(val) nn.appendChild(text(val));
773 else nn.appendChild(text(0));
778 //Add one td (creating a new column) to the copy summary
779 //table for each opac_visible copy status
780 function rdetailBuildStatusColumns() {
782 rdetailGrabCopyStatuses();
783 var parent = statusRow;
784 var template = parent.removeChild(G.ui.rdetail.cp_status);
787 for( i = 0; i < cp_statuses.length; i++ ) {
789 var c = cp_statuses[i];
790 if( c && isTrue(c.opac_visible()) ) {
792 _statusPositions[i] = c;
793 var node = template.cloneNode(true);
794 var data = findNodeByName( node, config.names.rdetail.cp_status);
796 data.appendChild(text(name));
797 parent.appendChild(node);
802 for(x in _statusPositions) numStatuses++;
805 function rdetailGrabCopyStatuses() {
806 if(cp_statuses) return cp_statuses;
807 var req = new Request(FETCH_COPY_STATUSES);
809 cp_statuses = req.result();
810 cp_statuses = cp_statuses.sort(_rdetailSortStatuses);
813 function _rdetailSortStatuses(a, b) {
814 return parseInt(a.id()) - parseInt(b.id());
818 * XXX Need to adopt a more typical approach to showing loading status
820 function rdetailCheckForGBPreview() {
822 if (!googleBookPreview) return;
823 var GBPp = document.createElement('p');
824 GBPp.appendChild( document.createTextNode('Loading... ' ) );
826 $('rdetail_preview_div').appendChild(GBPp);
827 searchForGBPreview( cleanISBN(record.isbn()) );
833 * @param {DOM object} query The form element containing the
834 * input parameters "isbns"
836 function searchForGBPreview( isbn ) {
838 // Delete any previous Google Booksearch JSON queries.
839 var GBPJsonScript = document.getElementById("GBPJsonScript");
841 GBPJsonScript.parentNode.removeChild(GBPJsonScript);
844 // Add a script element with the src as the user's Google Booksearch query.
845 // JSON output is specified by including the alt=json-in-script argument
846 // and the callback function is also specified as a URI argument.
847 var GBPScriptElement = document.createElement("script");
849 GBPScriptElement.setAttribute("id", "GBPJsonScript");
850 GBPScriptElement.setAttribute("src",
851 "http://books.google.com/books?bibkeys=" +
852 isbn + "&jscmd=viewapi&callback=GBPreviewCallback");
853 GBPScriptElement.setAttribute("type", "text/javascript");
855 // make the request to Google booksearch
856 document.documentElement.firstChild.appendChild(GBPScriptElement);
860 * This function is the call-back function for the JSON scripts which
861 * executes a Google book search response.
863 * XXX I18N of text needed
865 * @param {JSON} booksInfo is the JSON object pulled from the Google books service.
867 function GBPreviewCallback(GBPBookInfo) {
868 // Clear any old data to prepare to display the Loading... message.
869 var GBPreviewDiv = document.getElementById("rdetail_preview_div");
872 for ( i in GBPBookInfo ) {
873 GBPBook = GBPBookInfo[i];
880 if ( GBPBook.preview != "noview" ) {
881 if ( GBPBook.preview == 'full' ) {
882 setText( $('rdetail_preview_link'), 'Full Text' );
883 $('rdetail_preview_link_a').title = 'See the full text of this book.';
886 // Add a button below the book cover image to load the preview.
887 GBPBadge = document.createElement( 'img' );
888 GBPBadge.src = 'http://books.google.com/intl/en/googlebooks/images/gbs_preview_button1.gif';
889 GBPBadge.title = 'Show a preview of this book from Google Book Search';
890 GBPBadge.style.border = 0;
891 GBPBadgelink = document.createElement( 'a' );
892 GBPBadgelink.href = 'javascript:rdetailShowExtra("preview");';
893 GBPBadgelink.appendChild( GBPBadge );
894 $('rdetail_image_cell').appendChild( GBPBadgelink );
896 unHideMe( $('rdetail_preview_link' ) );
897 $('rdetail_preview_div').style.height = 600;
902 * This is called when the user clicks on the 'Preview' link. We assume
903 * a preview is available from Google if this link was made visible.
905 * XXX I18N of Google Book Preview language attribute needed
907 function rdetailDisplayGBPreview() {
908 GBPreviewPane = $('rdetail_preview_div');
909 if ( GBPreviewPane.getAttribute('loaded') == null ||
910 GBPreviewPane.getAttribute('loaded') == "false" ) {
911 google.load("books", "0", {"callback" : rdetailGBPViewerLoadCallback, "language": "en"} );
912 GBPreviewPane.setAttribute('loaded', 'true');
916 function rdetailGBPViewerLoadCallback() {
917 var GBPViewer = new google.books.DefaultViewer(document.getElementById('rdetail_preview_div'));
918 GBPViewer.load('ISBN:' + cleanISBN(record.isbn()) );