5 var idsCookie = new cookieObject("ids", 1, "/", COOKIE_IDS);
7 attachEvt("common", "unload", mresultUnload);
8 attachEvt("common", "run", mresultDoSearch);
9 attachEvt("mresult", "idsReceived", mresultSetRecords);
10 attachEvt("mresult", "idsReceived", mresultCollectRecords);
13 function mresultUnload() { removeChildren(table); table = null;}
15 function mresultDoSearch() {
17 table = G.ui.result.main_table;
19 hideMe(G.ui.result.row_template);
20 while( table.parentNode.rows.length <= getDisplayCount() ) /* add an extra row so IE and safari won't complain */
21 hideMe(table.appendChild(G.ui.result.row_template.cloneNode(true)));
23 if(getOffset() == 0 || getHitCount() == null ) {
25 mresultCollectIds(FETCH_MRIDS_FULL);
27 runEvt('result', 'hitCountReceived');
28 mresultCollectIds(FETCH_MRIDS);
32 function mresultGetCount() {
33 var form = (getForm() == "all") ? null : getForm();
34 var req = new Request(FETCH_MRCOUNT,
35 getStype(), getTerm(), getLocation(), getDepth(), form );
36 req.callback(mresultHandleCount);
40 function mresultHandleCount(r) {
41 HITCOUNT = parseInt(r.getResultObject());
42 runEvt('result', 'hitCountReceived');
46 /* performs the actual search */
47 function mresultCollectIds(method) {
49 if(getOffset() == 0) {
50 idsCookie.put(COOKIE_IDS,"");
54 var c = JSON2js(idsCookie.get(COOKIE_IDS));
55 if(c && c.recs) { records = c.recs; ranks = c.ranks; }
58 if( getOffset() != 0 &&
59 records[getOffset()] != null &&
60 records[resultFinalPageIndex()] != null) {
61 mresultCollectRecords();
65 var req = new Request(method, getStype(), getTerm(),
66 getLocation(), getDepth(), getDisplayCount() * 10, getOffset(), getForm() );
67 req.callback(mresultHandleMRIds);
72 function mresultHandleMRIds(r) {
73 var res = r.getResultObject();
75 if(res.count != null) {
77 runEvt('result', 'hitCountReceived');
79 runEvt('mresult', '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]);
89 idsCookie.put(COOKIE_IDS, js2JSON({ recs: records, ranks : ranks }) );
93 function mresultCollectRecords() {
95 for( var x = getOffset(); x!= getDisplayCount() + getOffset(); x++ ) {
96 if(isNull(records[x])) break;
97 var req = new Request(FETCH_MRMODS, records[x]);
98 req.request.userdata = i++;
99 req.callback(mresultHandleMods);
104 function mresultHandleMods(r) {
105 var rec = r.getResultObject();
106 var pagePosition = r.userdata;
107 runEvt('result', 'recordReceived', rec, pagePosition, true);
108 resultCollectCopyCounts(rec, pagePosition, FETCH_MR_COPY_COUNTS);