[Mapbender-commits] r2077 - branches/2.5/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Feb 11 09:15:32 EST 2008
Author: christoph
Date: 2008-02-11 09:15:32 -0500 (Mon, 11 Feb 2008)
New Revision: 2077
Modified:
branches/2.5/http/javascripts/map.js
Log:
bug in clone object (faulty array handling)
removed draft for event class (now in event.js and core.js)
Modified: branches/2.5/http/javascripts/map.js
===================================================================
--- branches/2.5/http/javascripts/map.js 2008-02-08 14:25:07 UTC (rev 2076)
+++ branches/2.5/http/javascripts/map.js 2008-02-11 14:15:32 UTC (rev 2077)
@@ -1948,21 +1948,31 @@
***************************************************************************************
*/
-function cloneObject(someObject){
- var clone = [];
-
- for (attribute in someObject) {
-
- var currentElement = someObject[attribute];
-
- if (typeof(currentElement) == "object") {
- clone[attribute] = cloneObject(currentElement);
- }
- else {
- clone[attribute] = currentElement;
- }
- }
- return clone;
+function cloneObject(obj) {
+ if (typeof obj !== 'object' || obj == null) {
+ return obj;
+ }
+ var c = obj instanceof Array ? [] : {};
+ for (var i in obj) {
+ var prop = obj[i];
+ if (typeof prop == 'object') {
+ if (prop instanceof Array) {
+ c[i] = [];
+ for (var j = 0; j < prop.length; j++) {
+ if (typeof prop[j] != 'object') {
+ c[i].push(prop[j]);
+ } else {
+ c[i].push(cloneObject(prop[j]));
+ }
+ }
+ } else {
+ c[i] = cloneObject(prop);
+ }
+ } else {
+ c[i] = prop;
+ }
+ }
+ return c;
}
@@ -2078,56 +2088,7 @@
};
-
/*
- * first draft of a redesign
- *
-var FunctionArray = function() {
- this.list = [];
-
- this.register = function (aFunction) {
- this.add(aFunction);
- }
- this.execute = function () {
- for (var i = 0; i < this.count(); i++) {
- var aFunction = this.get(i);
- if (typeof(aFunction) == 'function') {
- aFunction();
- }
- else if (typeof(aFunction) == 'string') {
- eval(aFunction);
- }
- else {
- var e = new mb_exception("FunctionArray.execute: Invalid parameter: " + aFunction);
- }
- }
- }
- this.remove = function (functionString) {
- var listLength = this.count();
- for (var i = listLength - 1; i >= 0; i--) {
- if (this.get(i) == functionString){
- this.del(i);
- }
- }
- }
-}
-
-FunctionArray.prototype = new List();
-
-var mbInitFunctions = new FunctionArray();
-var mbMapRequestSubFunctions = new FunctionArray();
-var mbWfsReadSubFunctions = new FunctionArray();
-var mbWfsWriteSubFunctions = new FunctionArray();
-var mbMapRequestPreFunctions = new FunctionArray();
-var mbFeatureInfoPreFunctions = new FunctionArray();
-var mbInitFunctions = new FunctionArray();
-var mbMapObjectSubFunctions = new FunctionArray();
-var mbGetScalePreFunctions = new FunctionArray();
-var mbloadWmsSubFunctions = new FunctionArray();
-
-*/
-
-/*
***************************************************************************************
* deprecated functions
***************************************************************************************
More information about the Mapbender_commits
mailing list