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 ) {
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 runEvt('result', 'hitCountReceived');
61 mresultCollectRecords();
65 var form = (getForm() == "all") ? null : getForm();
66 var req = new Request(method, getStype(), getTerm(),
67 getLocation(), getDepth(), 100, getOffset(), form );
68 req.callback(mresultHandleMRIds);
73 function mresultHandleMRIds(r) {
74 var res = r.getResultObject();
76 if(res.count != null) {
77 if( getOffset() == 0 ) HITCOUNT = res.count;
78 runEvt('result', 'hitCountReceived');
80 runEvt('result', 'idsReceived', res.ids);
83 function mresultSetRecords(idstruct) {
86 for( var x = o; x < idstruct.length + o; x++ ) {
87 if(idstruct[x-o] == null) break;
88 records[x] = parseInt(idstruct[x - o][0]);
89 ranks[x] = parseFloat(idstruct[x - o][1]);
90 onlyrecord[x] = parseInt(idstruct[x - o][2]);
92 idsCookie.put(COOKIE_IDS, js2JSON({ recs: records, ranks : ranks }) );
94 TOPRANK = ranks[getOffset()];
97 function mresultCollectRecords() {
98 runEvt("result", "preCollectRecords");
100 for( var x = getOffset(); x!= getDisplayCount() + getOffset(); x++ ) {
101 if(isNull(records[x])) break;
102 if(isNaN(records[x])) continue;
103 var req = new Request(FETCH_MRMODS, records[x]);
104 req.request.userdata = i++;
105 req.callback(mresultHandleMods);
110 function mresultHandleMods(r) {
111 var rec = r.getResultObject();
112 var pagePosition = r.userdata;
113 runEvt('result', 'recordReceived', rec, pagePosition, true);
114 resultCollectCopyCounts(rec, pagePosition, FETCH_MR_COPY_COUNTS);