From bbf295156bcbd099cef3ac63d60a15e0b1970d46 Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 16 May 2006 02:40:53 +0000 Subject: [PATCH] showing progress bar on rresult, added a timeout function for requests along with an abort callback, testing git-svn-id: svn://svn.open-ils.org/ILS/trunk@4301 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/common/js/RemoteRequest.js | 30 +++++++++++++++++-- Open-ILS/web/opac/skin/default/js/mresult.js | 26 ++++++++++------ .../web/opac/skin/default/js/result_common.js | 1 + Open-ILS/web/opac/skin/default/js/rresult.js | 6 ++++ 4 files changed, 51 insertions(+), 12 deletions(-) diff --git a/Open-ILS/web/opac/common/js/RemoteRequest.js b/Open-ILS/web/opac/common/js/RemoteRequest.js index cf7ba03166..b78a37d62f 100644 --- a/Open-ILS/web/opac/common/js/RemoteRequest.js +++ b/Open-ILS/web/opac/common/js/RemoteRequest.js @@ -27,8 +27,6 @@ function abortAllRequests() { for( var i in _allrequests ) { var r = _allrequests[i]; if(r) { - /* this has to come before abort() or IE will puke on you */ - r.xmlhttp.onreadystatechange = function(){}; r.abort(); destroyRequest(r); } @@ -80,6 +78,28 @@ function RemoteRequest( service, method ) { } + +RemoteRequest.prototype.timeout = function(t) { + t *= 1000 + var req = this; + req.timeoutFunc = setTimeout( + function() { + if( req && req.xmlhttp ) { + req.cancelled = true; + req.abort(); + if( req.abtCallback ) { + req.abtCallback(req); + } + } + }, + t + ); +} + +RemoteRequest.prototype.abortCallback = function(func) { + this.abtCallback = func; +} + RemoteRequest.prototype.event = function(evt) { if( arguments.length > 0 ) this.evt = evt; @@ -87,7 +107,11 @@ RemoteRequest.prototype.event = function(evt) { } RemoteRequest.prototype.abort = function() { - if( this.xmlhttp ) this.xmlhttp.abort(); + if( this.xmlhttp ) { + /* this has to come before abort() or IE will puke on you */ + this.xmlhttp.onreadystatechange = function(){}; + this.xmlhttp.abort(); + } } /* constructs our XMLHTTPRequest object */ diff --git a/Open-ILS/web/opac/skin/default/js/mresult.js b/Open-ILS/web/opac/skin/default/js/mresult.js index 7089b0e1d3..55df8024b0 100644 --- a/Open-ILS/web/opac/skin/default/js/mresult.js +++ b/Open-ILS/web/opac/skin/default/js/mresult.js @@ -20,14 +20,7 @@ function mresultDoSearch() { TFORM = null; /* clear the rresult tform var so it's not propogated */ - if(getOffset() == 0) { - swapCanvas($('loading_alt')); - /* - searchTimer = new Timer('searchTimer',$('loading_alt_span')); - searchTimer.start(); - */ - } - + swapCanvas($('loading_alt')); table = G.ui.result.main_table; while( table.parentNode.rows.length <= (getDisplayCount() + 1) ) @@ -215,7 +208,22 @@ function mresultCollectRecords() { if(isNull(records[x])) break; if(isNaN(records[x])) continue; var req = new Request(FETCH_MRMODS, records[x]); + req.request.userdata = i++; + + /* wait at most 10 seconds for the mods rec to come back */ + /* this needs more testing */ + req.request.timeout(10); + req.request.abortCallback( + function(){ + recordsHandled++; + if(resultPageIsDone()) { + runEvt('result', 'allRecordsReceived', recordsCache); + unHideMe($('copyright_block')); + } + } + ); + req.callback(mresultHandleMods); req.send(); } @@ -225,7 +233,7 @@ function mresultHandleMods(r) { var rec = r.getResultObject(); var pagePosition = r.userdata; runEvt('result', 'recordReceived', rec, pagePosition, true); - resultCollectCopyCounts(rec, pagePosition, FETCH_MR_COPY_COUNTS); + if(rec) resultCollectCopyCounts(rec, pagePosition, FETCH_MR_COPY_COUNTS); if(resultPageIsDone()) { runEvt('result', 'allRecordsReceived', recordsCache); unHideMe($('copyright_block')); /* *** */ diff --git a/Open-ILS/web/opac/skin/default/js/result_common.js b/Open-ILS/web/opac/skin/default/js/result_common.js index 42ba5d5214..5ee0ad02c1 100644 --- a/Open-ILS/web/opac/skin/default/js/result_common.js +++ b/Open-ILS/web/opac/skin/default/js/result_common.js @@ -65,6 +65,7 @@ function resultCollectSearchIds( type, method, handler ) { if(item_type) args.item_type = item_type; if(item_form) args.item_form = item_form; + if(getAudience()) args.audience = getAudience().split(/,/); if(getLitForm()) args.lit_form = getLitForm().split(/,/); if(getLanguage()) args.language = getLanguage().split(/,/); diff --git a/Open-ILS/web/opac/skin/default/js/rresult.js b/Open-ILS/web/opac/skin/default/js/rresult.js index 1bc38e38be..f3a613579e 100644 --- a/Open-ILS/web/opac/skin/default/js/rresult.js +++ b/Open-ILS/web/opac/skin/default/js/rresult.js @@ -13,6 +13,12 @@ attachEvt("result", "recordDrawn", rresultLaunchDrawn); hideMe($('copyright_block')); function rresultDoSearch() { + + swapCanvas($('loading_alt')); + /* + if(getOffset() == 0) swapCanvas($('loading_alt')); + */ + table = G.ui.result.main_table; hideMe(G.ui.result.row_template); while( table.parentNode.rows.length <= (getDisplayCount() +1) ) -- 2.43.2