var FETCH_FINES_SUMMARY = "open-ils.actor:open-ils.actor.user.fines.summary";
var FETCH_TRANSACTIONS = "open-ils.actor:open-ils.actor.user.transactions.have_charge.fleshed";
var FETCH_CROSSREF = "open-ils.search:open-ils.search.authority.crossref";
+var FETCH_CROSSREF_BATCH = "open-ils.search:open-ils.search.authority.crossref.batch";
var CREATE_HOLD = "open-ils.circ:open-ils.circ.holds.create";
var CANCEL_HOLD = "open-ils.circ:open-ils.circ.hold.cancel";
var UPDATE_USERNAME = "open-ils.actor:open-ils.actor.user.username.update";
-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()];
}
$("series_sidebar_tree_div") );
}
+var _oldFashioned = true;
function resultDrawSidebarTrees( stype, treeName, items, wrapperNode, destNode ) {
- var tree;
eval("tree = " + treeName);
+ var xrefCache = [];
var found = false;
var x = 0;
for( var i in items ) {
*/
//if(!IE) resultFireXRefReq(treeName, stype, items[i]);
//resultFireXRefReq(treeName, stype, items[i]);
- setTimeout('resultFireXRefReq("'+treeName+'","'+stype+'","'+item+'");', 100);
+
+
+ if(_oldFashioned && !IE)
+ resultFireXRefReq(treeName, stype, items[i]);
+
+ //setTimeout('resultFireXRefReq("'+treeName+'","'+stype+'","'+item+'");', 100);
+
+ var a = {};
+ a.type = stype;
+ a.term = item;
+ xrefCache.push(a);
}
if(found) {
unHideMe(wrapperNode);
- //tree.close(tree.rootid);
+ if(!_oldFashioned)
+ resultFireXRefBatch(treeName, xrefCache, stype);
}
}
+function resultFireXRefBatch(treeName, xrefCache, stype) {
+ var query = [];
+ for( var i = 0; i != xrefCache.length; i++ ) {
+ var topic = xrefCache[i];
+ query.push( [ topic.type, topic.term ] );
+ }
+ var req = new Request(FETCH_CROSSREF_BATCH, query);
+ var tree;
+ eval('tree=' + treeName);
+ req.request._tree = tree;
+ req.request._stype = stype;
+ req.callback(resultRenderXRefTree);
+ req.send();
+}
+
function resultFireXRefReq( treeName, stype, item ) {
var tree;
eval('tree=' + treeName);
return buildOPACLink(args);
}
+function resultRenderXRefTree(r) {
+ var tree = r._tree;
+ var res = r.getResultObject();
+ var stype = r._stype;
+
+ for( var c in res ) {
+ var cls = res[c];
+ for( var t in cls ) {
+ var term = res[c][t];
+ var froms = term['from'];
+ var alsos = term['also'];
+ var total = 0;
+
+ for( var i = 0; (total++ < 5 && i < froms.length); i++ ) {
+ var string = normalize(truncate(froms[i], 45));
+ if($(stype + '_' + froms[i])) continue;
+ tree.addNode(stype + '_' + froms[i],
+ stype + '_' + t, string, resultQuickLink(froms[i],stype));
+ }
+ for( var i = 0; (total++ < 10 && i < alsos.length); i++ ) {
+ var string = normalize(truncate(alsos[i], 45));
+ if($(stype + '_' + alsos[i])) continue;
+ tree.addNode(stype + '_' + alsos[i],
+ stype + '_' + t, string, resultQuickLink(alsos[i],stype));
+ }
+ }
+ }
+}
+
function resultAppendCrossRef(r) {
var tree = r._tree
<script language='javascript' src='../../../common/js//config.js'> </script>
<script language='javascript' src='../../../common/js/CGI.js'> </script>
<script language='javascript' src='../../../common/js/Cookie.js'> </script>
+ <script language='javascript' src='../../../common/js/Cookies.js'> </script>
<script language='javascript' src='../../../common/js/md5.js'> </script>
<script language='javascript' src='../../../common/js/slimtree.js'> </script>