From 33fd4af61679c880ac7684d5871f7e64e83d2a6e Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 11 Aug 2005 22:35:05 +0000 Subject: [PATCH] web git-svn-id: svn://svn.open-ils.org/ILS/trunk@1640 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/css/opac/opac.css | 2 ++ Open-ILS/src/javascript/lib/js/opac/config.js | 1 + .../src/javascript/lib/js/opac/mresult.js | 32 ++++++++++++++----- .../javascript/lib/js/opac/result_common.js | 9 ++++-- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/Open-ILS/css/opac/opac.css b/Open-ILS/css/opac/opac.css index 95fc2b053e..4aaf64a262 100644 --- a/Open-ILS/css/opac/opac.css +++ b/Open-ILS/css/opac/opac.css @@ -3,6 +3,8 @@ body a { color: black; } body a:visited { color: black; } body a:hover { color: red; text-decoration: underline;} body table { font-size: inherit; } +* { -moz-user-select : normal }; + .main_header { width: 100%; } .space { padding-right:5px; } diff --git a/Open-ILS/src/javascript/lib/js/opac/config.js b/Open-ILS/src/javascript/lib/js/opac/config.js index 49ab0eece0..29a2441d9e 100644 --- a/Open-ILS/src/javascript/lib/js/opac/config.js +++ b/Open-ILS/src/javascript/lib/js/opac/config.js @@ -16,6 +16,7 @@ var PARAM_RID = "rid"; /* metarecord id */ /* cookies */ var COOKIE_SB = "sbe"; var COOKIE_SES = "ses"; +var COOKIE_IDS = "ids"; /* these are the actual param values - set on page load */ diff --git a/Open-ILS/src/javascript/lib/js/opac/mresult.js b/Open-ILS/src/javascript/lib/js/opac/mresult.js index 99d936c581..6ed54b4559 100644 --- a/Open-ILS/src/javascript/lib/js/opac/mresult.js +++ b/Open-ILS/src/javascript/lib/js/opac/mresult.js @@ -1,7 +1,8 @@ -var records = new Array(); -var ranks = new Array(); +var records = {}; +var ranks = {}; var table; var rowtemplate; +var idsCookie = new cookieObject("ids", 1, "/", COOKIE_IDS); function mresultUnload() { removeChildren(table); table = null;} @@ -15,10 +16,11 @@ function mresultDoSearch() { hideMe(table.appendChild(G.ui.result.row_template.cloneNode(true))); if(getOffset() == 0 || getHitCount() == null ) { - mresultGetCount(); - mresultCollectIds(); + mresultGetCount(); /* get the hit count */ + mresultCollectIds(); /* do the actual search */ } else { resultSetInfo(); + //mresultCollectRecords(); /* grab the records if we have the id's cached */ mresultCollectIds(); } } @@ -38,10 +40,22 @@ function mresultHandleCount(r) { /* performs the actual search */ function mresultCollectIds() { - var req = new Request(FETCH_MRIDS, getStype(), getTerm(), - getLocation(), getDepth(), getDisplayCount(), getOffset(), getForm() ); - req.callback(mresultHandleMRIds); - req.send(); + + var c = JSON2js(idsCookie.get(COOKIE_IDS)); + if(c && c.recs) { records = c.recs; ranks = c.ranks; } + + if( records[getOffset()] != null && + records[getOffset() + getDisplayCount() - 1] != null) { + // alert("cached!"); + mresultCollectRecords(); + + } else { + + var req = new Request(FETCH_MRIDS, getStype(), getTerm(), + getLocation(), getDepth(), getDisplayCount() * 5, getOffset(), getForm() ); + req.callback(mresultHandleMRIds); + req.send(); + } } function mresultHandleMRIds(r) { @@ -55,6 +69,8 @@ function mresultSetRecords(idstruct) { records[x] = idstruct[x - o][0]; ranks[x] = idstruct[x - o][1]; } + idsCookie.put(COOKIE_IDS, js2JSON({ recs: records, ranks : ranks }) ); + idsCookie.write(); } function mresultHandleMods(r) { diff --git a/Open-ILS/src/javascript/lib/js/opac/result_common.js b/Open-ILS/src/javascript/lib/js/opac/result_common.js index 53f268fd61..7d9137fa4d 100644 --- a/Open-ILS/src/javascript/lib/js/opac/result_common.js +++ b/Open-ILS/src/javascript/lib/js/opac/result_common.js @@ -1,6 +1,7 @@ var subjectCache = {}; var authorCache = {}; var seriesCache = {}; +var recordsHandled = 0; /* set the search result info, number of hits, which results we're displaying, links to the next/prev pages, etc. */ @@ -55,6 +56,7 @@ function resultSetInfo() { function resultDisplayRecord(rec, rowtemplate, pos, is_mr) { if(rec == null) rec = new mvr(); /* so the page won't die */ + recordsHandled++; /* hide the 'now loading...' message */ hideMe(G.ui.common.loading); @@ -77,7 +79,8 @@ function resultDisplayRecord(rec, rowtemplate, pos, is_mr) { authorCache[rec.author()] = 1; for( var s in rec.series() ) seriesCache[rec.series()[s]] = 1; - if(resultPageIsDone(pos)) { + if(resultPageIsDone() && !subjectsAreDrawn) { + subjectsAreDrawn = true; resultDrawSubjects(); resultDrawAuthors(); resultDrawSeries(); @@ -94,8 +97,10 @@ function resultDisplayRecord(rec, rowtemplate, pos, is_mr) { } +var subjectsAreDrawn = false; function resultPageIsDone(pos) { - return ((pos+1) == getDisplayCount() || (pos+1 + getOffset()) == getHitCount()); + return (recordsHandled == getDisplayCount() + || recordsHandled + getOffset() == getHitCount()); } -- 2.43.2