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 var holdTarget = new CGI().param('hold_target');
27 if(holdTarget != null) {
28 mresultHandlePlaceHold(holdTarget);
33 while( table.parentNode.rows.length <= (getDisplayCount() + 1) )
34 table.appendChild(G.ui.result.row_template.cloneNode(true));
36 if( (getSearches() || getAdvTerm()) && !getTerm() ) {
37 if(getAdvType() == ADVTYPE_MULTI ) mresultCollectAdvIds();
46 function _mresultCollectIds() {
47 resultCollectSearchIds(true, SEARCH_MRS_QUERY, mresultHandleMRIds );
50 function mresultCollectAdvIds() {
51 resultCollectSearchIds(false, SEARCH_MRS_QUERY, mresultHandleMRIds );
55 function mresultHandleMRIds(r) {
56 var res = r.getResultObject();
57 resultCompiledSearch = res.compiled_search;
58 cookieManager.write(COOKIE_SEARCH, js2JSON(res.compiled_search), -1);
59 if(res.count != null) {
60 if( getOffset() == 0 ) HITCOUNT = res.count;
61 runEvt('result', 'hitCountReceived');
63 runEvt('result', 'idsReceived', res.ids);
68 function mresultSetRecords(idstruct) {
71 for( var x = o; x < idstruct.length + o; x++ ) {
72 if( idstruct[x-o] != null ) {
73 var r = parseInt(idstruct[x - o][0]);
74 var ra = parseFloat(idstruct[x - o][1]);
75 var or = parseInt(idstruct[x - o][2]);
76 if(!isNull(r) && !isNaN(r)) records[x] = r;
77 if(!isNull(ra) && !isNaN(ra)) ranks[x] = ra;
78 if(!isNull(or) && !isNaN(or)) onlyrecord[x] = or;
82 TOPRANK = ranks[getOffset()];
87 var recsReceivedCalled = false;
88 function mresultCollectRecords() {
89 if(getHitCount() > 0 ) runEvt("result", "preCollectRecords");
91 for( var x = getOffset(); x!= getDisplayCount() + getOffset(); x++ ) {
92 if(isNull(records[x])) break;
93 if(isNaN(records[x])) continue;
94 var req = new Request(FETCH_MRMODS, records[x]);
96 req.request.userdata = i++;
98 /* wait at most 10 seconds for the mods rec to come back */
99 /* this needs more testing */
100 req.request.timeout(10);
101 req.request.abortCallback(
104 if(resultPageIsDone() && !recsReceivedCalled) {
105 recsReceivedCalled = true;
106 runEvt('result', 'allRecordsReceived', recordsCache);
107 unHideMe($('copyright_block'));
112 req.callback(mresultHandleMods);
117 function mresultHandleMods(r) {
118 var rec = r.getResultObject();
119 var pagePosition = r.userdata;
120 runEvt('result', 'recordReceived', rec, pagePosition, true);
121 if(rec) resultCollectCopyCounts(rec, pagePosition, FETCH_MR_COPY_COUNTS);
122 if(resultPageIsDone()) {
123 runEvt('result', 'allRecordsReceived', recordsCache);
124 unHideMe($('copyright_block')); /* *** */
128 function mresultHandlePlaceHold(target) {
130 location.href = location.href.replace(/&hold_target=\d+/, '');
132 attachEvt("common", "holdUpdated", reload);
133 attachEvt("common", "holdUpdateCanceled", reload);
134 attachEvt("common", "loginCanceled", reload);
135 holdsDrawEditor({record:target, type: 'M'});