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