as universally approved on discussions on dev list, replace new Array() with []. all tests pass ff & ie6

git-svn-id: http://svn.openlayers.org/trunk/openlayers@3815 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2007-07-25 22:48:02 +00:00
parent 5f0bde51da
commit 8c552be94b
22 changed files with 44 additions and 44 deletions
+1 -1
View File
@@ -165,7 +165,7 @@ OpenLayers.Control.LayerSwitcher = OpenLayers.Class(OpenLayers.Control, {
} }
} }
this[layersType + "LayersDiv"].innerHTML = ""; this[layersType + "LayersDiv"].innerHTML = "";
this[layersType + "Layers"] = new Array(); this[layersType + "Layers"] = [];
}, },
+1 -1
View File
@@ -83,7 +83,7 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
* control, set <mapOptions> as one of the options properties. * control, set <mapOptions> as one of the options properties.
*/ */
initialize: function(options) { initialize: function(options) {
this.layers = new Array(); this.layers = [];
OpenLayers.Control.prototype.initialize.apply(this, [options]); OpenLayers.Control.prototype.initialize.apply(this, [options]);
}, },
+1 -1
View File
@@ -69,7 +69,7 @@ OpenLayers.Control.PanZoom = OpenLayers.Class(OpenLayers.Control, {
px = this.position; px = this.position;
// place the controls // place the controls
this.buttons = new Array(); this.buttons = [];
var sz = new OpenLayers.Size(18,18); var sz = new OpenLayers.Size(18,18);
var centered = new OpenLayers.Pixel(px.x+sz.w/2, px.y); var centered = new OpenLayers.Pixel(px.x+sz.w/2, px.y);
+1 -1
View File
@@ -111,7 +111,7 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
px = this.position.clone(); px = this.position.clone();
// place the controls // place the controls
this.buttons = new Array(); this.buttons = [];
var sz = new OpenLayers.Size(18,18); var sz = new OpenLayers.Size(18,18);
var centered = new OpenLayers.Pixel(px.x+sz.w/2, px.y); var centered = new OpenLayers.Pixel(px.x+sz.w/2, px.y);
+3 -3
View File
@@ -187,7 +187,7 @@ OpenLayers.Event = {
//if there is not yet a hash entry for this element, add one //if there is not yet a hash entry for this element, add one
if (!this.observers[cacheID]) { if (!this.observers[cacheID]) {
this.observers[cacheID] = new Array(); this.observers[cacheID] = [];
} }
//add a new observer to this element's list //add a new observer to this element's list
@@ -445,7 +445,7 @@ OpenLayers.Events = OpenLayers.Class({
*/ */
addEventType: function(eventName) { addEventType: function(eventName) {
if (!this.listeners[eventName]) { if (!this.listeners[eventName]) {
this.listeners[eventName] = new Array(); this.listeners[eventName] = [];
} }
}, },
@@ -573,7 +573,7 @@ OpenLayers.Events = OpenLayers.Class({
*/ */
remove: function(type) { remove: function(type) {
if (this.listeners[type] != null) { if (this.listeners[type] != null) {
this.listeners[type] = new Array(); this.listeners[type] = [];
} }
}, },
+1 -1
View File
@@ -48,7 +48,7 @@ OpenLayers.Geometry.Collection = OpenLayers.Class(OpenLayers.Geometry, {
*/ */
initialize: function (components) { initialize: function (components) {
OpenLayers.Geometry.prototype.initialize.apply(this, arguments); OpenLayers.Geometry.prototype.initialize.apply(this, arguments);
this.components = new Array(); this.components = [];
if (components != null) { if (components != null) {
this.addComponents(components); this.addComponents(components);
} }
+3 -3
View File
@@ -588,7 +588,7 @@ OpenLayers.Layer = OpenLayers.Class({
if ((confProps.scales != null) || (confProps.resolutions != null)) { if ((confProps.scales != null) || (confProps.resolutions != null)) {
//preset levels //preset levels
if (confProps.scales != null) { if (confProps.scales != null) {
confProps.resolutions = new Array(); confProps.resolutions = [];
for(var i = 0; i < confProps.scales.length; i++) { for(var i = 0; i < confProps.scales.length; i++) {
var scale = confProps.scales[i]; var scale = confProps.scales[i];
confProps.resolutions[i] = confProps.resolutions[i] =
@@ -601,7 +601,7 @@ OpenLayers.Layer = OpenLayers.Class({
} else { } else {
//maxResolution and numZoomLevels based calculation //maxResolution and numZoomLevels based calculation
confProps.resolutions = new Array(); confProps.resolutions = [];
// determine maxResolution // determine maxResolution
if (confProps.minScale) { if (confProps.minScale) {
@@ -658,7 +658,7 @@ OpenLayers.Layer = OpenLayers.Class({
var lastIndex = confProps.resolutions.length - 1; var lastIndex = confProps.resolutions.length - 1;
this.minResolution = confProps.resolutions[lastIndex]; this.minResolution = confProps.resolutions[lastIndex];
this.scales = new Array(); this.scales = [];
for(var i = 0; i < confProps.resolutions.length; i++) { for(var i = 0; i < confProps.resolutions.length; i++) {
this.scales[i] = this.scales[i] =
OpenLayers.Util.getScaleFromResolution(confProps.resolutions[i], OpenLayers.Util.getScaleFromResolution(confProps.resolutions[i],
+1 -1
View File
@@ -38,7 +38,7 @@ OpenLayers.Layer.GML = OpenLayers.Class(OpenLayers.Layer.Vector, {
* options - {Object} Hashtable of extra options to tag onto the layer. * options - {Object} Hashtable of extra options to tag onto the layer.
*/ */
initialize: function(name, url, options) { initialize: function(name, url, options) {
var newArguments = new Array() var newArguments = [];
newArguments.push(name, options); newArguments.push(name, options);
OpenLayers.Layer.Vector.prototype.initialize.apply(this, newArguments); OpenLayers.Layer.Vector.prototype.initialize.apply(this, newArguments);
this.url = url; this.url = url;
+1 -1
View File
@@ -53,7 +53,7 @@ OpenLayers.Layer.GeoRSS = OpenLayers.Class(OpenLayers.Layer.Markers, {
initialize: function(name, location, options) { initialize: function(name, location, options) {
OpenLayers.Layer.Markers.prototype.initialize.apply(this, [name, options]); OpenLayers.Layer.Markers.prototype.initialize.apply(this, [name, options]);
this.location = location; this.location = location;
this.features = new Array(); this.features = [];
OpenLayers.loadURL(location, null, this, this.parseData); OpenLayers.loadURL(location, null, this, this.parseData);
}, },
+5 -5
View File
@@ -68,7 +68,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
// //
this.events.addEventType("tileloaded"); this.events.addEventType("tileloaded");
this.grid = new Array(); this.grid = [];
}, },
/** /**
@@ -129,7 +129,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
} }
// we do not want to copy reference to grid, so we make a new array // we do not want to copy reference to grid, so we make a new array
obj.grid = new Array(); obj.grid = [];
return obj; return obj;
}, },
@@ -269,7 +269,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
var px = this.map.getLayerPxFromLonLat(ul); var px = this.map.getLayerPxFromLonLat(ul);
if (!this.grid.length) { if (!this.grid.length) {
this.grid[0] = new Array(); this.grid[0] = [];
} }
var tile = this.grid[0][0]; var tile = this.grid[0][0];
@@ -331,7 +331,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
do { do {
var row = this.grid[rowidx++]; var row = this.grid[rowidx++];
if (!row) { if (!row) {
row = new Array(); row = [];
this.grid.push(row); this.grid.push(row);
} }
@@ -390,7 +390,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
* outside-in to inside-out), calling draw() on each tile. * outside-in to inside-out), calling draw() on each tile.
*/ */
spiralTileLoad: function() { spiralTileLoad: function() {
var tileQueue = new Array(); var tileQueue = [];
var directions = ["right", "down", "left", "up"]; var directions = ["right", "down", "left", "up"];
+3 -3
View File
@@ -59,7 +59,7 @@ OpenLayers.Layer.KaMap = OpenLayers.Class(OpenLayers.Layer.Grid, {
* extends, can be overridden through the options parameter. * extends, can be overridden through the options parameter.
*/ */
initialize: function(name, url, params, options) { initialize: function(name, url, params, options) {
var newArguments = new Array(); var newArguments = [];
newArguments.push(name, url, params, options); newArguments.push(name, url, params, options);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
this.params = (params ? params : {}); this.params = (params ? params : {});
@@ -150,7 +150,7 @@ OpenLayers.Layer.KaMap = OpenLayers.Class(OpenLayers.Layer.Grid, {
row = this.grid[rowidx++]; row = this.grid[rowidx++];
if (!row) { if (!row) {
row = new Array(); row = [];
this.grid.push(row); this.grid.push(row);
} }
@@ -221,7 +221,7 @@ OpenLayers.Layer.KaMap = OpenLayers.Class(OpenLayers.Layer.Grid, {
} }
// we do not want to copy reference to grid, so we make a new array // we do not want to copy reference to grid, so we make a new array
obj.grid = new Array(); obj.grid = [];
return obj; return obj;
}, },
+1 -1
View File
@@ -36,7 +36,7 @@ OpenLayers.Layer.MapServer = OpenLayers.Class(OpenLayers.Layer.Grid, {
* options - {Ojbect} Hashtable of extra options to tag onto the layer * options - {Ojbect} Hashtable of extra options to tag onto the layer
*/ */
initialize: function(name, url, params, options) { initialize: function(name, url, params, options) {
var newArguments = new Array(); var newArguments = [];
newArguments.push(name, url, params, options); newArguments.push(name, url, params, options);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
+1 -1
View File
@@ -45,7 +45,7 @@ OpenLayers.Layer.Markers = OpenLayers.Class(OpenLayers.Layer, {
*/ */
initialize: function(name, options) { initialize: function(name, options) {
OpenLayers.Layer.prototype.initialize.apply(this, arguments); OpenLayers.Layer.prototype.initialize.apply(this, arguments);
this.markers = new Array(); this.markers = [];
}, },
/** /**
+1 -1
View File
@@ -41,7 +41,7 @@ OpenLayers.Layer.TMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
* options - {Object} Hashtable of extra options to tag onto the layer * options - {Object} Hashtable of extra options to tag onto the layer
*/ */
initialize: function(name, url, options) { initialize: function(name, url, options) {
var newArguments = new Array(); var newArguments = [];
newArguments.push(name, url, {}, options); newArguments.push(name, url, {}, options);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
}, },
+3 -3
View File
@@ -121,8 +121,8 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
this.displayError(); this.displayError();
} }
this.features = new Array(); this.features = [];
this.selectedFeatures = new Array(); this.selectedFeatures = [];
}, },
/** /**
@@ -310,7 +310,7 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
* Destroy all features on the layer and empty the selected features array. * Destroy all features on the layer and empty the selected features array.
*/ */
destroyFeatures: function () { destroyFeatures: function () {
this.selectedFeatures = new Array(); this.selectedFeatures = [];
for (var i = this.features.length - 1; i >= 0; i--) { for (var i = this.features.length - 1; i >= 0; i--) {
this.features[i].destroy(); this.features[i].destroy();
} }
+1 -1
View File
@@ -73,7 +73,7 @@ OpenLayers.Layer.WFS = OpenLayers.Class(
// Turn off error reporting, browsers like Safari may work // Turn off error reporting, browsers like Safari may work
// depending on the setup, and we don't want an unneccesary alert. // depending on the setup, and we don't want an unneccesary alert.
OpenLayers.Util.extend(options, {'reportError': false}); OpenLayers.Util.extend(options, {'reportError': false});
var newArguments=new Array() var newArguments = [];
newArguments.push(name, options); newArguments.push(name, options);
OpenLayers.Layer.Vector.prototype.initialize.apply(this, newArguments); OpenLayers.Layer.Vector.prototype.initialize.apply(this, newArguments);
if (!this.renderer || !this.vectorMode) { if (!this.renderer || !this.vectorMode) {
+1 -1
View File
@@ -64,7 +64,7 @@ OpenLayers.Layer.WMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
* options - {Ojbect} Hashtable of extra options to tag onto the layer * options - {Ojbect} Hashtable of extra options to tag onto the layer
*/ */
initialize: function(name, url, params, options) { initialize: function(name, url, params, options) {
var newArguments = new Array(); var newArguments = [];
//uppercase params //uppercase params
params = OpenLayers.Util.upperCaseObject(params); params = OpenLayers.Util.upperCaseObject(params);
newArguments.push(name, url, params, options); newArguments.push(name, url, params, options);
+1 -1
View File
@@ -49,7 +49,7 @@ OpenLayers.Layer.WorldWind = OpenLayers.Class(OpenLayers.Layer.Grid, {
initialize: function(name, url, lzd, zoomLevels, params, options) { initialize: function(name, url, lzd, zoomLevels, params, options) {
this.lzd = lzd; this.lzd = lzd;
this.zoomLevels = zoomLevels; this.zoomLevels = zoomLevels;
var newArguments = new Array(); var newArguments = [];
newArguments.push(name, url, params, options); newArguments.push(name, url, params, options);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
this.params = (params ? params : {}); this.params = (params ? params : {});
+1 -1
View File
@@ -341,7 +341,7 @@ OpenLayers.Map = OpenLayers.Class({
this.addControlToMap(this.controls[i]); this.addControlToMap(this.controls[i]);
} }
this.popups = new Array(); this.popups = [];
this.unloadDestroy = this.destroy.bind(this); this.unloadDestroy = this.destroy.bind(this);
+1 -1
View File
@@ -45,7 +45,7 @@ OpenLayers.Tile.WFS = OpenLayers.Class(OpenLayers.Tile, {
initialize: function(layer, position, bounds, url, size) { initialize: function(layer, position, bounds, url, size) {
OpenLayers.Tile.prototype.initialize.apply(this, arguments); OpenLayers.Tile.prototype.initialize.apply(this, arguments);
this.url = url; this.url = url;
this.features = new Array(); this.features = [];
}, },
/** /**
+4 -4
View File
@@ -13,7 +13,7 @@ OpenLayers.Util = {};
* This is the old $() from prototype * This is the old $() from prototype
*/ */
OpenLayers.Util.getElement = function() { OpenLayers.Util.getElement = function() {
var elements = new Array(); var elements = [];
for (var i = 0; i < arguments.length; i++) { for (var i = 0; i < arguments.length; i++) {
var element = arguments[i]; var element = arguments[i];
@@ -499,7 +499,7 @@ OpenLayers.Util.applyDefaults = function (to, from) {
* of being URL escaped (foo%3Abar). * of being URL escaped (foo%3Abar).
*/ */
OpenLayers.Util.getParameterString = function(params) { OpenLayers.Util.getParameterString = function(params) {
paramsArray = new Array(); paramsArray = [];
for (var key in params) { for (var key in params) {
var value = params[key]; var value = params[key];
@@ -507,7 +507,7 @@ OpenLayers.Util.getParameterString = function(params) {
var encodedValue; var encodedValue;
if (typeof value == 'object' && value.constructor == Array) { if (typeof value == 'object' && value.constructor == Array) {
/* value is an array; encode items and separate with "," */ /* value is an array; encode items and separate with "," */
var encodedItemArray = new Array(); var encodedItemArray = [];
for (var itemIndex=0; itemIndex<value.length; itemIndex++) { for (var itemIndex=0; itemIndex<value.length; itemIndex++) {
encodedItemArray.push(encodeURIComponent(value[itemIndex])); encodedItemArray.push(encodeURIComponent(value[itemIndex]));
} }
@@ -596,7 +596,7 @@ OpenLayers.Util.getNodes=function(p, tagName) {
* {Array} * {Array}
*/ */
OpenLayers.Util._getNodes=function(nodes, tagName) { OpenLayers.Util._getNodes=function(nodes, tagName) {
var retArray = new Array(); var retArray = [];
for (var i=0;i<nodes.length;i++) { for (var i=0;i<nodes.length;i++) {
if (nodes[i].nodeName==tagName) { if (nodes[i].nodeName==tagName) {
retArray.push(nodes[i]); retArray.push(nodes[i]);
+8 -8
View File
@@ -112,7 +112,7 @@
t.ok( bounds.equals(testBounds), "getGridBounds() wrapper works the same as getTilesBounds."); t.ok( bounds.equals(testBounds), "getGridBounds() wrapper works the same as getTilesBounds.");
//no tiles //no tiles
layer.grid = new Array(); layer.grid = [];
bounds = layer.getTilesBounds(); bounds = layer.getTilesBounds();
t.ok(bounds == null, "getTilesBounds() on a tile-less grid returns null"); t.ok(bounds == null, "getTilesBounds() on a tile-less grid returns null");
@@ -207,7 +207,7 @@
//FORCE //FORCE
//empty grid //empty grid
layer.grid = new Array(); layer.grid = [];
//grid //grid
clearTestBounds(); clearTestBounds();
layer.singleTile = false; layer.singleTile = false;
@@ -411,7 +411,7 @@
}; };
layer.grid = new Array(); layer.grid = [];
layer.initSingleTile(bounds); layer.initSingleTile(bounds);
t.ok(layer.grid[0][0] == newTile, "grid's 0,0 is set to the newly created tile"); t.ok(layer.grid[0][0] == newTile, "grid's 0,0 is set to the newly created tile");
@@ -446,7 +446,7 @@
} }
g_registered = {}; g_registered = {};
g_events = new Array(); g_events = [];
layer.addTileMonitoringHooks(tile); layer.addTileMonitoringHooks(tile);
@@ -456,13 +456,13 @@
t.ok( entry && entry[0] == layer && entry[1] == tile.onLoadStart, "loadstart correctly registered"); t.ok( entry && entry[0] == layer && entry[1] == tile.onLoadStart, "loadstart correctly registered");
layer.numLoadingTiles = 0; layer.numLoadingTiles = 0;
g_events = new Array(); g_events = [];
tile.onLoadStart.apply(layer); tile.onLoadStart.apply(layer);
t.eq(g_events[0], "loadstart", "loadstart event triggered when numLoadingTiles is 0"); t.eq(g_events[0], "loadstart", "loadstart event triggered when numLoadingTiles is 0");
t.eq(layer.numLoadingTiles, 1, "numLoadingTiles incremented"); t.eq(layer.numLoadingTiles, 1, "numLoadingTiles incremented");
g_events = new Array(); g_events = [];
tile.onLoadStart.apply(layer); tile.onLoadStart.apply(layer);
t.eq(g_events.length, 0, "loadstart event not triggered when numLoadingTiles is not 0"); t.eq(g_events.length, 0, "loadstart event not triggered when numLoadingTiles is not 0");
t.eq(layer.numLoadingTiles, 2, "numLoadingTiles incremented"); t.eq(layer.numLoadingTiles, 2, "numLoadingTiles incremented");
@@ -474,14 +474,14 @@
t.ok( entry && entry[0] == layer && entry[1] == tile.onLoadEnd, "loadend correctly registered"); t.ok( entry && entry[0] == layer && entry[1] == tile.onLoadEnd, "loadend correctly registered");
layer.numLoadingTiles = 2; layer.numLoadingTiles = 2;
g_events = new Array(); g_events = [];
tile.onLoadEnd.apply(layer); tile.onLoadEnd.apply(layer);
t.eq(g_events[0], "tileloaded", "tileloaded triggered when numLoadingTiles is > 0"); t.eq(g_events[0], "tileloaded", "tileloaded triggered when numLoadingTiles is > 0");
t.eq(g_events.length, 1, "loadend event not triggered when numLoadingTiles is > 0"); t.eq(g_events.length, 1, "loadend event not triggered when numLoadingTiles is > 0");
t.eq(layer.numLoadingTiles, 1, "numLoadingTiles decremented"); t.eq(layer.numLoadingTiles, 1, "numLoadingTiles decremented");
g_events = new Array(); g_events = [];
tile.onLoadEnd.apply(layer); tile.onLoadEnd.apply(layer);
t.eq(g_events[0], "tileloaded", "tileloaded triggered when numLoadingTiles is 0"); t.eq(g_events[0], "tileloaded", "tileloaded triggered when numLoadingTiles is 0");
t.eq(g_events[1], "loadend", "loadend event triggered when numLoadingTiles is 0"); t.eq(g_events[1], "loadend", "loadend event triggered when numLoadingTiles is 0");