From 60eba3e7822e0d87418ebaf2d8912d6db8721524 Mon Sep 17 00:00:00 2001 From: euzuro Date: Thu, 1 Jun 2006 01:15:23 +0000 Subject: [PATCH] change Ajax.js's loadURL() function to take directly function references instead of strings to be dereferenced through a 'handlers' variable. Update code in Tile.WFS... only place it is used. git-svn-id: http://svn.openlayers.org/trunk/openlayers@487 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Ajax.js | 43 ++++++++++++++------------------------ lib/OpenLayers/Tile/WFS.js | 5 +---- 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/lib/OpenLayers/Ajax.js b/lib/OpenLayers/Ajax.js index 28e16b703e..2ba366b814 100644 --- a/lib/OpenLayers/Ajax.js +++ b/lib/OpenLayers/Ajax.js @@ -5,21 +5,23 @@ OpenLayers.ProxyHost = "/viewer/Crossbrowser/blindproxy.py?url="; /** * Ajax reader for OpenLayers * -* Pay close attention to how this works: -* *@uri url to do remote XML http get *@param 'get' format params (x=y&a=b...) -*@who object which is providing a specific callbacks for this request -*@complete the name of the function which must be defined in the callers.handler[] array -*@failure the name of the function which must be defined in the callers.handler[] array +*@who object to handle callbacks for this request +*@complete the function to be called on success +*@failure the function to be called on failure * * example usage from a caller: * -* this.handlers["caps"] = function(request){..} -* OpenLayers.loadURL(url,params,this,"caps"); +* caps: function(request) { +* -blah- +* }, +* +* OpenLayers.loadURL(url,params,this,caps); * * Notice the above example does not provide an error handler; a default empty -* handler is provided which merely logs the error if a failure handler is not supplied +* handler is provided which merely logs the error if a failure handler is not +* supplied * */ @@ -55,31 +57,18 @@ OpenLayers.loadURL = function(uri, params, caller, // ol.Log.debug("loadURL [" + uri + "]"); - var successx; - var failurex; - var bind1 = null; - var bind2 = null; + var success = (onComplete) ? onComplete.bind(caller) + : OpenLayers.nullHandler; - if (onComplete) { - successx = caller.handlers[onComplete]; - bind1 = caller; - } else { - successx = OpenLayers.nullHandler; - } - - if (onFailure) { - failurex = caller.handlers[onFailure]; - bind2=caller; - } else { - failurex = OpenLayers.nullHandler; - } + var failure = (onFailure) ? onFailure.bind(caller) + : OpenLayers.nullHandler; // from prototype.js new Ajax.Request(uri, { method: 'get', parameters: params, - onComplete: successx.bind(bind1), - onFailure: failurex.bind(bind2) + onComplete: success, + onFailure: failure } ); }; diff --git a/lib/OpenLayers/Tile/WFS.js b/lib/OpenLayers/Tile/WFS.js index c44fa45ea9..a0cba4b509 100644 --- a/lib/OpenLayers/Tile/WFS.js +++ b/lib/OpenLayers/Tile/WFS.js @@ -26,16 +26,13 @@ OpenLayers.Tile.WFS.prototype = OpenLayers.Tile.prototype.initialize.apply(this, arguments); this.features = new Array(); - - this.handlers = new Array(); - this.handlers["requestSuccess"] = this.requestSuccess; }, /** */ draw:function() { OpenLayers.Tile.prototype.draw.apply(this, arguments); - this.loadFeaturesForRegion("requestSuccess"); + this.loadFeaturesForRegion(this.requestSuccess); },