6 var mresultPreCache = 200;
\r
9 attachEvt("common", "unload", mresultUnload);
\r
10 attachEvt("common", "run", mresultDoSearch);
\r
11 attachEvt("result", "idsReceived", mresultSetRecords);
\r
12 attachEvt("result", "idsReceived", mresultCollectRecords);
\r
14 function mresultUnload() { removeChildren(table); table = null;}
\r
16 hideMe($('copyright_block'));
\r
18 function mresultDoSearch() {
\r
19 TFORM = null; /* clear the rresult tform var so it's not propogated */
\r
21 swapCanvas($('loading_alt'));
\r
22 table = G.ui.result.main_table;
\r
24 var holdTarget = new CGI().param('hold_target');
\r
25 if(holdTarget != null) {
\r
26 mresultHandlePlaceHold(holdTarget);
\r
30 while( table.parentNode.rows.length <= (getDisplayCount() + 1) )
\r
31 table.appendChild(G.ui.result.row_template.cloneNode(true));
\r
33 if( (getSearches() || getAdvTerm()) && !getTerm() ) {
\r
34 if(getAdvType() == ADVTYPE_MULTI ) mresultCollectAdvIds();
\r
37 _mresultCollectIds();
\r
43 function _mresultCollectIds() {
\r
44 resultCollectSearchIds(true, SEARCH_MRS_QUERY, mresultHandleMRIds );
\r
47 function mresultCollectAdvIds() {
\r
48 resultCollectSearchIds(false, SEARCH_MRS_QUERY, mresultHandleMRIds );
\r
52 function mresultHandleMRIds(r) {
\r
53 var res = r.getResultObject();
\r
54 resultCompiledSearch = res.compiled_search;
\r
55 cookieManager.write(COOKIE_SEARCH, js2JSON(res.compiled_search), -1);
\r
56 if(res.count != null) {
\r
57 if( getOffset() == 0 ) HITCOUNT = res.count;
\r
58 runEvt('result', 'hitCountReceived');
\r
60 runEvt('result', 'idsReceived', res.ids);
\r
65 function mresultSetRecords(idstruct) {
\r
66 if(!idstruct) return;
\r
67 var o = getOffset();
\r
68 for( var x = o; x < idstruct.length + o; x++ ) {
\r
69 if( idstruct[x-o] != null ) {
\r
70 var r = parseInt(idstruct[x - o][0]);
\r
71 var ra = parseFloat(idstruct[x - o][1]);
\r
72 var or = parseInt(idstruct[x - o][2]);
\r
73 if(!isNull(r) && !isNaN(r)) records[x] = r;
\r
74 if(!isNull(ra) && !isNaN(ra)) ranks[x] = ra;
\r
75 if(!isNull(or) && !isNaN(or)) onlyrecord[x] = or;
\r
79 TOPRANK = ranks[getOffset()];
\r
83 var recsReceivedCalled = false;
\r
84 function mresultCollectRecords() {
\r
85 if(getHitCount() > 0 ) runEvt("result", "preCollectRecords");
\r
87 for( var x = getOffset(); x!= getDisplayCount() + getOffset(); x++ ) {
\r
88 if(isNull(records[x])) break;
\r
89 if(isNaN(records[x])) continue;
\r
90 var req = new Request(FETCH_MRMODS, records[x]);
\r
92 req.request.userdata = i++;
\r
94 /* wait at most 10 seconds for the mods rec to come back */
\r
95 /* this needs more testing */
\r
96 req.request.timeout(10);
\r
97 req.request.abortCallback(
\r
100 if(resultPageIsDone() && !recsReceivedCalled) {
\r
101 recsReceivedCalled = true;
\r
102 runEvt('result', 'allRecordsReceived', recordsCache);
\r
103 unHideMe($('copyright_block'));
\r
108 req.callback(mresultHandleMods);
\r
113 function mresultHandleMods(r) {
\r
114 var rec = r.getResultObject();
\r
115 var pagePosition = r.userdata;
\r
116 runEvt('result', 'recordReceived', rec, pagePosition, true);
\r
117 if(rec) resultCollectCopyCounts(rec, pagePosition, FETCH_MR_COPY_COUNTS);
\r
118 if(resultPageIsDone()) {
\r
119 runEvt('result', 'allRecordsReceived', recordsCache);
\r
120 unHideMe($('copyright_block')); /* *** */
\r
124 function mresultHandlePlaceHold(target) {
\r
125 function reload() {
\r
126 location.href = location.href.replace(/&hold_target=\d+/, '');
\r
128 attachEvt("common", "holdUpdated", reload);
\r
129 attachEvt("common", "holdUpdateCanceled", reload);
\r
130 attachEvt("common", "loginCanceled", reload);
\r
131 holdsDrawEditor({record:target, type: 'M'});
\r