6 var mresultPreCache = 200;
9 attachEvt("common", "unload", mresultUnload);
10 attachEvt("common", "run", mresultDoSearch);
11 attachEvt("result", "idsReceived", mresultSetRecords);
12 attachEvt("result", "idsReceived", mresultCollectRecords);
14 function mresultUnload() { removeChildren(table); table = null;}
16 hideMe($('copyright_block'));
18 function mresultDoSearch() {
21 TFORM = null; /* clear the rresult tform var so it's not propogated */
23 swapCanvas($('loading_alt'));
24 table = G.ui.result.main_table;
26 while( table.parentNode.rows.length <= (getDisplayCount() + 1) )
27 table.appendChild(G.ui.result.row_template.cloneNode(true));
29 if( (getSearches() || getAdvTerm()) && !getTerm() ) {
30 if(getAdvType() == ADVTYPE_MULTI ) mresultCollectAdvIds();
39 function _mresultCollectIds() {
40 resultCollectSearchIds(true, SEARCH_MRS_QUERY, mresultHandleMRIds );
43 function mresultCollectAdvIds() {
44 resultCollectSearchIds(false, SEARCH_MRS_QUERY, mresultHandleMRIds );
48 function mresultHandleMRIds(r) {
49 var res = r.getResultObject();
50 resultCompiledSearch = res.compiled_search;
51 cookieManager.write(COOKIE_SEARCH, js2JSON(res.compiled_search), -1);
52 if(res.count != null) {
53 if( getOffset() == 0 ) HITCOUNT = res.count;
54 runEvt('result', 'hitCountReceived');
56 runEvt('result', 'idsReceived', res.ids);
61 function mresultSetRecords(idstruct) {
64 for( var x = o; x < idstruct.length + o; x++ ) {
65 if( idstruct[x-o] != null ) {
66 var r = parseInt(idstruct[x - o][0]);
67 var ra = parseFloat(idstruct[x - o][1]);
68 var or = parseInt(idstruct[x - o][2]);
69 if(!isNull(r) && !isNaN(r)) records[x] = r;
70 if(!isNull(ra) && !isNaN(ra)) ranks[x] = ra;
71 if(!isNull(or) && !isNaN(or)) onlyrecord[x] = or;
75 TOPRANK = ranks[getOffset()];
80 function mresultCollectRecords() {
81 if(getHitCount() > 0 ) runEvt("result", "preCollectRecords");
83 for( var x = getOffset(); x!= getDisplayCount() + getOffset(); x++ ) {
84 if(isNull(records[x])) break;
85 if(isNaN(records[x])) continue;
86 var req = new Request(FETCH_MRMODS, records[x]);
88 req.request.userdata = i++;
90 /* wait at most 10 seconds for the mods rec to come back */
91 /* this needs more testing */
92 req.request.timeout(10);
93 req.request.abortCallback(
96 if(resultPageIsDone()) {
97 runEvt('result', 'allRecordsReceived', recordsCache);
98 unHideMe($('copyright_block'));
103 req.callback(mresultHandleMods);
108 function mresultHandleMods(r) {
109 var rec = r.getResultObject();
110 var pagePosition = r.userdata;
111 runEvt('result', 'recordReceived', rec, pagePosition, true);
112 if(rec) resultCollectCopyCounts(rec, pagePosition, FETCH_MR_COPY_COUNTS);
113 if(resultPageIsDone()) {
114 runEvt('result', 'allRecordsReceived', recordsCache);
115 unHideMe($('copyright_block')); /* *** */