6 var idsCookie = new cookieObject("ids", 1, "/", COOKIE_IDS);
8 attachEvt("common", "unload", mresultUnload);
9 attachEvt("common", "run", mresultDoSearch);
10 attachEvt("mresult", "idsReceived", mresultSetRecords);
11 attachEvt("mresult", "idsReceived", mresultCollectRecords);
14 function mresultUnload() { removeChildren(table); table = null;}
16 function mresultDoSearch() {
18 table = G.ui.result.main_table;
20 hideMe(G.ui.result.row_template);
21 while( table.parentNode.rows.length <= getDisplayCount() ) /* add an extra row so IE and safari won't complain */
22 hideMe(table.appendChild(G.ui.result.row_template.cloneNode(true)));
24 if(getOffset() == 0 || getHitCount() == null ) {
26 mresultCollectIds(FETCH_MRIDS_FULL);
28 runEvt('result', 'hitCountReceived');
29 mresultCollectIds(FETCH_MRIDS);
33 function mresultGetCount() {
34 var form = (getForm() == "all") ? null : getForm();
35 var req = new Request(FETCH_MRCOUNT,
36 getStype(), getTerm(), getLocation(), getDepth(), form );
37 req.callback(mresultHandleCount);
41 function mresultHandleCount(r) {
42 HITCOUNT = parseInt(r.getResultObject());
43 runEvt('result', 'hitCountReceived');
47 /* performs the actual search */
48 function mresultCollectIds(method) {
50 if(getOffset() == 0) {
51 idsCookie.put(COOKIE_IDS,"");
55 var c = JSON2js(idsCookie.get(COOKIE_IDS));
56 if(c && c.recs) { records = c.recs; ranks = c.ranks; }
59 if( getOffset() != 0 &&
60 records[getOffset()] != null &&
61 records[resultFinalPageIndex()] != null) {
62 mresultCollectRecords();
66 var form = (getForm() == "all") ? null : getForm();
67 var req = new Request(method, getStype(), getTerm(),
68 getLocation(), getDepth(), getDisplayCount() * 10, getOffset(), form );
69 req.callback(mresultHandleMRIds);
74 function mresultHandleMRIds(r) {
75 var res = r.getResultObject();
77 if(res.count != null) {
79 runEvt('result', 'hitCountReceived');
81 runEvt('mresult', 'idsReceived', res.ids);
84 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][4]);
92 idsCookie.put(COOKIE_IDS, js2JSON({ recs: records, ranks : ranks }) );
96 function mresultCollectRecords() {
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);