6 var mresultPreCache = 200;
7 //var idsCookie = new cookieObject("ids", 1, "/", COOKIE_IDS);
9 var idsCookie = new HTTP.Cookies();
12 attachEvt("common", "unload", mresultUnload);
13 attachEvt("common", "run", mresultDoSearch);
14 attachEvt("result", "idsReceived", mresultSetRecords);
15 attachEvt("result", "idsReceived", mresultCollectRecords);
18 function mresultUnload() { removeChildren(table); table = null;}
20 function mresultDoSearch() {
21 //idsCookie = new HTTP.Cookies();
23 if(getOffset() == 0) {
24 swapCanvas($('loading_alt'));
25 searchTimer = new Timer('searchTimer',$('loading_alt_span'));
29 table = G.ui.result.main_table;
31 while( table.parentNode.rows.length <= (getDisplayCount() + 1) ) /* add an extra row so IE and safari won't complain */
32 table.appendChild(G.ui.result.row_template.cloneNode(true));
34 if(getOffset() == 0 || getHitCount() == null )
35 mresultCollectIds(FETCH_MRIDS_FULL);
37 mresultCollectIds(FETCH_MRIDS);
40 function mresultGetCount() {
41 var form = (getForm() == "all") ? null : getForm();
42 var req = new Request(FETCH_MRCOUNT,
43 getStype(), getTerm(), getLocation(), getDepth(), form );
44 req.callback(mresultHandleCount);
48 function mresultHandleCount(r) {
49 HITCOUNT = parseInt(r.getResultObject());
50 runEvt('result', 'hitCountReceived');
54 /* performs the actual search */
55 function mresultCollectIds(method) {
57 if( (getOffset() > 0) && (getOffset() < mresultPreCache) ) {
58 //alert('cached: ' + idsCookie.read(COOKIE_IDS));
59 var c = JSON2js(idsCookie.read(COOKIE_IDS));
60 if(c) { records = c[0]; ransk = c[1]; }
63 if( getOffset() != 0 &&
64 records[getOffset()] != null &&
65 records[resultFinalPageIndex()] != null) {
66 //alert('we have cookies... offset : ' + getOffset() );
67 runEvt('result', 'hitCountReceived');
68 mresultCollectRecords();
72 var form = (getForm() == "all") ? null : getForm();
73 var req = new Request(method, getStype(), getTerm(),
74 getLocation(), getDepth(), mresultPreCache, getOffset(), form );
75 req.callback(mresultHandleMRIds);
80 function mresultHandleMRIds(r) {
81 var res = r.getResultObject();
83 if(res.count != null) {
84 if( getOffset() == 0 ) HITCOUNT = res.count;
85 runEvt('result', 'hitCountReceived');
87 runEvt('result', 'idsReceived', res.ids);
90 function mresultSetRecords(idstruct) {
94 for( var x = o; x < idstruct.length + o; x++ ) {
95 if( idstruct[x-o] != null ) {
96 var r = parseInt(idstruct[x - o][0]);
97 var ra = parseFloat(idstruct[x - o][1]);
98 var or = parseInt(idstruct[x - o][2]);
99 if(!isNull(r) && !isNaN(r)) records[x] = r;
100 if(!isNull(ra) && !isNaN(ra)) ranks[x] = ra;
101 if(!isNull(or) && !isNaN(or)) onlyrecord[x] = or;
105 if(getOffset() == 0) {
106 idsCookie.remove(COOKIE_IDS);
107 idsCookie.write(COOKIE_IDS, js2JSON([ records, ranks ]), '+1d' );
108 //alert('Set cookies: ' + idsCookie.read(COOKIE_IDS) + ' : ' + idsCookie.read(COOKIE_IDS).length );
111 TOPRANK = ranks[getOffset()];
114 function mresultCollectRecords() {
115 if(getHitCount() > 0 ) runEvt("result", "preCollectRecords");
117 for( var x = getOffset(); x!= getDisplayCount() + getOffset(); x++ ) {
118 if(isNull(records[x])) break;
119 if(isNaN(records[x])) continue;
120 var req = new Request(FETCH_MRMODS, records[x]);
121 req.request.userdata = i++;
122 req.callback(mresultHandleMods);
127 function mresultHandleMods(r) {
128 var rec = r.getResultObject();
129 var pagePosition = r.userdata;
130 runEvt('result', 'recordReceived', rec, pagePosition, true);
131 resultCollectCopyCounts(rec, pagePosition, FETCH_MR_COPY_COUNTS);