-var records = {};
-var ranks = {};
+//var records = {};
+var records = [];
+var ranks = [];
var onlyrecord = {};
var table;
-var idsCookie = new cookieObject("ids", 1, "/", COOKIE_IDS);
+var mresultPreCache = 200;
+//var idsCookie = new cookieObject("ids", 1, "/", COOKIE_IDS);
+//var idsCookie;
+var idsCookie = new HTTP.Cookies();
var searchTimer;
attachEvt("common", "unload", mresultUnload);
function mresultUnload() { removeChildren(table); table = null;}
function mresultDoSearch() {
+ //idsCookie = new HTTP.Cookies();
if(getOffset() == 0) {
swapCanvas($('loading_alt'));
/* performs the actual search */
function mresultCollectIds(method) {
- if(getOffset() == 0) {
- idsCookie.put(COOKIE_IDS,"[]");
- idsCookie.write();
-
- } else {
- var c = JSON2js(idsCookie.get(COOKIE_IDS));
- if(c && c.recs) { records = c.recs; ranks = c.ranks; }
+ if( (getOffset() > 0) && (getOffset() < mresultPreCache) ) {
+ //alert('cached: ' + idsCookie.read(COOKIE_IDS));
+ var c = JSON2js(idsCookie.read(COOKIE_IDS));
+ if(c) { records = c[0]; ransk = c[1]; }
}
if( getOffset() != 0 &&
records[getOffset()] != null &&
records[resultFinalPageIndex()] != null) {
+ //alert('we have cookies... offset : ' + getOffset() );
runEvt('result', 'hitCountReceived');
mresultCollectRecords();
var form = (getForm() == "all") ? null : getForm();
var req = new Request(method, getStype(), getTerm(),
- getLocation(), getDepth(), 100, getOffset(), form );
+ getLocation(), getDepth(), mresultPreCache, getOffset(), form );
req.callback(mresultHandleMRIds);
req.send();
}
function mresultSetRecords(idstruct) {
if(!idstruct) return;
var o = getOffset();
+
for( var x = o; x < idstruct.length + o; x++ ) {
- if(idstruct[x-o] == null) break;
- records[x] = parseInt(idstruct[x - o][0]);
- ranks[x] = parseFloat(idstruct[x - o][1]);
- onlyrecord[x] = parseInt(idstruct[x - o][2]);
+ if( idstruct[x-o] != null ) {
+ var r = parseInt(idstruct[x - o][0]);
+ var ra = parseFloat(idstruct[x - o][1]);
+ var or = parseInt(idstruct[x - o][2]);
+ if(!isNull(r) && !isNaN(r)) records[x] = r;
+ if(!isNull(ra) && !isNaN(ra)) ranks[x] = ra;
+ if(!isNull(or) && !isNaN(or)) onlyrecord[x] = or;
+ }
}
- idsCookie.put(COOKIE_IDS, js2JSON({ recs: records, ranks : ranks }) );
- idsCookie.write();
+
+ if(getOffset() == 0) {
+ idsCookie.remove(COOKIE_IDS);
+ idsCookie.write(COOKIE_IDS, js2JSON([ records, ranks ]), '+1d' );
+ //alert('Set cookies: ' + idsCookie.read(COOKIE_IDS) + ' : ' + idsCookie.read(COOKIE_IDS).length );
+ }
+
TOPRANK = ranks[getOffset()];
}