tried out new authority code, but it didn't really help..
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 21 Nov 2005 19:37:37 +0000 (19:37 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 21 Nov 2005 19:37:37 +0000 (19:37 +0000)
trying new cookie object

git-svn-id: svn://svn.open-ils.org/ILS/trunk@2104 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/common/js/config.js
Open-ILS/web/opac/skin/default/js/mresult.js
Open-ILS/web/opac/skin/default/js/result_common.js
Open-ILS/web/opac/skin/default/xml/js_common.xml

index 6b12a8d..0deadbe 100644 (file)
@@ -194,6 +194,7 @@ var FETCH_HOLDS                                     = "open-ils.circ:open-ils.circ.holds.retrieve";
 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";
index bb45b10..46ba55d 100644 (file)
@@ -1,8 +1,12 @@
-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);
@@ -14,6 +18,7 @@ attachEvt("result", "idsReceived", mresultCollectRecords);
 function mresultUnload() { removeChildren(table); table = null;}
 
 function mresultDoSearch() {
+       //idsCookie = new HTTP.Cookies();
 
        if(getOffset() == 0) {
                swapCanvas($('loading_alt'));
@@ -49,18 +54,16 @@ function mresultHandleCount(r) {
 /* 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(); 
 
@@ -68,7 +71,7 @@ function mresultCollectIds(method) {
 
                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();
        }
@@ -87,14 +90,24 @@ function mresultHandleMRIds(r) {
 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()];
 }
 
index b1fdccd..34e24eb 100644 (file)
@@ -510,10 +510,11 @@ function resultDrawSeries() {
                $("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 ) {
@@ -534,15 +535,41 @@ function resultDrawSidebarTrees( stype, treeName, items, wrapperNode, destNode )
                        */
                //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);
@@ -564,6 +591,35 @@ function resultQuickLink( term, type ) {
        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
index db440de..e951e60 100644 (file)
@@ -8,6 +8,7 @@
        <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>