5 var idsCookie = new cookieObject("ids", 1, "/", COOKIE_IDS);
7 G.evt.common.unload.push(mresultUnload);
8 G.evt.mresult.run.push(mresultDoSearch);
9 G.evt.mresult.idsReceived.push(mresultSetRecords, mresultCollectRecords);
11 function mresultUnload() { removeChildren(table); table = null;}
13 function mresultDoSearch() {
15 table = G.ui.result.main_table;
17 hideMe(G.ui.result.row_template);
18 while( table.parentNode.rows.length <= getDisplayCount() ) /* add an extra row so IE and safari won't complain */
19 hideMe(table.appendChild(G.ui.result.row_template.cloneNode(true)));
21 if(getOffset() == 0 || getHitCount() == null ) {
23 mresultCollectIds(FETCH_MRIDS_FULL);
25 runEvt('result', 'hitCountReceived');
26 mresultCollectIds(FETCH_MRIDS);
30 function mresultGetCount() {
31 var form = (getForm() == "all") ? null : getForm();
32 var req = new Request(FETCH_MRCOUNT,
33 getStype(), getTerm(), getLocation(), getDepth(), form );
34 req.callback(mresultHandleCount);
38 function mresultHandleCount(r) {
39 HITCOUNT = parseInt(r.getResultObject());
40 runEvt('result', 'hitCountReceived');
44 /* performs the actual search */
45 function mresultCollectIds(method) {
47 if(getOffset() == 0) {
48 idsCookie.put(COOKIE_IDS,"");
52 var c = JSON2js(idsCookie.get(COOKIE_IDS));
53 if(c && c.recs) { records = c.recs; ranks = c.ranks; }
56 if( getOffset() != 0 &&
57 records[getOffset()] != null &&
58 records[resultFinalPageIndex()] != null) {
59 mresultCollectRecords();
63 var req = new Request(method, getStype(), getTerm(),
64 getLocation(), getDepth(), getDisplayCount() * 10, getOffset(), getForm() );
65 req.callback(mresultHandleMRIds);
70 function mresultHandleMRIds(r) {
71 var res = r.getResultObject();
73 if(res.count != null) {
75 runEvt('result', 'hitCountReceived');
77 runEvt('mresult', 'idsReceived', res.ids);
80 function mresultSetRecords(idstruct) {
82 for( var x = o; x < idstruct.length + o; x++ ) {
83 if(idstruct[x-o] == null) break;
84 records[x] = parseInt(idstruct[x - o][0]);
85 ranks[x] = parseFloat(idstruct[x - o][1]);
87 idsCookie.put(COOKIE_IDS, js2JSON({ recs: records, ranks : ranks }) );
91 function mresultCollectRecords() {
93 for( var x = getOffset(); x!= getDisplayCount() + getOffset(); x++ ) {
94 if(isNull(records[x])) break;
95 var req = new Request(FETCH_MRMODS, records[x]);
96 req.request.userdata = i++;
97 req.callback(mresultHandleMods);
102 function mresultHandleMods(r) {
103 var rec = r.getResultObject();
104 var pagePosition = r.userdata;
105 runEvt('result', 'recordReceived', rec, pagePosition, true);
106 resultCollectCopyCounts(rec, pagePosition, FETCH_MR_COPY_COUNTS);