--- /dev/null
+//var records = {};\r
+var records = [];\r
+var ranks = [];\r
+var onlyrecord = {};\r
+var table;\r
+var mresultPreCache = 200;\r
+var searchTimer;\r
+\r
+attachEvt("common", "unload", mresultUnload);\r
+attachEvt("common", "run", mresultDoSearch);\r
+attachEvt("result", "idsReceived", mresultSetRecords); \r
+attachEvt("result", "idsReceived", mresultCollectRecords); \r
+\r
+function mresultUnload() { removeChildren(table); table = null;}\r
+\r
+hideMe($('copyright_block')); \r
+\r
+function mresultDoSearch() {\r
+ TFORM = null; /* clear the rresult tform var so it's not propogated */\r
+\r
+ swapCanvas($('loading_alt'));\r
+ table = G.ui.result.main_table;\r
+\r
+ var holdTarget = new CGI().param('hold_target');\r
+ if(holdTarget != null) {\r
+ mresultHandlePlaceHold(holdTarget);\r
+ return;\r
+ }\r
+\r
+ while( table.parentNode.rows.length <= (getDisplayCount() + 1) ) \r
+ table.appendChild(G.ui.result.row_template.cloneNode(true));\r
+\r
+ if( (getSearches() || getAdvTerm()) && !getTerm() ) {\r
+ if(getAdvType() == ADVTYPE_MULTI ) mresultCollectAdvIds();\r
+\r
+ } else {\r
+ _mresultCollectIds(); \r
+ ADVTERM = "";\r
+ ADVTYPE = "";\r
+ }\r
+}\r
+\r
+function _mresultCollectIds() { \r
+ resultCollectSearchIds(true, SEARCH_MRS_QUERY, mresultHandleMRIds ); \r
+}\r
+\r
+function mresultCollectAdvIds() { \r
+ resultCollectSearchIds(false, SEARCH_MRS_QUERY, mresultHandleMRIds ); \r
+}\r
+\r
+\r
+function mresultHandleMRIds(r) {\r
+ var res = r.getResultObject();\r
+ resultCompiledSearch = res.compiled_search;\r
+ cookieManager.write(COOKIE_SEARCH, js2JSON(res.compiled_search), -1);\r
+ if(res.count != null) {\r
+ if( getOffset() == 0 ) HITCOUNT = res.count;\r
+ runEvt('result', 'hitCountReceived');\r
+ } \r
+ runEvt('result', 'idsReceived', res.ids);\r
+}\r
+\r
+\r
+\r
+function mresultSetRecords(idstruct) {\r
+ if(!idstruct) return;\r
+ var o = getOffset();\r
+ for( var x = o; x < idstruct.length + o; x++ ) {\r
+ if( idstruct[x-o] != null ) {\r
+ var r = parseInt(idstruct[x - o][0]);\r
+ var ra = parseFloat(idstruct[x - o][1]);\r
+ var or = parseInt(idstruct[x - o][2]);\r
+ if(!isNull(r) && !isNaN(r)) records[x] = r;\r
+ if(!isNull(ra) && !isNaN(ra)) ranks[x] = ra;\r
+ if(!isNull(or) && !isNaN(or)) onlyrecord[x] = or;\r
+ }\r
+ }\r
+\r
+ TOPRANK = ranks[getOffset()];\r
+}\r
+\r
+\r
+var recsReceivedCalled = false;\r
+function mresultCollectRecords() {\r
+ if(getHitCount() > 0 ) runEvt("result", "preCollectRecords");\r
+ var i = 0;\r
+ for( var x = getOffset(); x!= getDisplayCount() + getOffset(); x++ ) {\r
+ if(isNull(records[x])) break;\r
+ if(isNaN(records[x])) continue;\r
+ var req = new Request(FETCH_MRMODS, records[x]);\r
+\r
+ req.request.userdata = i++;\r
+\r
+ /* wait at most 10 seconds for the mods rec to come back */\r
+ /* this needs more testing */\r
+ req.request.timeout(10); \r
+ req.request.abortCallback(\r
+ function(){\r
+ recordsHandled++;\r
+ if(resultPageIsDone() && !recsReceivedCalled) {\r
+ recsReceivedCalled = true;\r
+ runEvt('result', 'allRecordsReceived', recordsCache);\r
+ unHideMe($('copyright_block'));\r
+ }\r
+ }\r
+ );\r
+\r
+ req.callback(mresultHandleMods);\r
+ req.send();\r
+ }\r
+}\r
+\r
+function mresultHandleMods(r) {\r
+ var rec = r.getResultObject();\r
+ var pagePosition = r.userdata;\r
+ runEvt('result', 'recordReceived', rec, pagePosition, true);\r
+ if(rec) resultCollectCopyCounts(rec, pagePosition, FETCH_MR_COPY_COUNTS);\r
+ if(resultPageIsDone()) {\r
+ runEvt('result', 'allRecordsReceived', recordsCache);\r
+ unHideMe($('copyright_block')); /* *** */\r
+ }\r
+}\r
+\r
+function mresultHandlePlaceHold(target) {\r
+ function reload() {\r
+ location.href = location.href.replace(/&hold_target=\d+/, '');\r
+ }\r
+ attachEvt("common", "holdUpdated", reload);\r
+ attachEvt("common", "holdUpdateCanceled", reload);\r
+ attachEvt("common", "loginCanceled", reload);\r
+ holdsDrawEditor({record:target, type: 'M'});\r
+}\r
+\r
+\r
+\r