Array.indexOf(), though implemented in FF, is not standard javascript. we replace it with OpenLayers.Util.indexOf(), replace all usage

git-svn-id: http://svn.openlayers.org/trunk/openlayers@1596 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-10-05 16:28:24 +00:00
parent d81c2f0187
commit 07ef71b7b0
4 changed files with 21 additions and 4 deletions
+1 -1
View File
@@ -243,7 +243,7 @@ OpenLayers.Layer.Grid.prototype =
var iRow = 0; var iRow = 0;
var iCell = -1; var iCell = -1;
var direction = directions.indexOf("right"); var direction = OpenLayers.Util.indexOf(directions, "right");
var directionsTried = 0; var directionsTried = 0;
while( directionsTried < directions.length) { while( directionsTried < directions.length) {
+1 -1
View File
@@ -359,7 +359,7 @@ OpenLayers.Map.prototype = {
if (newBaseLayer != oldBaseLayer) { if (newBaseLayer != oldBaseLayer) {
// is newBaseLayer an already loaded layer? // is newBaseLayer an already loaded layer?
if (this.layers.indexOf(newBaseLayer) != -1) { if (OpenLayers.Util.indexOf(this.layers, newBaseLayer) != -1) {
// make the old base layer invisible // make the old base layer invisible
if (oldBaseLayer != null) { if (oldBaseLayer != null) {
+15
View File
@@ -60,6 +60,21 @@ OpenLayers.Util.clearArray = function(array) {
array.length = 0; array.length = 0;
}; };
/** Seems to exist already in FF, but not in MOZ.
*
* @param {Array} array
* @param {Object} obj
*/
OpenLayers.Util.indexOf = function(array, obj) {
for(var i=0; i < array.length; i++) {
if (array[i] == obj) return i;
}
return -1;
};
/** /**
* @param {String} id * @param {String} id
* @param {OpenLayers.Pixel} px * @param {OpenLayers.Pixel} px
+4 -2
View File
@@ -125,7 +125,8 @@
map.setCenter(new OpenLayers.LonLat(0, 0), 0); map.setCenter(new OpenLayers.LonLat(0, 0), 0);
map.addPopup(popup); map.addPopup(popup);
t.eq(map.popups.indexOf(popup), 0, "popup successfully added to Map's internal popups array"); var pIndex = OpenLayers.Util.indexOf(map.popups, popup);
t.eq(pIndex, 0, "popup successfully added to Map's internal popups array");
var nodes = map.layerContainerDiv.childNodes; var nodes = map.layerContainerDiv.childNodes;
@@ -140,7 +141,8 @@
map.removePopup(popup); map.removePopup(popup);
t.eq(map.popups.indexOf(popup), -1, "popup successfully removed from Map's internal popups array"); var pIndex = OpenLayers.Util.indexOf(map.popups, popup);
t.eq(pIndex, -1, "popup successfully removed from Map's internal popups array");
var found = false; var found = false;
for (var i=0; i < nodes.length; i++) { for (var i=0; i < nodes.length; i++) {