5 var idsCookie = new cookieObject("ids", 1, "/", COOKIE_IDS);
8 attachEvt("common", "unload", mresultUnload);
9 attachEvt("common", "run", mresultDoSearch);
10 attachEvt("result", "idsReceived", mresultSetRecords);
11 attachEvt("result", "idsReceived", mresultCollectRecords);
14 function mresultUnload() { removeChildren(table); table = null;}
16 function mresultDoSearch() {
18 if(getOffset() == 0) {
19 swapCanvas($('loading_alt'));
20 searchTimer = new Timer('searchTimer',$('loading_alt_span'));
24 table = G.ui.result.main_table;
26 while( table.parentNode.rows.length <= (getDisplayCount() + 1) ) /* add an extra row so IE and safari won't complain */
27 table.appendChild(G.ui.result.row_template.cloneNode(true));
29 if(getOffset() == 0 || getHitCount() == null )
30 mresultCollectIds(FETCH_MRIDS_FULL);
32 mresultCollectIds(FETCH_MRIDS);
35 function mresultGetCount() {
36 var form = (getForm() == "all") ? null : getForm();
37 var req = new Request(FETCH_MRCOUNT,
38 getStype(), getTerm(), getLocation(), getDepth(), form );
39 req.callback(mresultHandleCount);
43 function mresultHandleCount(r) {
44 HITCOUNT = parseInt(r.getResultObject());
45 runEvt('result', 'hitCountReceived');
49 /* performs the actual search */
50 function mresultCollectIds(method) {
52 if(getOffset() == 0) {
53 idsCookie.put(COOKIE_IDS,"[]");
57 var c = JSON2js(idsCookie.get(COOKIE_IDS));
58 if(c && c.recs) { records = c.recs; ranks = c.ranks; }
61 if( getOffset() != 0 &&
62 records[getOffset()] != null &&
63 records[resultFinalPageIndex()] != null) {
64 runEvt('result', 'hitCountReceived');
65 mresultCollectRecords();
69 var form = (getForm() == "all") ? null : getForm();
70 var req = new Request(method, getStype(), getTerm(),
71 getLocation(), getDepth(), 100, getOffset(), form );
72 req.callback(mresultHandleMRIds);
77 function mresultHandleMRIds(r) {
78 var res = r.getResultObject();
80 if(res.count != null) {
81 if( getOffset() == 0 ) HITCOUNT = res.count;
82 runEvt('result', 'hitCountReceived');
84 runEvt('result', 'idsReceived', res.ids);
87 function mresultSetRecords(idstruct) {
90 for( var x = o; x < idstruct.length + o; x++ ) {
91 if(idstruct[x-o] == null) break;
92 records[x] = parseInt(idstruct[x - o][0]);
93 ranks[x] = parseFloat(idstruct[x - o][1]);
94 onlyrecord[x] = parseInt(idstruct[x - o][2]);
96 idsCookie.put(COOKIE_IDS, js2JSON({ recs: records, ranks : ranks }) );
98 TOPRANK = ranks[getOffset()];
101 function mresultCollectRecords() {
102 if(getHitCount() > 0 ) runEvt("result", "preCollectRecords");
104 for( var x = getOffset(); x!= getDisplayCount() + getOffset(); x++ ) {
105 if(isNull(records[x])) break;
106 if(isNaN(records[x])) continue;
107 var req = new Request(FETCH_MRMODS, records[x]);
108 req.request.userdata = i++;
109 req.callback(mresultHandleMods);
114 function mresultHandleMods(r) {
115 var rec = r.getResultObject();
116 var pagePosition = r.userdata;
117 runEvt('result', 'recordReceived', rec, pagePosition, true);
118 resultCollectCopyCounts(rec, pagePosition, FETCH_MR_COPY_COUNTS);