[Mapbender-commits] r3902 - branches/2.5/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Apr 21 06:01:36 EDT 2009


Author: christoph
Date: 2009-04-21 06:01:35 -0400 (Tue, 21 Apr 2009)
New Revision: 3902

Modified:
   branches/2.5/http/javascripts/geometry.js
   branches/2.5/http/javascripts/map.js
Log:
http://trac.osgeo.org/mapbender/ticket/418

Modified: branches/2.5/http/javascripts/geometry.js
===================================================================
--- branches/2.5/http/javascripts/geometry.js	2009-04-21 09:58:38 UTC (rev 3901)
+++ branches/2.5/http/javascripts/geometry.js	2009-04-21 10:01:35 UTC (rev 3902)
@@ -1016,7 +1016,7 @@
 	 * @type Integer
 	 */
 	this.count = function(){
-		return name.length;
+		return this.name.length;
 	};
 
 	/**
@@ -1027,7 +1027,7 @@
 	 * @type String
 	 */
 	this.getName = function(i){ 
-		if (isValidElementIndex(i)) {return name[i];}
+		if (this.isValidElementIndex(i)) {return this.name[i];}
 		return false;
 	};
 	
@@ -1038,7 +1038,7 @@
 	 * @return the value
 	 */
 	this.getValue = function(i){ 
-		if (isValidElementIndex(i)) {return value[i];}
+		if (this.isValidElementIndex(i)) {return this.value[i];}
 		return false;
 	};
 
@@ -1051,8 +1051,8 @@
 	this.setElement = function(aName, aValue){ 
 		var i = this.getElementIndexByName(aName);
 		if (i === false) {i = this.count();}
-		name[i] = aName;
-		value[i] = aValue;
+		this.name[i] = aName;
+		this.value[i] = aValue;
 	};
 
 	/**
@@ -1063,8 +1063,8 @@
 	this.delElement = function(aName){
 		var i = this.getElementIndexByName(aName);
 		if (i !== false) {
-			name.splice(i, 1);
-			value.splice(i, 1);
+			this.name.splice(i, 1);
+			this.value.splice(i, 1);
 		}
 	}
 	
@@ -1076,14 +1076,14 @@
 	 * @return true if the index is valid; otherwise false
 	 * @type Boolean
 	 */
-	var isValidElementIndex = function(i){ 
-		if (i>=0 && i<name.length) {return true;}
+	this.isValidElementIndex = function(i){ 
+		if (i>=0 && i<this.name.length) {return true;}
 		var e = new Mb_exception("class Wfs_element: function isValidElementIndex: illegal element index");
 		return false;
 	};
 	
-	var name  = [];
-	var value = [];
+	this.name  = [];
+	this.value = [];
 }
 
 /**

Modified: branches/2.5/http/javascripts/map.js
===================================================================
--- branches/2.5/http/javascripts/map.js	2009-04-21 09:58:38 UTC (rev 3901)
+++ branches/2.5/http/javascripts/map.js	2009-04-21 10:01:35 UTC (rev 3902)
@@ -2024,34 +2024,20 @@
  ***************************************************************************************
  */
 
-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;
+function cloneObject (p, c) {
+	var c = c || {};
+	for (var i in p) {
+		if (typeof p[i] === 'object') {
+			c[i] = (p[i].constructor === Array) ? [] : {};
+			cloneObject(p[i], c[i]);
+		}
+		else {
+			c[i] = p[i];
+		}
+	}
+	return c;
 }
 
-
 /**
  * @class A List object is an array of arbitrary objects with additional methods. 
  *



More information about the Mapbender_commits mailing list