]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/opac/skin/default/js/rdetail.js
Now that we're guaranteeing each URL attribute will be defined,
[Evergreen.git] / Open-ILS / web / opac / skin / default / js / rdetail.js
1 /* */
2
3
4 detachAllEvt('common', 'run');
5 attachEvt("common", "run", rdetailDraw);
6 attachEvt("rdetail", "recordDrawn", rdetailBuildStatusColumns);
7 attachEvt("rdetail", "recordDrawn", rdetailBuildInfoRows);
8 attachEvt("rdetail", "recordDrawn", rdetailGetPageIds);
9
10 var record = null;
11 var cp_statuses = null;
12 var recordsCache = [];
13
14 var copyRowParent = null;
15 var copyRow = null;
16 var statusRow = null;
17 var numStatuses = null;
18 var defaultCN;
19 var callnumberCache = {};
20 var rdetailLocalOnly = true;
21 var globalCNCache       = {};
22 var localTOC;
23 var cachedRecords;
24
25 var rdetailShowLocal = true;
26
27
28
29 var nextContainerIndex;
30
31 function rdetailReload() {
32         var args = {};
33         args[PARAM_LOCATION] = getNewSearchLocation();
34         args[PARAM_DEPTH] = depthSelGetDepth();
35         goTo(buildOPACLink(args));
36 }
37
38 var nextRecord;
39 var prevRecord;
40
41 var rdetailPrev = null;
42 var rdetailNext = null;
43 var rdetailStart = null;
44 var rdetailEnd = null;
45
46
47
48 /* looks to see if we have a next and/or previous record in the
49 record cache, if so, set up the nav links */
50 function rdetailSetPaging(ids) {
51
52         cachedRecords = {};
53         cachedRecords.ids = ids;
54
55         for( var i = 0; i < cachedRecords.ids.length; i++ ) {
56                 var rec = cachedRecords.ids[i];
57                 if( rec == getRid() ) {
58                         if( i > 0 ) prevRecord = cachedRecords.ids[i-1];
59                         if( i < cachedRecords.ids.length - 1 )
60                                 nextRecord = cachedRecords.ids[i+1];
61                         break;
62                 }
63         }
64
65         $('np_offset').appendChild(text(i + 1));
66         $('np_count').appendChild(text(getHitCount()));
67
68         if(prevRecord) {
69                 unHideMe($('np_table'));
70                 unHideMe($('np_prev'));
71                 unHideMe($('np_start'));
72                 rdetailPrev = function() { _rdetailNav(prevRecord); };
73                 rdetailStart = function() { _rdetailNav(cachedRecords.ids[0]); };
74         }
75
76         if(nextRecord) {
77                 unHideMe($('np_table'));
78                 unHideMe($('np_next'));
79                 unHideMe($('np_end'));
80                 rdetailNext = function() { _rdetailNav(nextRecord); };
81                 rdetailEnd = function() { _rdetailNav(cachedRecords.ids[cachedRecords.ids.length-1]); };
82         }
83
84         runEvt('rdetail', 'nextPrevDrawn', i, cachedRecords.ids.length);
85 }
86
87
88 function _rdetailNav(id, offset) {
89         var args = {};
90         args[PARAM_RID] = id;
91         goTo(buildOPACLink(args));
92 }
93
94 function rdetailDraw() {
95
96         detachAllEvt('common','depthChanged');
97         detachAllEvt('common','locationUpdated');
98         attachEvt('common','depthChanged', rdetailReload);
99         attachEvt('common','locationUpdated', rdetailReload);
100         attachEvt('common','holdUpdated', rdetailReload);
101         attachEvt('common','holdUpdateCanceled', rdetailReload);
102
103         copyRowParent = G.ui.rdetail.cp_info_row.parentNode;
104         copyRow = copyRowParent.removeChild(G.ui.rdetail.cp_info_row);
105         statusRow = G.ui.rdetail.cp_status.parentNode;
106         statusRow.id = '__rdsrow';
107
108         G.ui.rdetail.cp_info_local.onclick = rdetailShowLocalCopies;
109         G.ui.rdetail.cp_info_all.onclick = rdetailShowAllCopies;
110
111         if(getLocation() == globalOrgTree.id())
112                 hideMe(G.ui.rdetail.cp_info_all);
113
114         var req = new Request(FETCH_RMODS, getRid());
115         req.callback(_rdetailDraw);
116         req.send();
117
118         detachAllEvt("result", "idsReceived");
119         G.evt.result.hitCountReceived = [];
120         G.evt.result.recordReceived = [];
121         G.evt.result.copyCountsReceived = [];
122         G.evt.result.allRecordsReceived = [];
123 }
124
125 function rdetailGetPageIds() {
126         attachEvt("result", "idsReceived", rdetailSetPaging );
127         resultFetchAllRecords = true;
128         rresultCollectIds(true);
129 }
130
131
132 function buildunAPISpan (span, type, id) {
133         var cgi = new CGI();
134         var d = new Date();
135
136         addCSSClass(span,'unapi-id');
137
138         span.setAttribute(
139                 'title', 'tag:' + cgi.server_name + ',' +
140                 d.getFullYear() + ':' + type + '/' + id
141         );
142 }
143
144 function rdetailViewMarc(r,id) {
145         hideMe($('rdetail_extras_loading'));
146         $('rdetail_view_marc_box').innerHTML = r.getResultObject();
147
148         var div = elem('div', { "class" : 'hide_me' });
149         var span = div.appendChild( elem('abbr') );
150
151         buildunAPISpan( span, 'biblio-record_entry', record.doc_id() );
152
153         $('rdetail_view_marc_box').insertBefore(span, $('rdetail_view_marc_box').firstChild);
154 }
155
156
157 function rdetailShowLocalCopies() {
158         rdetailShowLocal = true;
159         rdetailBuildInfoRows();
160         hideMe(G.ui.rdetail.cp_info_local);
161         unHideMe(G.ui.rdetail.cp_info_all);
162         hideMe(G.ui.rdetail.cp_info_none); 
163 }
164
165 function rdetailShowAllCopies() {
166
167         rdetailShowLocal = false;
168         rdetailBuildInfoRows();
169         hideMe(G.ui.rdetail.cp_info_all);
170         unHideMe(G.ui.rdetail.cp_info_local);
171         hideMe(G.ui.rdetail.cp_info_none); 
172 }
173
174
175 function _rdetailDraw(r) {
176         record = r.getResultObject();
177
178         runEvt('rdetail', 'recordRetrieved', record.doc_id());
179
180         G.ui.rdetail.title.appendChild(text(record.title()));
181         buildSearchLink(STYPE_AUTHOR, record.author(), G.ui.rdetail.author);
182         G.ui.rdetail.isbn.appendChild(text(cleanISBN(record.isbn())));
183         G.ui.rdetail.edition.appendChild(text(record.edition()));
184         G.ui.rdetail.pubdate.appendChild(text(record.pubdate()));
185         G.ui.rdetail.publisher.appendChild(text(record.publisher()));
186         $('rdetail_physical_desc').appendChild(text(record.physical_description()));
187     r = record.types_of_resource();
188     if(r) {
189         G.ui.rdetail.tor.appendChild(text(r[0]));
190             setResourcePic( G.ui.rdetail.tor_pic, r[0]);
191     }
192         G.ui.rdetail.abstr.appendChild(text(record.synopsis()));
193
194     try{
195         if(record.isbn()) {
196             if(ENABLE_ADDED_CONTENT_ATTRIB_LINKS) {
197                 unHideMe($('rdetail.jacket_attrib_div'));
198                 var href = $('rdetail.jacket_attrib_link').getAttribute('href') +cleanISBN(record.isbn());
199                 $('rdetail.jacket_attrib_link').setAttribute('href', href);
200             }
201         } else {
202             hideMe($("rdetail.jacket_attrib_div"));
203             hideMe($("rdetail_img_link"));
204         }
205     } catch(E) {}
206
207
208         // see if the record has any external links 
209         var links = record.online_loc();
210         for( var i = 0; links && links.length > 0 && i < links.length; i = i + 3 ) {
211                 var href = links[i];
212                 // avoid matching "HTTP: The Complete Reference"
213                 if( href.match(/https?:\/|ftps?:\/|mailto:/i) ) {
214                         unHideMe($('rdetail_online_row'));
215                         // MODS can contain a display label (used for the text of the link)
216                         // as well as a note about the URL; many legacy systems conflate the
217                         // two and generate MARC records that expect the note to be used as
218                         // the text of the link, with no display label; here's the canonical
219                         // format:
220                         //
221                         // 856 40 $uhttp://localhost$yDisplay label$zPublic note
222                         //
223                         // Note that the MARC21slim2MODS XSL concatenates $3 and $y together
224                         // (as $y was defined later in MARC21's life as the display label)
225                         var displayLabel = '' + links[i+1];
226                         var note = '' + links[i+2];
227                         if(!displayLabel || displayLabel.match(/https?:\/|ftps?:\/|mailto:/i)) {
228                                 if(!note || note.match(/https?:\/|ftps?:\/|mailto:/i)) {
229                                         displayLabel = href;
230                                 } else {
231                                         displayLabel = note;
232                                 }
233                         }
234                         $('rdetail_online').appendChild(elem('a', {href:href,'class':'classic_link'}, displayLabel));
235                         if (!note && note != displayLabel) {
236                                 $('rdetail_online').appendChild(elem('span', {'class':'url_note'}, ' - ' + note));
237                         }
238                         $('rdetail_online').appendChild(elem('br'));
239                 }
240         }
241
242
243         $('rdetail_place_hold').setAttribute(
244                 'href','javascript:holdsDrawEditor({record:"'+record.doc_id()+'",type:"T"});');
245
246         $('rdetail_img_link').setAttribute('href', buildISBNSrc(cleanISBN(record.isbn()), 'large'));
247         G.ui.rdetail.image.setAttribute("src", buildISBNSrc(cleanISBN(record.isbn())));
248         runEvt("rdetail", "recordDrawn");
249         recordsCache.push(record);
250
251         rdetailSetExtrasSelector();
252
253         var breq = new Request(FETCH_BRE, [getRid()]);
254         breq.callback( rdetailCheckDeleted );
255         breq.send();
256
257         resultBuildCaches( [ record ] );
258         resultDrawSubjects();
259         resultDrawSeries();
260
261         // grab added content 
262         acCollectData(cleanISBN(record.isbn()), rdetailhandleAC);
263 }
264
265
266
267 function rdetailCheckDeleted(r) {
268         var br = r.getResultObject()[0];
269         if( isTrue(br.deleted()) ) {
270                 hideMe($('rdetail_place_hold'));
271                 $('rdetail_more_actions_selector').disabled = true;
272                 unHideMe($('rdetail_deleted_exp'));
273         }
274 }
275
276 function rdetailSetExtrasSelector() {
277         if(!grabUser()) return;
278         unHideMe($('rdetail_more_actions'));
279
280         var req = new Request( 
281                 FETCH_CONTAINERS, G.user.session, G.user.id(), 'biblio', 'bookbag' );
282         req.callback(rdetailAddBookbags);
283         req.send();
284 }
285
286 function rdetailAddBookbags(r) {
287
288         var containers = r.getResultObject();
289         var selector = $('rdetail_more_actions_selector');
290         var found = false;
291         var index = 3;
292         doSelectorActions(selector);
293
294         for( var i = 0; i != containers.length; i++ ) {
295                 found = true;
296                 var container = containers[i];
297                 insertSelectorVal( selector, index++, container.name(), 
298                         "container_" + container.id(), rdetailAddToBookbag,  1 );
299         }
300
301         nextContainerIndex = index;
302 }
303
304 var _actions = {};
305 function rdetailNewBookbag() {
306         var name = prompt($('rdetail_bb_new').innerHTML,"");
307         if(!name) return;
308
309         var id;
310         if( id = containerCreate( name ) ) {
311                 alert($('rdetail_bb_success').innerHTML);
312                 var selector = $('rdetail_more_actions_selector');
313                 insertSelectorVal( selector, nextContainerIndex++, name, 
314                         "container_" + id, rdetailAddToBookbag, 1 );
315                 setSelector( selector, 'start' );
316         }
317 }
318
319
320 function rdetailAddToBookbag() {
321         var selector = $('rdetail_more_actions_selector');
322         var id = selector.options[selector.selectedIndex].value;
323         setSelector( selector, 'start' );
324
325         if( containerCreateItem( id.substring(10), record.doc_id() )) {
326                 alert($('rdetail_bb_item_success').innerHTML);
327         }
328 }
329
330
331 var rdetailMarcFetched = false;
332 function rdetailShowExtra(type, args) {
333
334         hideMe($('rdetail_copy_info_div'));
335         hideMe($('rdetail_reviews_div'));
336         hideMe($('rdetail_toc_div'));
337         hideMe($('rdetail_anotes_div'));
338         hideMe($('rdetail_excerpt_div'));
339         hideMe($('rdetail_marc_div'));
340         hideMe($('cn_browse'));
341         hideMe($('rdetail_cn_browse_div'));
342         hideMe($('rdetail_notes_div'));
343
344         removeCSSClass($('rdetail_copy_info_link'), 'rdetail_extras_selected');
345         removeCSSClass($('rdetail_viewcn_link'), 'rdetail_extras_selected');
346         removeCSSClass($('rdetail_reviews_link'), 'rdetail_extras_selected');
347         removeCSSClass($('rdetail_toc_link'), 'rdetail_extras_selected');
348         removeCSSClass($('rdetail_excerpt_link'), 'rdetail_extras_selected');
349         removeCSSClass($('rdetail_anotes_link'), 'rdetail_extras_selected');
350         removeCSSClass($('rdetail_annotation_link'), 'rdetail_extras_selected');
351         removeCSSClass($('rdetail_viewmarc_link'), 'rdetail_extras_selected');
352
353         switch(type) {
354
355                 case "copyinfo": 
356                         unHideMe($('rdetail_copy_info_div')); 
357                         addCSSClass($('rdetail_copy_info_link'), 'rdetail_extras_selected');
358                         break;
359
360                 case "reviews": 
361                         addCSSClass($('rdetail_reviews_link'), 'rdetail_extras_selected');
362                         unHideMe($('rdetail_reviews_div')); 
363                         break;
364
365
366                 case "excerpt": 
367                         addCSSClass($('rdetail_excerpt_link'), 'rdetail_extras_selected');
368                         unHideMe($('rdetail_excerpt_div'));
369                         break;
370
371                 case "anotes": 
372                         addCSSClass($('rdetail_anotes_link'), 'rdetail_extras_selected');
373                         unHideMe($('rdetail_anotes_div'));
374                         break;
375
376
377                 case "toc": 
378                         addCSSClass($('rdetail_toc_link'), 'rdetail_extras_selected');
379                         unHideMe($('rdetail_toc_div'));
380                         break;
381
382                 case "marc": 
383                         addCSSClass($('rdetail_viewmarc_link'), 'rdetail_extras_selected');
384                         unHideMe($('rdetail_marc_div')); 
385                         if(rdetailMarcFetched) return;
386                         unHideMe($('rdetail_extras_loading'));
387                         rdetailMarcFetched = true;
388                         var req = new Request( FETCH_MARC_HTML, record.doc_id() );
389                         req.callback(rdetailViewMarc); 
390                         req.send();
391                         break;
392
393                 case 'cn':
394                         addCSSClass($('rdetail_viewcn_link'), 'rdetail_extras_selected');
395                         unHideMe($('rdetail_cn_browse_div'));
396                         rdetailShowCNBrowse(defaultCN, getLocation(), null, true);
397                         break;
398
399         }
400 }
401
402 function rdetailVolumeDetails(args) {
403         var row = $(args.rowid);
404         var tbody = row.parentNode;
405         cpdBuild( tbody, row, record, args.cn, args.org, args.depth );
406         return;
407 }
408
409
410 function rdetailBuildCNList() {
411
412         var select = $('cn_browse_selector');
413         var index = 0;
414         var arr = [];
415         for( var cn in callnumberCache ) arr.push( cn );
416         arr.sort();
417
418         if( arr.length == 0 ) {
419                 hideMe($('rdetail_cn_browse_select_div'));
420                 return;
421         }
422
423         for( var i in arr ) {
424                 var cn = arr[i];
425                 var opt = new Option(cn);
426                 select.options[index++] = opt;
427         }
428         select.onchange = rdetailGatherCN;
429 }
430
431 function rdetailGatherCN() {
432         var cn = getSelectorVal($('cn_browse_selector'));
433         rdetailShowCNBrowse( cn, getLocation(), getDepth(), true );
434         setSelector( $('cn_browse_selector'), cn );
435 }
436
437
438 function rdetailShowCNBrowse( cn, loc, depth, fromOnclick ) {
439
440         if(!cn) {
441                 unHideMe($('cn_browse_none'));
442                 hideMe($('rdetail_cn_browse_select_div'));
443                 return;
444         }
445                 
446         unHideMe($('rdetail_cn_browse_select_div'));
447         rdetailBuildCNList();
448         setSelector( $('cn_browse_selector'), cn );
449         hideMe($('rdetail_copy_info_div'));
450         hideMe($('rdetail_reviews_div'));
451         hideMe($('rdetail_toc_div'));
452         hideMe($('rdetail_marc_div'));
453         unHideMe($('rdetail_cn_browse_div'));
454         unHideMe($('cn_browse'));
455         if( !rdetailLocalOnly && ! fromOnclick ) depth = findOrgDepth(globalOrgTree);
456         cnBrowseGo(cn, loc, depth);
457 }
458
459 function rdetailhandleAC(data) {
460
461         if( data.reviews.html ) {
462                 $('rdetail_review_container').innerHTML = data.reviews.html;
463                 unHideMe($('rdetail_reviews_link'));
464         }
465
466         if( data.toc.html ) {
467                 $('rdetail_toc_div').innerHTML = data.toc.html;
468                 unHideMe($('rdetail_toc_link'));
469         }
470
471         if( data.excerpt.html ) {
472                 $('rdetail_excerpt_div').innerHTML = data.excerpt.html;
473                 unHideMe($('rdetail_excerpt_link'));
474         }
475
476         if( data.anotes.html ) {
477                 $('rdetail_anotes_div').innerHTML = data.anotes.html;
478                 unHideMe($('rdetail_anotes_link'));
479         }
480 }
481
482 function rdetailShowReviews(r) {
483         hideMe($('rdetail_extras_loading'));
484         var res = r.getResultObject();
485         var par = $('rdetail_reviews_div');
486         var template = par.removeChild($('rdetail_review_template'));
487         if( res && res.length > 0 ) {
488                 unHideMe($('rdetail_reviews_link'));
489                 for( var i = 0; i != res.length; i++ ) {
490                         var rev = res[i];       
491                         if( rev.text && rev.info ) {
492                                 var node = template.cloneNode(true);
493                                 $n(node, 'review_header').appendChild(text(rev.info));
494                                 $n(node, 'review_text').appendChild(text(rev.text));
495                                 par.appendChild(node);
496                         }
497                 }
498         }
499 }
500
501
502 function rdetailShowTOC(r) {
503         hideMe($('rdetail_extras_loading'));
504         var resp = r.getResultObject();
505         if(resp) {
506                 unHideMe($('rdetail_toc_link'));
507                 $('rdetail_toc_div').innerHTML = resp;
508         }
509 }
510
511
512 function rdetailBuildInfoRows() {
513         var req;
514         if( rdetailShowLocal ) 
515                 req = new Request(FETCH_COPY_COUNTS_SUMMARY, record.doc_id(), getLocation(), getDepth())
516         else
517                 req = new Request(FETCH_COPY_COUNTS_SUMMARY, record.doc_id());
518         req.callback(_rdetailBuildInfoRows);
519         req.send();
520 }
521
522 function _rdetailRows(node) {
523
524         if( rdetailShowLocal && getLocation() != globalOrgTree.id() ) {
525
526                 var loc = findOrgUnit(getLocation());
527
528                 if( node ) {
529                         if( !orgIsMine(loc, node) ) return;
530
531                 } else {
532
533                         for( var i = 0; i < globalOrgTree.children().length; i++ ) {
534                                 var org = findOrgUnit(globalOrgTree.children()[i]);
535                                 if( orgIsMine(org, loc) ) {
536                                         node = org;
537                                         break;
538                                 }
539                         }
540                 } 
541         }
542
543     if(!node && findOrgType(globalOrgTree.ou_type()).can_have_vols())
544         node = globalOrgTree;
545
546
547     /* don't show hidden orgs */
548
549         if(node) {
550
551         if(!isXUL() && !isTrue(node.opac_visible())) return;
552
553                 var row = copyRow.cloneNode(true);
554                 row.id = "cp_info_" + node.id();
555
556                 var libtd = findNodeByName( row, config.names.rdetail.lib_cell );
557                 var cntd  = findNodeByName( row, config.names.rdetail.cn_cell );
558                 var cpctd = findNodeByName( row, config.names.rdetail.cp_count_cell );
559                 var actions = $n(row, 'rdetail_actions_cell');
560         
561                 var p = libtd.getElementsByTagName('a')[0];
562                 libtd.insertBefore(text(node.name()), p);
563                 libtd.setAttribute("style", "padding-left: " + ((findOrgDepth(node) - 1)  * 9) + "px;");
564         
565                 if(!findOrgType(node.ou_type()).can_have_vols()) {
566
567                         row.removeChild(cntd);
568                         row.removeChild(cpctd);
569                         row.removeChild(actions);
570                         row.setAttribute('novols', '1');
571
572                         libtd.setAttribute("colspan", numStatuses + 3 );
573                         libtd.colSpan = numStatuses + 3;
574                         addCSSClass(row, 'copy_info_region_row');
575                 } 
576         
577                 copyRowParent.appendChild(row);
578
579         } else { node = globalOrgTree; }
580
581         for( var c in node.children() ) 
582                 _rdetailRows(node.children()[c]);
583 }
584
585 function rdetailCNPrint(orgid, cn) {
586         var div = cpdBuildPrintWindow( record, orgid);
587         var template = div.removeChild($n(div, 'cnrow'));
588         var rowNode = $("cp_info_" + orgid);
589         cpdStylePopupWindow(div);
590         openWindow(div.innerHTML);
591 }
592
593 var localCNFound = false;
594 var ctr = 0;
595 function _rdetailBuildInfoRows(r) {
596
597         removeChildren(copyRowParent);
598
599         _rdetailRows();
600
601         var summary = r.getResultObject();
602         if(!summary) return;
603
604         var found = false;
605         for( var i = 0; i < summary.length; i++ ) {
606
607                 var arr = summary[i];
608                 globalCNCache[arr[1]] = 1;
609                 var thisOrg = findOrgUnit(arr[0]);
610                 var rowNode = $("cp_info_" + thisOrg.id());
611                 if(!rowNode) continue;
612
613                 if(rowNode.getAttribute("used")) {
614
615                         if( rowNode.nextSibling ) {
616                 sib = rowNode.nextSibling;
617                 o ='cp_info_'+thisOrg.id()+'_';
618                 /* push the new row on as the last row for this org unit */
619                 while( sib && sib.id.match(o) ) {
620                     sib = sib.nextSibling;
621                 }
622                 if(sib)
623                                     rowNode = copyRowParent.insertBefore(copyRow.cloneNode(true), sib);
624                 else
625                     rowNode = copyRowParent.appendChild(copyRow.cloneNode(true));
626             } else {
627                                 rowNode = copyRowParent.appendChild(copyRow.cloneNode(true));
628             }
629
630                         var n = findNodeByName( rowNode, config.names.rdetail.lib_cell );
631                         n.appendChild(text(thisOrg.name()));
632                         n.setAttribute("style", "padding-left: " + ((findOrgDepth(thisOrg) - 1)  * 9) + "px;");
633                         rowNode.id = "cp_info_" + thisOrg.id() + '_' + (++ctr); 
634
635                 } else {
636                         rowNode.setAttribute("used", "1");
637                 }
638
639                 var cpc_temp = rowNode.removeChild(
640                         findNodeByName(rowNode, config.names.rdetail.cp_count_cell));
641
642                 rdetailApplyStatuses(rowNode, cpc_temp, arr[2]);
643
644                 var isLocal = false;
645                 if( orgIsMine( findOrgUnit(getLocation()), thisOrg ) ) { 
646                         found = true; 
647                         isLocal = true; 
648                         if(!localCNFound) {
649                                 localCNFound = true;
650                                 defaultCN = arr[1];
651                         }
652                 }
653
654                 //if(isLocal) unHideMe(rowNode);
655                 unHideMe(rowNode);
656
657                 rdetailSetPath( thisOrg, isLocal );
658                 rdetailBuildBrowseInfo( rowNode, arr[1], isLocal, thisOrg );
659
660                 if( i == summary.length - 1 && !defaultCN) defaultCN = arr[1];
661         }
662
663         if(!found) unHideMe(G.ui.rdetail.cp_info_none);
664 }
665
666
667 function rdetailBuildBrowseInfo(row, cn, local, orgNode) {
668
669         if(local) {
670                 var cache = callnumberCache[cn];
671                 if( cache ) cache.count++;
672                 else callnumberCache[cn] = { count : 1 };
673         }
674
675         var depth = getDepth();
676         if( !local ) depth = findOrgDepth(globalOrgTree);
677
678         $n(row, 'rdetail_callnumber_cell').appendChild(text(cn));
679
680         _debug('setting action clicks for cn ' + cn);
681
682         var dHref = 'javascript:rdetailVolumeDetails('+
683                 '{rowid : "'+row.id+'", cn :"'+cn+'", depth:"'+depth+'", org:"'+orgNode.id()+'", local: '+local+'});';
684
685         var bHref = 'javascript:rdetailShowCNBrowse("' + cn + '", '+orgNode.id()+', "'+depth+'");'; 
686
687         $n(row, 'details').setAttribute('href', dHref);
688         $n(row, 'browse').setAttribute('href', bHref);
689
690         if(isXUL()) {
691                 unHideMe($n(row, 'hold_div'));
692                 $n(row, 'hold').onclick = function() {
693                         var req = new Request(FETCH_VOLUME_BY_INFO, cn, record.doc_id(), orgNode.id());
694                         req.callback(
695                                 function(r) {
696                                         var vol = r.getResultObject();
697                                         holdsDrawEditor({type: 'V', volumeObject : vol});
698                                 }
699                         );
700                         req.send();
701                 };
702         }
703 }
704
705
706 // sets the path to org as 'active' and displays the path if it's local 
707 function rdetailSetPath(org, local) {
708         if( findOrgDepth(org) == 0 ) return;
709         var row = $("cp_info_" + org.id());
710         row.setAttribute("hasinfo", "1");
711         unHideMe(row);
712         rdetailSetPath(findOrgUnit(org.parent_ou()), local);
713 }
714
715
716
717
718 //Append all the statuses for a give summary to the 
719 //copy summary table 
720 function rdetailApplyStatuses( row, template, statuses ) {
721         for( var j in _statusPositions ) {
722                 var stat = _statusPositions[j];
723                 var val = statuses[stat.id()];
724                 var nn = template.cloneNode(true);
725                 if(val) nn.appendChild(text(val));
726                 else nn.appendChild(text(0));
727                 row.appendChild(nn);    
728         }
729 }
730
731
732 var _statusPositions = {};
733
734 //Add one td (creating a new column) to the copy summary
735 //table for each opac_visible copy status
736
737 function rdetailBuildStatusColumns() {
738
739         rdetailGrabCopyStatuses();
740         var parent = statusRow;
741         var template = parent.removeChild(G.ui.rdetail.cp_status);
742
743         var i = 0;
744         for( i = 0; i < cp_statuses.length; i++ ) {
745
746                 var c = cp_statuses[i];
747                 if( c && isTrue(c.opac_visible()) ) {
748                         var name = c.name();
749                         _statusPositions[i] = c;
750                         var node = template.cloneNode(true);
751                         var data = findNodeByName( node, config.names.rdetail.cp_status);
752         
753                         data.appendChild(text(name));
754                         parent.appendChild(node);
755                 }
756         }       
757
758         numStatuses = 0;
759         for(x in _statusPositions) numStatuses++; 
760 }
761
762 function rdetailGrabCopyStatuses() {
763         if(cp_statuses) return cp_statuses;
764    var req = new Request(FETCH_COPY_STATUSES);
765    req.send(true);
766         cp_statuses = req.result();
767         cp_statuses = cp_statuses.sort(_rdetailSortStatuses);
768 }
769
770 function _rdetailSortStatuses(a, b) {
771         return parseInt(a.id()) - parseInt(b.id());
772 }
773