6 var mresultPreCache = 200;
10 attachEvt("common", "unload", mresultUnload);
11 attachEvt("common", "run", mresultDoSearch);
12 attachEvt("result", "idsReceived", mresultSetRecords);
13 attachEvt("result", "idsReceived", mresultCollectRecords);
15 function mresultUnload() { removeChildren(table); table = null;}
17 hideMe($('copyright_block'));
19 function mresultDoSearch() {
22 TFORM = null; /* clear the rresult tform var so it's not propogated */
24 swapCanvas($('loading_alt'));
25 table = G.ui.result.main_table;
27 while( table.parentNode.rows.length <= (getDisplayCount() + 1) )
28 table.appendChild(G.ui.result.row_template.cloneNode(true));
30 if( (getSearches() || getAdvTerm()) && !getTerm() ) {
31 if(getAdvType() == ADVTYPE_MULTI ) mresultCollectAdvIds();
40 function _mresultCollectIds() {
41 resultCollectSearchIds(true, SEARCH_MRS_QUERY, mresultHandleMRIds );
44 function mresultCollectAdvIds() {
45 resultCollectSearchIds(false, SEARCH_MRS_QUERY, mresultHandleMRIds );
48 function mresultHandleMRIds(r) {
49 var res = r.getResultObject();
50 resultFacetKey = res.facet_key;
51 resultCompiledSearch = res.compiled_search;
52 dojo.require('dojo.cookie');
53 dojo.cookie(COOKIE_SEARCH, js2JSON(res.compiled_search));
54 if(res.count != null) {
55 if( getOffset() == 0 ) HITCOUNT = res.count;
56 runEvt('result', 'hitCountReceived');
58 runEvt('result', 'idsReceived', res.ids);
63 function mresultSetRecords(idstruct) {
66 for( var x = o; x < idstruct.length + o; x++ ) {
67 if( idstruct[x-o] != null ) {
68 var r = parseInt(idstruct[x - o][0]);
69 var ra = parseFloat(idstruct[x - o][1]);
70 var or = parseInt(idstruct[x - o][2]);
71 if(!isNull(r) && !isNaN(r)) records[x] = r;
72 if(!isNull(ra) && !isNaN(ra)) ranks[x] = ra;
73 if(!isNull(or) && !isNaN(or)) onlyrecord[x] = or;
77 TOPRANK = ranks[getOffset()];
82 function mresultCollectRecords() {
83 if(getHitCount() > 0 ) runEvt("result", "preCollectRecords");
85 for( var x = getOffset(); x!= getDisplayCount() + getOffset(); x++ ) {
86 if(isNull(records[x])) break;
87 if(isNaN(records[x])) continue;
88 var req = new Request(FETCH_MRMODS, records[x]);
90 req.request.userdata = i++;
92 /* wait at most 10 seconds for the mods rec to come back */
93 /* this needs more testing */
94 req.request.timeout(10);
95 req.request.abortCallback(
98 if(resultPageIsDone()) {
99 runEvt('result', 'allRecordsReceived', recordsCache);
100 unHideMe($('copyright_block'));
105 req.callback(mresultHandleMods);
110 function mresultHandleMods(r) {
111 var rec = r.getResultObject();
112 var pagePosition = r.userdata;
113 runEvt('result', 'recordReceived', rec, pagePosition, true);
114 if(rec) resultCollectCopyCounts(rec, pagePosition, FETCH_MR_COPY_COUNTS);
115 if(resultPageIsDone()) {
116 runEvt('result', 'allRecordsReceived', recordsCache);
117 unHideMe($('copyright_block')); /* *** */