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 = result.facet_key;
51 resultCompiledSearch = res.compiled_search;
52 cookieManager.write(COOKIE_SEARCH, js2JSON(res.compiled_search), -1);
53 if(res.count != null) {
54 if( getOffset() == 0 ) HITCOUNT = res.count;
55 runEvt('result', 'hitCountReceived');
57 runEvt('result', 'idsReceived', res.ids);
62 function mresultSetRecords(idstruct) {
65 for( var x = o; x < idstruct.length + o; x++ ) {
66 if( idstruct[x-o] != null ) {
67 var r = parseInt(idstruct[x - o][0]);
68 var ra = parseFloat(idstruct[x - o][1]);
69 var or = parseInt(idstruct[x - o][2]);
70 if(!isNull(r) && !isNaN(r)) records[x] = r;
71 if(!isNull(ra) && !isNaN(ra)) ranks[x] = ra;
72 if(!isNull(or) && !isNaN(or)) onlyrecord[x] = or;
76 TOPRANK = ranks[getOffset()];
81 function mresultCollectRecords() {
82 if(getHitCount() > 0 ) runEvt("result", "preCollectRecords");
84 for( var x = getOffset(); x!= getDisplayCount() + getOffset(); x++ ) {
85 if(isNull(records[x])) break;
86 if(isNaN(records[x])) continue;
87 var req = new Request(FETCH_MRMODS, records[x]);
89 req.request.userdata = i++;
91 /* wait at most 10 seconds for the mods rec to come back */
92 /* this needs more testing */
93 req.request.timeout(10);
94 req.request.abortCallback(
97 if(resultPageIsDone()) {
98 runEvt('result', 'allRecordsReceived', recordsCache);
99 unHideMe($('copyright_block'));
104 req.callback(mresultHandleMods);
109 function mresultHandleMods(r) {
110 var rec = r.getResultObject();
111 var pagePosition = r.userdata;
112 runEvt('result', 'recordReceived', rec, pagePosition, true);
113 if(rec) resultCollectCopyCounts(rec, pagePosition, FETCH_MR_COPY_COUNTS);
114 if(resultPageIsDone()) {
115 runEvt('result', 'allRecordsReceived', recordsCache);
116 unHideMe($('copyright_block')); /* *** */