5 var idsCookie = new cookieObject("ids", 1, "/", COOKIE_IDS);
7 attachEvt("common", "unload", mresultUnload);
8 attachEvt("common", "run", mresultDoSearch);
9 attachEvt("result", "idsReceived", mresultSetRecords);
10 attachEvt("result", "idsReceived", mresultCollectRecords);
13 function mresultUnload() { removeChildren(table); table = null;}
15 function mresultDoSearch() {
17 table = G.ui.result.main_table;
19 while( table.parentNode.rows.length <= getDisplayCount() ) /* add an extra row so IE and safari won't complain */
20 table.appendChild(G.ui.result.row_template.cloneNode(true));
22 if(getOffset() == 0 || getHitCount() == null ) {
24 mresultCollectIds(FETCH_MRIDS_FULL);
26 runEvt('result', 'hitCountReceived');
27 mresultCollectIds(FETCH_MRIDS);
31 function mresultGetCount() {
32 var form = (getForm() == "all") ? null : getForm();
33 var req = new Request(FETCH_MRCOUNT,
34 getStype(), getTerm(), getLocation(), getDepth(), form );
35 req.callback(mresultHandleCount);
39 function mresultHandleCount(r) {
40 HITCOUNT = parseInt(r.getResultObject());
41 runEvt('result', 'hitCountReceived');
45 /* performs the actual search */
46 function mresultCollectIds(method) {
48 if(getOffset() == 0) {
49 idsCookie.put(COOKIE_IDS,"");
53 var c = JSON2js(idsCookie.get(COOKIE_IDS));
54 if(c && c.recs) { records = c.recs; ranks = c.ranks; }
57 if( getOffset() != 0 &&
58 records[getOffset()] != null &&
59 records[resultFinalPageIndex()] != null) {
60 mresultCollectRecords();
64 var form = (getForm() == "all") ? null : getForm();
65 var req = new Request(method, getStype(), getTerm(),
66 getLocation(), getDepth(), getDisplayCount() * 5, getOffset(), form );
67 req.callback(mresultHandleMRIds);
72 function mresultHandleMRIds(r) {
73 var res = r.getResultObject();
75 if(res.count != null) {
77 runEvt('result', 'hitCountReceived');
79 runEvt('result', 'idsReceived', res.ids);
82 function mresultSetRecords(idstruct) {
84 for( var x = o; x < idstruct.length + o; x++ ) {
85 if(idstruct[x-o] == null) break;
86 records[x] = parseInt(idstruct[x - o][0]);
87 ranks[x] = parseFloat(idstruct[x - o][1]);
88 onlyrecord[x] = parseInt(idstruct[x - o][4]);
90 idsCookie.put(COOKIE_IDS, js2JSON({ recs: records, ranks : ranks }) );
92 TOPRANK = ranks[getOffset()];
95 function mresultCollectRecords() {
96 runEvt("result", "preCollectRecords");
98 for( var x = getOffset(); x!= getDisplayCount() + getOffset(); x++ ) {
99 if(isNull(records[x])) break;
100 var req = new Request(FETCH_MRMODS, records[x]);
101 req.request.userdata = i++;
102 req.callback(mresultHandleMods);
107 function mresultHandleMods(r) {
108 var rec = r.getResultObject();
109 var pagePosition = r.userdata;
110 runEvt('result', 'recordReceived', rec, pagePosition, true);
111 resultCollectCopyCounts(rec, pagePosition, FETCH_MR_COPY_COUNTS);