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() + 1) ) /* 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 )
23 mresultCollectIds(FETCH_MRIDS_FULL);
25 mresultCollectIds(FETCH_MRIDS);
28 function mresultGetCount() {
29 var form = (getForm() == "all") ? null : getForm();
30 var req = new Request(FETCH_MRCOUNT,
31 getStype(), getTerm(), getLocation(), getDepth(), form );
32 req.callback(mresultHandleCount);
36 function mresultHandleCount(r) {
37 HITCOUNT = parseInt(r.getResultObject());
38 runEvt('result', 'hitCountReceived');
42 /* performs the actual search */
43 function mresultCollectIds(method) {
45 if(getOffset() == 0) {
46 idsCookie.put(COOKIE_IDS,"[]");
50 var c = JSON2js(idsCookie.get(COOKIE_IDS));
51 if(c && c.recs) { records = c.recs; ranks = c.ranks; }
54 if( getOffset() != 0 &&
55 records[getOffset()] != null &&
56 records[resultFinalPageIndex()] != null) {
57 runEvt('result', 'hitCountReceived');
58 mresultCollectRecords();
62 var form = (getForm() == "all") ? null : getForm();
63 var req = new Request(method, getStype(), getTerm(),
64 getLocation(), getDepth(), 100, getOffset(), form );
65 req.callback(mresultHandleMRIds);
70 function mresultHandleMRIds(r) {
71 var res = r.getResultObject();
73 if(res.count != null) {
74 if( getOffset() == 0 ) HITCOUNT = res.count;
75 runEvt('result', 'hitCountReceived');
77 runEvt('result', 'idsReceived', res.ids);
80 function mresultSetRecords(idstruct) {
83 for( var x = o; x < idstruct.length + o; x++ ) {
84 if(idstruct[x-o] == null) break;
85 records[x] = parseInt(idstruct[x - o][0]);
86 ranks[x] = parseFloat(idstruct[x - o][1]);
87 onlyrecord[x] = parseInt(idstruct[x - o][2]);
89 idsCookie.put(COOKIE_IDS, js2JSON({ recs: records, ranks : ranks }) );
91 TOPRANK = ranks[getOffset()];
94 function mresultCollectRecords() {
95 runEvt("result", "preCollectRecords");
97 for( var x = getOffset(); x!= getDisplayCount() + getOffset(); x++ ) {
98 if(isNull(records[x])) break;
99 if(isNaN(records[x])) continue;
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);