From 0b5306fef8c74225941f7f8a8c8b8be9b94e4c63 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 1 Mar 2006 21:15:35 +0000 Subject: [PATCH] added an abort() method for remoterequests (which works great in FF, but may as well not exist in IE). cancelling requests on login/logout to speed up interface response time git-svn-id: svn://svn.open-ils.org/ILS/trunk@3230 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/common/js/RemoteRequest.js | 14 ++++++++++++-- Open-ILS/web/opac/common/js/opac_utils.js | 9 +++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Open-ILS/web/opac/common/js/RemoteRequest.js b/Open-ILS/web/opac/common/js/RemoteRequest.js index 11c40de12c..6126f38db4 100644 --- a/Open-ILS/web/opac/common/js/RemoteRequest.js +++ b/Open-ILS/web/opac/common/js/RemoteRequest.js @@ -25,8 +25,14 @@ function cleanRemoteRequests() { function destroyRequest(r) { if(r == null) return; - r.xmlhttp.onreadystatechange = function(){}; - r.xmlhttp = null; + + if( r.xmlhttp ) { + /* this has to come before abort() or IE will puke on you */ + r.xmlhttp.onreadystatechange = function(){}; + r.abort(); + r.xmlhttp = null; + } + r.callback = null; r.userdata = null; _allrequests[r.id] = null; @@ -62,6 +68,10 @@ function RemoteRequest( service, method ) { if( this.buildXMLRequest() == null ) alert("Browser is not supported!"); } +RemoteRequest.prototype.abort = function() { + if( this.xmlhttp ) this.xmlhttp.abort(); +} + /* constructs our XMLHTTPRequest object */ RemoteRequest.prototype.buildXMLRequest = function() { diff --git a/Open-ILS/web/opac/common/js/opac_utils.js b/Open-ILS/web/opac/common/js/opac_utils.js index 5157f22fb8..cd9a078691 100644 --- a/Open-ILS/web/opac/common/js/opac_utils.js +++ b/Open-ILS/web/opac/common/js/opac_utils.js @@ -176,7 +176,7 @@ function buildOPACLink(args, slim, ssl) { for( var x in args ) { var v = args[x]; - if(x == "page" || v == null || v == undefined ) continue; + if(x == "page" || v == null || v == undefined || v+'' == 'NaN' ) continue; if(x == PARAM_OFFSET && v == 0) continue; if(x == PARAM_LOCATION && v == 1) continue; if(x == PARAM_DEPTH && v == 0) continue; @@ -221,7 +221,7 @@ function buildOPACLink(args, slim, ssl) { function _appendParam( fieldVar, fieldName, overrideArgs, getFunc, string ) { var ret = ""; - if( fieldVar != null && overrideArgs[fieldName] == null ) + if( fieldVar != null && (fieldVar +'' != 'NaN') && overrideArgs[fieldName] == null ) ret = "&" + fieldName + "=" + encodeURIComponent(getFunc()); return ret; } @@ -425,6 +425,8 @@ function grabSkinFromURL() { /* returns a fleshed G.user on success, false on failure */ function doLogin() { + cleanRemoteRequests(); /* cancel whatever is out there */ + var uname = G.ui.login.username.value; var passwd = G.ui.login.password.value; @@ -458,6 +460,9 @@ function doLogin() { function doLogout(noredirect) { + /* cancel everything else */ + cleanRemoteRequests(); + /* be nice and delete the session from the server */ if(G.user && G.user.session) { var req = new Request(LOGIN_DELETE, G.user.session); -- 2.43.2