]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/opac/skin/default/js/result_common.js
d8052a38850420aae031fb58beb6921808943a9a
[Evergreen.git] / Open-ILS / web / opac / skin / default / js / result_common.js
1
2 var recordsHandled = 0;
3 var recordsCache = [];
4 var lowHitCount = 4;
5
6 /* set up the event handlers */
7 G.evt.result.hitCountReceived.push(resultSetHitInfo);
8 G.evt.result.recordReceived.push(resultDisplayRecord, resultAddCopyCounts);
9 G.evt.result.copyCountsReceived.push(resultDisplayCopyCounts);
10 G.evt.result.allRecordsReceived.push(resultBuildCaches, resultDrawSubjects, resultDrawAuthors, resultDrawSeries);
11
12 attachEvt('result','lowHits',resultLowHits);
13 attachEvt('result','zeroHits',resultZeroHits);
14
15 attachEvt( "common", "locationUpdated", resultSBSubmit );
16 function resultSBSubmit(){searchBarSubmit();}
17
18 /* do this after we have ID's so the rank for mr pages will be correct */
19 attachEvt("result", "preCollectRecords", resultPaginate);
20
21 /* returns the last 'index' postion ocurring in this page */
22 function resultFinalPageIndex() {
23         if(getHitCount() < (getOffset() + getDisplayCount())) 
24                 return getHitCount() - 1;
25         return getOffset() + getDisplayCount() - 1;
26 }
27
28 /* set the search result info, number of hits, which results we're 
29         displaying, links to the next/prev pages, etc. */
30 function resultSetHitInfo() { 
31         if( findCurrentPage() == MRESULT ) {
32                 if(getHitCount() <= lowHitCount)
33                         runEvt('result', 'lowHits');
34                 if(getHitCount() == 0) {
35                         runEvt('result', 'zeroHits');
36                         return;
37                 }
38         }
39
40         var c;  
41         if( getDisplayCount() > (getHitCount() - getOffset()))  c = getHitCount();
42         else c = getDisplayCount() + getOffset();
43
44         var pages = getHitCount() / getDisplayCount();
45         if(pages % 1) pages = parseInt(pages) + 1;
46
47         G.ui.result.current_page.appendChild(text( (getOffset()/getDisplayCount()) + 1));
48         G.ui.result.num_pages.appendChild(text(pages + ")")); /* the ) is dumb */
49
50         G.ui.result.offset_start.appendChild(text(getOffset() + 1));
51         G.ui.result.offset_end.appendChild(text(c));
52         G.ui.result.result_count.appendChild(text(getHitCount()));
53         unHideMe(G.ui.result.info);
54 }
55
56 function resultLowHits() {
57         try{searchTimer.stop()}catch(e){}
58         showCanvas();
59         unHideMe($('result_low_hits'));
60         if(getHitCount() > 0)
61                 unHideMe($('result_low_hits_msg'));
62
63         var sreq = new Request(CHECK_SPELL, getTerm());
64         sreq.callback(resultSuggestSpelling);
65         sreq.send();
66
67         var words = getTerm().split(' ');
68         var word;
69         while( word = words.shift() ) {
70                 var areq = new Request(FETCH_CROSSREF, getStype(), getTerm() );
71                 areq.callback(resultLowHitXRef);
72                 areq.send();
73         }
74
75         if( !(getForm() == null || getForm() == 'all' || getForm == "") ) {
76                 var a = {};
77                 a[PARAM_FORM] = "all";
78                 $('low_hits_remove_format_link').setAttribute('href',buildOPACLink(a));
79                 unHideMe($('low_hits_remove_format'));
80         }
81 }
82
83 var lowHitsXRefLink;
84 var lowHitsXRefLinkParent;
85 function resultLowHitXRef(r) {
86         if(!lowHitsXRefLink){
87                 lowHitsXRefLinkParent = $('low_hits_xref_link').parentNode;
88                 lowHitsXRefLink = lowHitsXRefLinkParent.removeChild($('low_hits_xref_link'));
89         }
90         var res = r.getResultObject();
91         var arr = res.from;
92         arr.concat(res.also);
93         if(arr && arr.length > 0) {
94                 unHideMe($('low_hits_cross_ref'));
95                 var word;
96                 var c = 0;
97                 while( word = arr.shift() ) {
98                         if(c++ > 20) break;
99                         var a = {};
100                         a[PARAM_TERM] = word;
101                         var template = lowHitsXRefLink.cloneNode(true);
102                         template.setAttribute('href',buildOPACLink(a));
103                         template.appendChild(text(word));
104                         lowHitsXRefLinkParent.appendChild(template);
105                         lowHitsXRefLinkParent.appendChild(text(' '));
106                 }
107         }
108 }
109
110 function resultZeroHits() {
111         unHideMe($('result_zero_hits_msg'));
112         resultExpandSearch();
113         resultSuggestSearchClass();
114 }
115
116 function resultExpandSearch() {
117         var top = findOrgDepth(globalOrgTree);
118         if(getDepth() == top) return;
119         unHideMe($('low_hits_expand_range'));
120         var par = $('low_hits_expand_link').parentNode;
121         var template = par.removeChild($('low_hits_expand_link'));
122
123         var bottom = getDepth();
124         while( top < bottom ) {
125                 var a = {};
126                 a[PARAM_DEPTH] = top;
127                 var temp = template.cloneNode(true);
128                 temp.appendChild(text(findOrgTypeFromDepth(top).opac_label()))
129                 temp.setAttribute('href',buildOPACLink(a));
130                 par.appendChild(temp);
131                 top++;
132         }
133 }
134
135 function resultSuggestSearchClass() {
136         var stype = getStype();
137         if(stype == STYPE_KEYWORD) return;
138         var a = {}; var ref;
139         unHideMe($('low_hits_search_type'));
140         if(stype != STYPE_TITLE) {
141                 ref = $('low_hits_title_search');
142                 unHideMe(ref);
143                 a[PARAM_STYPE] = STYPE_TITLE;
144                 ref.setAttribute('href',buildOPACLink(a));
145         }
146         if(stype != STYPE_AUTHOR) {
147                 ref = $('low_hits_author_search');
148                 unHideMe(ref);
149                 a[PARAM_STYPE] = STYPE_AUTHOR;
150                 ref.setAttribute('href',buildOPACLink(a));
151         }
152         if(stype != STYPE_SUBJECT) {
153                 ref = $('low_hits_subject_search');
154                 unHideMe(ref);
155                 a[PARAM_STYPE] = STYPE_SUBJECT;
156                 ref.setAttribute('href',buildOPACLink(a));
157         }
158         if(stype != STYPE_KEYWORD) {
159                 ref = $('low_hits_keyword_search');
160                 unHideMe(ref);
161                 a[PARAM_STYPE] = STYPE_KEYWORD;
162                 ref.setAttribute('href',buildOPACLink(a));
163         }
164         if(stype != STYPE_SERIES) {
165                 ref = $('low_hits_series_search');
166                 unHideMe(ref);
167                 a[PARAM_STYPE] = STYPE_SERIES;
168                 ref.setAttribute('href',buildOPACLink(a));
169         }
170 }
171
172 function resultSuggestSpelling(r) {
173         var res = r.getResultObject();
174         if(res) {
175                 unHideMe($('did_you_mean'));
176                 var arg = {};
177                 arg[PARAM_TERM] = res;
178                 $('spell_check_link').setAttribute(
179                         'href', buildOPACLink(arg) );
180                 $('spell_check_link').appendChild(text(res));
181         }
182 }
183
184
185 function resultPaginate() {
186         var o = getOffset();
187
188         if( !((o + getDisplayCount()) >= getHitCount()) ) {
189
190                 var args = {};
191                 args[PARAM_OFFSET] = o + getDisplayCount();
192                 G.ui.result.next_link.setAttribute("href", buildOPACLink(args)); 
193                 addCSSClass(G.ui.result.next_link, config.css.result.nav_active);
194
195                 args[PARAM_OFFSET] = getHitCount() - (getHitCount() % getDisplayCount());
196                 G.ui.result.end_link.setAttribute("href", buildOPACLink(args)); 
197                 addCSSClass(G.ui.result.end_link, config.css.result.nav_active);
198         }
199
200         if( o > 0 ) {
201
202                 var args = {};
203                 args[PARAM_OFFSET] = o - getDisplayCount();
204                 G.ui.result.prev_link.setAttribute( "href", buildOPACLink(args)); 
205                 addCSSClass(G.ui.result.prev_link, config.css.result.nav_active);
206
207                 args[PARAM_OFFSET] = 0;
208                 G.ui.result.home_link.setAttribute( "href", buildOPACLink(args)); 
209                 addCSSClass(G.ui.result.home_link, config.css.result.nav_active);
210         }
211         if(getDisplayCount() < getHitCount())
212                 unHideMe($('start_end_links_span'));
213
214         showCanvas();
215         try{searchTimer.stop()}catch(e){}
216 }
217
218
219 /* display the record info in the record display table 'pos' is the 
220                 zero based position the record should have in the display table */
221 function resultDisplayRecord(rec, pos, is_mr) {
222
223         if(rec == null) rec = new mvr(); /* so the page won't die if there was an error */
224         recordsHandled++;
225         recordsCache.push(rec);
226
227         var r = table.rows[pos + 1];
228         
229         try {
230                 var rank = parseFloat(ranks[pos + getOffset()]);
231                 rank = ( rank / getTopRank() ) * 100;
232                 rank = parseInt(rank) + "%";
233                 var relspan = $n(r, "relevancy_span");
234                 relspan.appendChild(text(rank));
235                 unHideMe(relspan.parentNode);
236         } catch(e){ }
237
238         var pic = $n(r, config.names.result.item_jacket);
239         pic.setAttribute("src", buildISBNSrc(cleanISBN(rec.isbn())));
240
241         var title_link = $n(r, config.names.result.item_title);
242         var author_link = $n(r, config.names.result.item_author);
243
244         if( is_mr )  {
245                 var onlyrec = onlyrecord[ getOffset() + pos ];
246                 if(onlyrec) {
247                         var args = {};
248                         args.page = RDETAIL;
249                         args[PARAM_OFFSET] = 0;
250                         args[PARAM_RID] = onlyrec;
251                         args[PARAM_MRID] = rec.doc_id();
252                         pic.parentNode.setAttribute("href", buildOPACLink(args));
253                         title_link.setAttribute("href", buildOPACLink(args));
254                         title_link.appendChild(text(normalize(truncate(rec.title(), 65))));
255                         
256                 } else {
257                         buildTitleLink(rec, title_link); 
258                         var args = {};
259                         args.page = RRESULT;
260                         args[PARAM_OFFSET] = 0;
261                         args[PARAM_MRID] = rec.doc_id();
262                         pic.parentNode.setAttribute("href", buildOPACLink(args));
263                 }
264
265         } else {
266                 buildTitleDetailLink(rec, title_link); 
267                 var args = {};
268                 args.page = RDETAIL;
269                 args[PARAM_OFFSET] = 0;
270                 args[PARAM_RID] = rec.doc_id();
271                 pic.parentNode.setAttribute("href", buildOPACLink(args));
272
273                 unHideMe($n(r,'place_hold_span'));
274                 $n(r,'place_hold_link').setAttribute(
275                         'href','javascript:holdsDrawWindow("'+rec.doc_id()+'");');
276         }
277
278         buildSearchLink(STYPE_AUTHOR, rec.author(), author_link);
279
280         if(! is_mr ) {
281         
282                 if(!isNull(rec.edition()))      {
283                         unHideMe( $n(r, "result_table_extra_span"));
284                         $n(r, "result_table_edition_span").appendChild( text( rec.edition()) );
285                 }
286                 if(!isNull(rec.pubdate())) {
287                         unHideMe( $n(r, "result_table_extra_span"));
288                         unHideMe($n(r, "result_table_pub_span"));
289                         $n(r, "result_table_pub_span").appendChild( text( rec.pubdate() ));
290                 }
291                 if(!isNull(rec.publisher()) ) {
292                         unHideMe( $n(r, "result_table_extra_span"));
293                         unHideMe($n(r, "result_table_pub_span"));
294                         $n(r, "result_table_pub_span").appendChild( text( " " + rec.publisher() ));
295                 }
296         }
297
298         resultBuildFormatIcons( r, rec );
299
300         unHideMe(r);
301         
302         runEvt("result", "recordDrawn", rec.doc_id(), title_link);
303
304         if(resultPageIsDone())  {
305                 //showCanvas();
306                 /* hide the 'now loading...' message */
307                 /*
308                 hideMe(G.ui.common.loading);
309                 */
310                 runEvt('result', 'allRecordsReceived', recordsCache);
311         }
312 }
313
314 function _resultFindRec(id) {
315         for( var i = 0; i != recordsCache.length; i++ ) {
316                 var rec = recordsCache[i];
317                 if( rec && rec.doc_id() == id )
318                         return rec;
319         }
320         return null;
321 }
322
323 /*
324 var currentHoldRecord;
325 var holdsOrgSelectorBuilt = false;
326 function resultDrawHoldsWindow(recid) {
327
328         if(recid == null) {
329                 recid = currentHoldRecord;
330                 if(recid == null) return;
331         }
332         currentHoldRecord = recid;
333
334         detachEvt('common','locationUpdated', resultSBSubmit );
335         attachEvt( "common", "locationUpdated", resultSBSubmit );
336
337         if(!(G.user && G.user.session)) {
338
339                 detachEvt('common','locationUpdated', resultSBSubmit );
340                 attachEvt('common','loggedIn', resultDrawHoldsWindow)
341                 //alert(G.evt['common']['locationUpdated']);
342                 initLogin();
343                 //attachEvt( "common", "locationUpdated", resultSBSubmit );
344                 return;
345         }
346         swapCanvas($('holds_box'));
347
348         var rec = _resultFindRec(recid);
349
350         if(!holdsOrgSelectorBuilt) {
351                 resultBuildHoldsSelector(null, 0);
352                 holdsOrgSelectorBuilt = true;
353         }
354
355         removeChildren($('holds_title'));
356         removeChildren($('holds_author'));
357         removeChildren($('holds_format'));
358         removeChildren($('holds_email'));
359         removeChildren($('holds_email'));
360
361         $('holds_title').appendChild(text(rec.title()));
362         $('holds_author').appendChild(text(rec.author()));
363
364         for( var i in rec.types_of_resource() ) {
365                 var res = rec.types_of_resource()[i];
366                 var img = elem("img");
367                 setResourcePic(img, res);
368                 $('holds_format').appendChild(text(' '+res+' '));
369                 $('holds_format').appendChild(img);
370                 $('holds_format').appendChild(text(' '));
371         }
372
373         $('holds_phone').appendChild(text(G.user.day_phone()));
374         $('holds_email').appendChild(text(G.user.email()));
375         $('holds_cancel').onclick = showCanvas;
376         $('holds_submit').onclick = resultPlaceHold; 
377 }
378
379
380 function resultBuildHoldsSelector(node, depth) {
381
382         if(!node) {
383                 node = globalOrgTree;
384                 depth = 0;
385         }
386
387         var selector = $('holds_org_selector');
388         var index = selector.options.length;
389
390         if(IE) {
391                 var pre = elem("pre");
392                 for(var x=2; x <= findOrgType(node.ou_type()).depth(); x++) {
393                         pre.appendChild(text("    "));
394                 }
395                 pre.appendChild(text(node.name()));
396                 var select = new Option("", node.id());
397                 selector.options[index] = select;
398                 select.appendChild(pre);
399         
400         } else {
401                 var pad = (findOrgType(node.ou_type()).depth() - 1) * 12;
402                 if(pad < 0) pad = 0;
403                 var select = new Option(node.name(), node.id());
404                 select.setAttribute("style", "padding-left: "+pad+'px;');
405                 selector.options[index] = select;
406         }       
407
408         if( node.id() == getLocation() ) {
409                 selector.selectedIndex = index;
410                 selector.options[index].selected = true;        
411         }
412
413         for( var i in node.children() ) {
414                 var child = node.children()[i];
415                 if(child) {
416                         resultBuildHoldsSelector(child, depth+1);
417                 }
418         }
419 }
420
421 function resultPlaceHold() {
422         var hold = new ahr();
423         hold.pickup_lib( 1 ); 
424         hold.requestor(G.user.id());
425         hold.usr(G.user.id());
426         hold.hold_type('T');
427         hold.email_notify(G.user.email());
428         hold.phone_notify(G.user.day_phone());
429         hold.target(currentHoldRecord);
430         
431         var req = new Request( CREATE_HOLD, G.user.session, hold );
432         req.send(true);
433         var res = req.result();
434
435         if( res == '1' ) {
436                 alert('ok');
437         } else {
438                 alert('hold failed');
439         }
440 }
441 */
442
443
444
445 function resultBuildFormatIcons( row, rec ) {
446
447         var ress = rec.types_of_resource();
448
449         for( var i in ress ) {
450
451                 var res = ress[i];
452                 var link = $n(row, res + "_link");
453                 link.title = res;
454                 var img = link.getElementsByTagName("img")[0];
455                 removeCSSClass( img, config.css.dim );
456
457                 var f = getForm();
458                 if( f != "all" ) {
459                         if( f == modsFormatToMARC(res) ) 
460                                 addCSSClass( img, "dim2_border");
461                 }
462
463                 var args = {};
464                 args.page = RRESULT;
465                 args[PARAM_OFFSET] = 0;
466                 args[PARAM_MRID] = rec.doc_id();
467                 args[PARAM_FORM] = modsFormatToMARC(res);
468
469                 link.setAttribute("href", buildOPACLink(args));
470
471         }
472 }
473
474
475 function resultPageIsDone(pos) {
476         return (recordsHandled == getDisplayCount() 
477                 || recordsHandled + getOffset() == getHitCount());
478 }
479
480 var resultCCHeaderApplied = false;
481
482 /* -------------------------------------------------------------------- */
483 /* dynamically add the copy count rows based on the org type 'countsrow' 
484         is the row into which we will add TD's to hold the copy counts 
485         This code generates copy count cells with an id of
486         'copy_count_cell_<depth>_<pagePosition>'  */
487 function resultAddCopyCounts(rec, pagePosition) {
488
489         var r = table.rows[pagePosition + 1];
490         var countsrow = $n(r, config.names.result.counts_row );
491         var ccell = $n(countsrow, config.names.result.count_cell);
492
493         var nodes = orgNodeTrail(findOrgUnit(getLocation()));
494         var node = nodes[0];
495         var type = findOrgType(node.ou_type());
496         ccell.id = "copy_count_cell_" + type.depth() + "_" + pagePosition;
497         ccell.title = type.opac_label();
498         //addCSSClass(ccell, config.css.result.cc_cell_even);
499
500         var lastcell = ccell;
501         var lastheadcell = null;
502
503         var cchead = null;
504         var ccheadcell = null;
505         if(!resultCCHeaderApplied) {
506                 ccrow = $('result_thead_row');
507                 ccheadcell =  ccrow.removeChild($n(ccrow, "result_thead_ccell"));
508                 var t = ccheadcell.cloneNode(true);
509                 lastheadcell = t;
510                 t.appendChild(text(type.opac_label()));
511                 ccrow.appendChild(t);
512                 resultCCHeaderApplied = true;
513         }
514
515         if(nodes[1]) {
516
517                 var x = 1;
518                 var d = findOrgDepth(nodes[1]);
519                 var d2 = findOrgDepth(nodes[nodes.length -1]);
520
521                 for( var i = d; i <= d2 ; i++ ) {
522         
523                         ccell = ccell.cloneNode(true);
524
525                         //if((i % 2)) removeCSSClass(ccell, "copy_count_cell_even");
526                         //else addCSSClass(ccell, "copy_count_cell_even");
527
528                         var node = nodes[x++];
529                         var type = findOrgType(node.ou_type());
530         
531                         ccell.id = "copy_count_cell_" + type.depth() + "_" + pagePosition;
532                         ccell.title = type.opac_label();
533                         countsrow.insertBefore(ccell, lastcell);
534                         lastcell = ccell;
535
536                         if(ccheadcell) {
537                                 var t = ccheadcell.cloneNode(true);
538                                 t.appendChild(text(type.opac_label()));
539                                 ccrow.insertBefore(t, lastheadcell);
540                                 lastheadcell = t;
541                         }
542                 }
543         }
544
545         unHideMe($("search_info_table"));
546 }
547
548 /* collect copy counts for a record using method 'methodName' */
549 function resultCollectCopyCounts(rec, pagePosition, methodName) {
550         if(rec == null || rec.doc_id() == null) return;
551         var req = new Request(methodName, getLocation(), rec.doc_id(), getForm() );
552         req.request.userdata = [ rec, pagePosition ];
553         req.callback(resultHandleCopyCounts);
554         req.send();
555 }
556
557 function resultHandleCopyCounts(r) {
558         runEvt('result', 'copyCountsReceived', r.userdata[0], r.userdata[1], r.getResultObject()); 
559 }
560
561
562 /* display the collected copy counts */
563 function resultDisplayCopyCounts(rec, pagePosition, copy_counts) {
564         if(copy_counts == null || rec == null) return;
565         var i = 0;
566         while(copy_counts[i] != null) {
567                 var cell = $("copy_count_cell_" + i +"_" + pagePosition);
568                 /*
569                 var span = cell.getElementsByTagName("div")[0];
570                 */
571                 cell.appendChild(text(copy_counts[i].available + " / " + copy_counts[i].count));
572
573                 i++;
574         }
575 }
576
577
578 /* captures extraneous info from each record */
579
580 var subjectCache = {};
581 var authorCache = {};
582 var seriesCache = {};
583
584 function resultBuildCaches(records) {
585         for( var r in records ) {
586                 var rec = records[r];
587                 for( var s in rec.subject() ) 
588                         subjectCache[s] == null ? subjectCache[s] = 1 : subjectCache[s]++;
589                 authorCache[rec.author()] = 1;
590                 for( var s in rec.series() ) seriesCache[rec.series()[s]] = 1;
591         }
592 }
593
594 function resultSortSubjects(a, b) { return -(a.count - b.count); } /* sort in reverse */
595 function resultDrawSubjects() {
596
597         var subjs = [];
598         for( var s in subjectCache )
599                 subjs.push( { sub : s, count : subjectCache[s] } );
600         subjs.sort(resultSortSubjects);
601
602         var ss = [];
603         for( var s in subjs ) ss.push(subjs[s].sub);
604
605         resultDrawSidebarTrees( 
606                 STYPE_SUBJECT, 
607                 "subjectSidebarTree", ss, 
608                 $("subject_tree_sidebar"), 
609                 $("subject_sidebar_tree_div") );
610 }
611
612 function resultDrawAuthors() {
613         var auths = new Array();
614         for( var s in authorCache ) auths.push(s);
615
616         resultDrawSidebarTrees( 
617                 STYPE_AUTHOR, 
618                 "authorSidebarTree", auths.sort(), 
619                 $("author_tree_sidebar"), 
620                 $("author_sidebar_tree_div") );
621 }
622
623 function resultDrawSeries() {
624         var sers = new Array();
625         for( var s in seriesCache ) sers.push(s);
626         resultDrawSidebarTrees( 
627                 STYPE_SERIES, 
628                 "seriesSidebarTree", sers.sort(), 
629                 $("series_tree_sidebar"), 
630                 $("series_sidebar_tree_div") );
631 }
632
633 function resultDrawSidebarTrees( stype, treeName, items, wrapperNode, destNode ) {
634         var tree;
635         eval("tree = " + treeName);
636
637         var found = false;
638         var x = 0;
639         for( var i in items ) {
640
641                 if(isNull(items[i])) continue;
642                 if(x++ > 7) break;
643                 found = true;
644
645                 var item = normalize(truncate(items[i], 65));
646                 var trunc = 65;
647                 var args = {};
648                 var href = resultQuickLink( items[i], stype );
649                 tree.addNode( stype + "_" + items[i], treeName + 'Root', item, href );
650
651                 /*
652                 if(!IE)
653                         setTimeout('resultFireXRefReq("'+treeName+'","'+stype+'","'+item+'");',200);
654                         */
655                 if(!IE) resultFireXRefReq(treeName, stype, items[i]);
656         }
657
658         if(found) {
659                 unHideMe(wrapperNode);
660                 //tree.close(tree.rootid);
661         }
662 }
663
664 function resultFireXRefReq( treeName, stype, item ) {
665         var tree;
666         eval('tree=' + treeName);
667         var req = new Request(FETCH_CROSSREF, stype, item);
668         req.request._tree = tree;
669         req.request._item = item;
670         req.request._stype = stype;
671         req.callback(resultAppendCrossRef);
672         req.send();
673 }
674
675
676 function resultQuickLink( term, type ) {
677         var args = {};
678         args.page = MRESULT;
679         args[PARAM_OFFSET] = 0;
680         args[PARAM_TERM] = term;
681         args[PARAM_STYPE] = type;
682         return buildOPACLink(args);
683 }
684
685
686 function resultAppendCrossRef(r) {
687         var tree                = r._tree
688         var item                = r._item
689         var stype       = r._stype;
690         var result      = r.getResultObject();
691         if(!result) return;
692         var froms       = result['from'];
693         var alsos       = result['also'];
694
695         var total = 0;
696
697         for( var i = 0; (total++ < 5 && i < froms.length); i++ ) {
698                 var string = normalize(truncate(froms[i], 45));
699                 if($(stype + '_' + froms[i])) continue;
700                 tree.addNode(stype + '_' + froms[i], 
701                         stype + '_' + item, string, resultQuickLink(froms[i],stype));
702         }
703         for( var i = 0; (total++ < 10 && i < alsos.length); i++ ) {
704                 var string = normalize(truncate(alsos[i], 45));
705                 if($(stype + '_' + alsos[i])) continue;
706                 tree.addNode(stype + '_' + alsos[i], 
707                         stype + '_' + item, string, resultQuickLink(alsos[i],stype));
708         }
709 }
710
711
712
713
714