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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Feb 19 08:37:57 EST 2008


Author: christoph
Date: 2008-02-19 08:37:57 -0500 (Tue, 19 Feb 2008)
New Revision: 2096

Modified:
   branches/2.5/http/javascripts/map.js
Log:
jslinted

Modified: branches/2.5/http/javascripts/map.js
===================================================================
--- branches/2.5/http/javascripts/map.js	2008-02-18 14:18:16 UTC (rev 2095)
+++ branches/2.5/http/javascripts/map.js	2008-02-19 13:37:57 UTC (rev 2096)
@@ -90,7 +90,7 @@
 
 var mb_security_proxy = "http://wms1.ccgis.de/mapbender/tools/security_proxy.php?mb_ows_security_proxy=";
 
-var mb_trans = new Image; 
+var mb_trans = new Image(); 
 mb_trans.src = "../img/transparent.gif";
 /*END OF GLOBALS*/
 
@@ -209,7 +209,7 @@
 	 * @type integer  
 	 */
 	this.getWidth = function(){
-		return parseInt(this.width);
+		return parseInt(this.width, 10);
 	};
 	
 	/**
@@ -218,7 +218,7 @@
 	 * @param {integer} widht the width of the mapObj  
 	 */
 	this.setWidth = function(width){
-		this.width = parseInt(width);
+		this.width = parseInt(width, 10);
 	};
 	
 	/**
@@ -229,7 +229,7 @@
 	 * @type integer  
 	 */
 	this.getHeight = function(){
-		return parseInt(this.height);
+		return parseInt(this.height, 10);
 	};
 	
 	/**
@@ -238,7 +238,7 @@
 	 * @param {integer} height the height of the mapObj  
 	 */
 	this.setHeight = function(height){
-		this.height = parseInt(height);
+		this.height = parseInt(height, 10);
 	};
 	
 	/**
@@ -322,14 +322,14 @@
 		this.setExtent(minx,miny,maxx,maxy);
 		//Todo:
 		//setMapRequest!
-	 }
+	 };
 
 	/**
 	 * set the extent of the wms
 	 */
 	 this.setExtent = function(minx,miny,maxx,maxy){
 	 	this.extent = String(minx)+","+String(miny)+","+String(maxx)+","+String(maxy);
-	 }
+	 };
 	
 	/**
 	 * get the srs of the mapObj
@@ -444,18 +444,21 @@
 	this.move = function(wms_id, layer_id, moveUp){
 		var i,j;
 		for(i=0;i<this.wms.length;i++){
-			if(wms_id==this.wms[i].wms_id)
+			if (wms_id == this.wms[i].wms_id) {
 				break;
+			}
 		}
 		
 		//check if only one wms is affected?
-		if(layer_id&&layer_id!=this.wms[i].objLayer[0].layer_id)
+		if (layer_id && layer_id != this.wms[i].objLayer[0].layer_id) {
 			return this.wms[i].moveLayer(layer_id, moveUp);
+		}
 		
 		//else swap wms
 		j = i + (moveUp?-1:1);
-		if (!(i != j && i >= 0 && i < this.wms.length && j >= 0 && j < this.wms.length))
+		if (!(i != j && i >= 0 && i < this.wms.length && j >= 0 && j < this.wms.length)) {
 			return false;
+		}
 		
 		upper = this.wms[i];
 		this.wms[i] = this.wms[j];
@@ -471,7 +474,7 @@
 		this.querylayers[j] = upperQuerylayers;
 		
 		return true;
-	}
+	};
 	
 	eventAfterMapObjectConstruction.trigger();
 }
@@ -511,13 +514,17 @@
 		if (fromIndex > toIndex) {
 			for (var i = fromIndex; i > toIndex ; i--) {
 				var result = mb_swapWmsByIndex(mapObj_ind, i-1, i);
-				if (result == true) changed = true;
+				if (result === true) {
+					changed = true;
+				}
 			}
 		}
 		else {
 			for (var i = fromIndex; i < toIndex ; i++) {
 				var result = mb_swapWmsByIndex(mapObj_ind, i, i+1);
-				if (result == true) changed = true;
+				if (result === true) {
+					changed = true;
+				}
 			}
 		}
 		return changed;
@@ -579,8 +586,8 @@
 	var ind = getMapObjIndexByName(obj);
 	//is the id valid?
 	for( var i=0; i<(wms.length-1); i++){
-		if(parseInt(wms[i].wms_id) >= parseInt(wms[wms.length-1].wms_id)){
-			wms[wms.length-1].wms_id = parseInt(mb_mapObj[ind].wms[i].wms_id) + 1;
+		if(parseInt(wms[i].wms_id, 10) >= parseInt(wms[wms.length-1].wms_id, 10)){
+			wms[wms.length-1].wms_id = parseInt(mb_mapObj[ind].wms[i].wms_id, 10) + 1;
 		}
 	} 
 	mb_mapObj[ind].wms[mb_mapObj[ind].wms.length] = wms[wms.length-1];
@@ -616,7 +623,7 @@
 			new_layerarray[new_layerarray.length] = mb_mapObj[objind].layers[i];
 			new_querylayerarray[new_querylayerarray.length] = mb_mapObj[objind].querylayers[i];
 			new_stylesarray[new_stylesarray.length] = mb_mapObj[objind].styles[i];
-			new_mapURLarray[new_mapURLarray.length] = mb_mapObj[objind].mapURL[i] 
+			new_mapURLarray[new_mapURLarray.length] = mb_mapObj[objind].mapURL[i];
 		}
 		else {
 			wms_ID = mb_mapObj[objind].wms[i].wms_id;
@@ -692,7 +699,7 @@
 					//disable Layer which are out of scale
 					var validLayers = mb_checkScale(frameName,i,ii);
 					var layerNames = validLayers.toString();
-					if(mb_mapObj[i].layers[ii] != "" && validLayers != ''){
+					if(mb_mapObj[i].layers[ii] !== "" && validLayers !== ''){
 						var newMapURL = "";
 
 						if (mb_mapObj[i].wms[ii].gui_wms_mapopacity != 1) {
@@ -725,7 +732,7 @@
 							if(j>0){
 								newMapURL  += ",";
 							}
-							if(mb_mapObj[i].wms[ii].getCurrentStyleByLayerName(layer[j])==false){
+							if(mb_mapObj[i].wms[ii].getCurrentStyleByLayerName(layer[j]) === false){
 								newMapURL  += "";
 							}
 							else{
@@ -756,14 +763,14 @@
 							}
 						}           
 						// add Filter
-						if(mb_mapObj[i].wms[ii].wms_filter != ""){
+						if(mb_mapObj[i].wms[ii].wms_filter !== ""){
 							var tmp = mb_mapObj[i].wms[ii].wms_filter +"?id="+ mb_styleID;
 
 							var temp = "&SLD=" + tmp+ "&";
 							newMapURL += temp;
 						}
 						// add sld
-						if(mb_mapObj[i].wms[ii].gui_wms_sldurl != ""){
+						if(mb_mapObj[i].wms[ii].gui_wms_sldurl !== ""){
 							//alert(mb_mapObj[i].wms[ii].gui_wms_sldurl);
 							var temp = "&SLD=" + escape(mb_mapObj[i].wms[ii].gui_wms_sldurl) + "&";
 							newMapURL += temp;
@@ -835,7 +842,7 @@
 						if(j>0){
 							newMapURL  += ",";
 						}
-						if(mb_mapObj[i].wms[ii].getCurrentStyleByLayerName(layer[j])==false){
+						if(mb_mapObj[i].wms[ii].getCurrentStyleByLayerName(layer[j])===false){
 							newMapURL  += "";
 						}
 						else{
@@ -865,21 +872,21 @@
 						} 
 					}
 					// add Filter
-					if(mb_mapObj[i].wms[ii].wms_filter != ""){
+					if(mb_mapObj[i].wms[ii].wms_filter !== ""){
 						var tmp = mb_mapObj[i].wms[ii].wms_filter +"?id="+ mb_styleID;
 						//prompt("",tmp);;
 						var temp = "&SLD=" + tmp+ "&";
 						newMapURL += temp;
 					}
 					// add sld
-					if(mb_mapObj[i].wms[ii].gui_wms_sldurl != ""){
+					if(mb_mapObj[i].wms[ii].gui_wms_sldurl !== ""){
 						//alert(mb_mapObj[i].wms[ii].gui_wms_sldurl);
 						var temp = "&SLD=" + escape(mb_mapObj[i].wms[ii].gui_wms_sldurl) + "&";
 						newMapURL += temp;
 					}
 
 					//prompt("",newMapURL);
-					if(mb_mapObj[i].layers[ii] != "" && layerNames!=''){
+					if(mb_mapObj[i].layers[ii] !== "" && layerNames!==''){
 						newMapRequest += newMapURL;
 						mb_mapObj[i].mapURL[ii] = newMapURL;
 						mb_mapObj[i].wms[ii].mapURL = newMapURL;
@@ -951,9 +958,9 @@
 			var minscaleOK = false;
 			var maxscaleOK = false;   
 			if(thisLayer[ii] == myLayername){
-				if(myMinscale == 0 || thisScale >= myMinscale){minscaleOK = true;}
-				if(myMaxscale == 0 || thisScale <= myMaxscale){maxscaleOK = true;}
-				if(maxscaleOK == true && minscaleOK == true ){
+				if(myMinscale === 0 || thisScale >= myMinscale){minscaleOK = true;}
+				if(myMaxscale === 0 || thisScale <= myMaxscale){maxscaleOK = true;}
+				if(maxscaleOK === true && minscaleOK === true ){
 					if(cnt_layer > 0){str_layer += ","; }//str_styles += ","; str_titles += ",";str_parent += ","; str_legendurls += ",";}
 					str_layer += thisLayer[ii];
 					cnt_layer++;
@@ -1002,7 +1009,7 @@
 				requestParams += "X=" + x  + "&";
 				requestParams += "Y=" + y;
 				
-				if(mb_mapObj[i].querylayers[ii] != "" && mb_mapObj[i].layers[ii] != ""){
+				if(mb_mapObj[i].querylayers[ii] !== "" && mb_mapObj[i].layers[ii] !== ""){
 					validation = true;
 				}
 				//add vendor-specific
@@ -1016,15 +1023,15 @@
 				if(document.getElementById("FeatureInfoRedirect") && validation){
 					newfeatureInfoRequest += requestParams;
 					if(path){
-						window.frames["FeatureInfoRedirect"].document.getElementById(mb_mapObj[i].wms[ii].wms_id).src = path + "?url=" + escape(newfeatureInfoRequest)+"&"+mb_nr;
+						window.frames.FeatureInfoRedirect.document.getElementById(mb_mapObj[i].wms[ii].wms_id).src = path + "?url=" + escape(newfeatureInfoRequest)+"&"+mb_nr;
 					}
 					else{
-						window.frames["FeatureInfoRedirect"].document.getElementById(mb_mapObj[i].wms[ii].wms_id).src = newfeatureInfoRequest;
+						window.frames.FeatureInfoRedirect.document.getElementById(mb_mapObj[i].wms[ii].wms_id).src = newfeatureInfoRequest;
 					}
 					cnt_fi++;
             	}
 				else if(path && validation){
-					newfeatureInfoRequest += requestParams
+					newfeatureInfoRequest += requestParams;
 					try{
 						var p = new mb_popup("Feature Info","url:"+path + "?url=" + escape(newfeatureInfoRequest)+"&"+mb_nr,300,400);
 						p.show();
@@ -1036,7 +1043,7 @@
 				else if(validation){
 					newfeatureInfoRequest += requestParams;
 					try{
-						var p = new  mb_popup("Feature Info","url:"+newfeatureInfoRequest,300,400);
+						var p = new mb_popup("Feature Info","url:"+newfeatureInfoRequest,300,400);
 						p.show();
 					}
 					catch(e){
@@ -1047,7 +1054,9 @@
 			}
 		}
 	}
-   	if(cnt_fi == 0){alert(unescape("Please select a layer! \n Bitte waehlen Sie eine Ebene zur Abfrage aus!"));}
+   	if(cnt_fi === 0){
+		alert(unescape("Please select a layer! \n Bitte waehlen Sie eine Ebene zur Abfrage aus!"));
+	}
 }
 
 /*
@@ -1172,12 +1181,12 @@
 				for(var ii=0; ii<mb_mapObj[ind].wms[i].objLayer.length; ii++){
 					if(mb_mapObj[ind].wms[i].wms_id == array_wms[j] && mb_mapObj[ind].wms[i].objLayer[ii].layer_name == array_layer[j]){
 						if(type == "visible"){
-							mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_visible = parseInt(status);
+							mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_visible = parseInt(status, 10);
 							//alert(mb_mapObj[ind].wms[i].objLayer[ii].layer_name);
 							check = true;
 						}
                         if(type == "querylayer" && (mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_queryable == "1" || mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_queryable == 1)){
-							mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_querylayer = parseInt(status);
+							mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_querylayer = parseInt(status, 10);
 						}
 					}
 				}
@@ -1186,7 +1195,7 @@
                 /*
                 * hier noch checken, welche wms sich geaendert haben und disctinct eine singleRequest aufrufen:
                 */ 
-                if(check == true){					
+                if(check === true){					
                     
                     if(mb_mapObj[ind].wms[i].gui_wms_visible == 1){
 						setSingleMapRequest(mapObj,mb_mapObj[ind].wms[i].wms_id);
@@ -1200,8 +1209,8 @@
 
 function makeClickPos2RealWorldPos(frameName, myClickX, myClickY) {
 	var ind = getMapObjIndexByName(frameName);
-	var width = parseInt(mb_mapObj[ind].width);
-	var height = parseInt(mb_mapObj[ind].height);
+	var width = parseInt(mb_mapObj[ind].width, 10);
+	var height = parseInt(mb_mapObj[ind].height, 10);
 	var arrayBBox = mb_mapObj[ind].extent.split(",");
 	var minX = parseFloat(arrayBBox[0]);
 	var minY = parseFloat(arrayBBox[1]);
@@ -1227,7 +1236,7 @@
 	var posY = parseFloat(maxY - (myClickY / height) * xtenty);
 	posX = Math.round(posX * roundx)/roundx;
 	posY = Math.round(posY * roundy)/roundy;
-	return new Array(posX, posY);
+	return [posX, posY];
 }
 
 function makeRealWorld2mapPos(frameName,rw_posx, rw_posy){
@@ -1242,7 +1251,7 @@
 }
 
 function mb_arrangeElement(frameName, elName, left, top) {
-   if(frameName != ""){
+   if(frameName !== ""){
       window.frames[frameName].document.getElementById(elName).style.top = top;
       window.frames[frameName].document.getElementById(elName).style.left = left;
    }
@@ -1274,7 +1283,7 @@
         clickY = e.pageY;
      }
   }
-  var pos = new Array(clickX,clickY);
+  var pos = [clickX,clickY];
   return pos;
 }
 // function for object-identification 
@@ -1353,7 +1362,7 @@
 
 function mb_repaintScale(frameName, x, y, scale){
    var ind = getMapObjIndexByName(frameName);
-   if(x == null && y == null){
+   if(x === null && y === null){
       var arrayBBox = mb_mapObj[ind].extent.split(",");
       x = parseFloat(arrayBBox[0]) + ((parseFloat(arrayBBox[2]) - parseFloat(arrayBBox[0]))/2);
       y = parseFloat(arrayBBox[1]) + ((parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]))/2);
@@ -1478,21 +1487,21 @@
 	var t = mb_mapObj[objInd].wms[wmsInd];
 	var pos = mb_getlayerposbyname(objInd, wmsInd,lname);
 	var l = [];
-	l["name"] = [];
-	l["title"] = [];
-	l["legendurl"] = [];
+	l.name = [];
+	l.title = [];
+	l.legendurl = [];
 	for(var i=0; i < t.objLayer.length; i++){
 		if(t.objLayer[i].layer_parent == pos){
-			l["name"][l["name"].length] = t.objLayer[i].layer_name;
-			l["title"][l["title"].length] = t.objLayer[i].layer_title;
+			l.name[l.name.length] = t.objLayer[i].layer_name;
+			l.title[l.title.length] = t.objLayer[i].layer_title;
 			if(t.objLayer[i].layer_style.length>0){
-				l["legendurl"][l["legendurl"].length] = t.objLayer[i].layer_style[0]["legendurl"] ;
+				l.legendurl[l.legendurl.length] = t.objLayer[i].layer_style[0].legendurl;
 			}else{
-				l["legendurl"][l["legendurl"].length] = 0 ;
+				l.legendurl[l.legendurl.length] = 0 ;
 			}
 		}
 	}
-	if(l["name"].length > 0){
+	if(l.name.length > 0){
 		return l;
 	}
 	else{
@@ -1557,7 +1566,7 @@
 			}
 		}
 		return newString;
-	}
+	};
 	
 	/**
 	 * @private
@@ -1574,7 +1583,7 @@
 				}
 			}
 		}
-	}
+	};
 	
 	/**
 	 * @private
@@ -1686,7 +1695,7 @@
 			}
 		}
 	};
-}	
+};	
 
 /**
  *  class for exception logging
@@ -1792,15 +1801,15 @@
 function mb_regButton_frame(wii, frameName, param){
 	var ind = mb_button.length;
 	mb_button[ind] = new mb_conButton(wii, ind);
-	if (frameName == null) {
-		if (param == null) {
+	if (frameName === null) {
+		if (param === null) {
 			eval(wii+"("+ind+")");
 		}
 		else {
 			eval(wii+"("+ind+", "+param+")");
 		}
 	}
-	else if (param == null) {
+	else if (param === null) {
 		eval("window.frames['" + frameName + "']."+wii+"("+ind+")");
 	}
 	else {
@@ -1808,10 +1817,16 @@
 	}
 	mb_button[ind].prev = mb_button[ind].src;
 	mb_button[ind].src = mb_button[ind].img_off;
-	mb_button[ind].onmouseover = new Function("mb_button_over("+ind+")");
-	mb_button[ind].onmouseout = new Function("mb_button_out("+ind+")");
-	mb_button[ind].onclick = new Function("mb_button_click("+ind+")");
-	if (frameName==null) {
+	mb_button[ind].onmouseover = function () {
+		mb_button_over(ind);
+	};
+	mb_button[ind].onmouseout = function(){
+		mb_button_out(ind);
+	};
+	mb_button[ind].onclick = function(){
+		mb_button_click(ind);
+	};
+	if (frameName === null) {
 		mb_button[ind].frameName = "";
 	}
 	else {
@@ -1828,7 +1843,7 @@
    return true;
 }
 function mb_button_over(ind){
-   if(mb_button[ind].status == 0){
+   if(mb_button[ind].status === 0){
       mb_button[ind].prev = mb_button[ind].src;
       mb_button[ind].src = mb_button[ind].img_over;
    }
@@ -1838,12 +1853,12 @@
 }
 function mb_button_click(ind){
    var mbStatus = mb_button[ind].status;
-   if(mbStatus == 0){
+   if(mbStatus === 0){
       mb_disableButton(mb_button[ind].elName);
       mb_button[ind].prev = mb_button[ind].img_on;
       mb_button[ind].src = mb_button[ind].img_on;
       mb_button[ind].status = 1;
-      if (mb_button[ind].frameName != "") {
+      if (mb_button[ind].frameName !== "") {
           window.frames[mb_button[ind].frameName].document.getElementById(mb_button[ind].elName).go();
       }
       else {
@@ -1854,7 +1869,7 @@
       mb_button[ind].prev = mb_button[ind].img_off;
       mb_button[ind].src = mb_button[ind].img_off;
       mb_button[ind].status = 0;      
-      if (mb_button[ind].frameName != "") {
+      if (mb_button[ind].frameName !== "") {
           window.frames[mb_button[ind].frameName].document.getElementById(mb_button[ind].elName).stop();
       }
       else {
@@ -1866,7 +1881,7 @@
    for(var i=0; i<mb_button.length; i++){
       if(mb_button[i].elName != elName && mb_button[i].status == 1){
             mb_button[i].status = 0;
-		      if (mb_button[i].frameName != "") {
+		      if (mb_button[i].frameName !== "") {
     	        window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
 	            window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).stop();
 		      }
@@ -1884,7 +1899,7 @@
       if(mb_button[i].elName == elName && mb_button[i].status == 1){
       		//alert(mb_button[i].elName);
             mb_button[i].status = 0;
-		      if (mb_button[i].frameName != "") {
+		      if (mb_button[i].frameName !== "") {
     	        window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
 	            window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).stop();
 		      }
@@ -1904,7 +1919,7 @@
 		for(var j=0; j<obj.length; j++){
 //			console.log("%s %s", mb_button[i].elName, obj[j].id);
 			if (mb_button[i].elName == obj[j].id) {
-				if (mb_button[i].frameName != "") {
+				if (mb_button[i].frameName !== "") {
 					window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).title = obj[j].title;
 				}
 				else {
@@ -1929,7 +1944,7 @@
  */
 
 function cloneObject(obj) { 
-    if (typeof obj !== 'object' || obj == null) {
+    if (typeof obj !== 'object' || obj === null) {
         return obj;
     }
     var c = obj instanceof Array ? [] : {};
@@ -1994,10 +2009,10 @@
 	 * empties this {@link List}
 	 */
 	this.empty = function() {
-		while (this.list != null && this.count() > 0) {
+		while (this.list !== null && this.count() > 0) {
 			this.list.pop();
 		}
-	}
+	};
 	
 	/**
 	 * @param {Integer} i index
@@ -2080,14 +2095,14 @@
 	var oldElement;
 	var newElement;
 	var prefix;
-	if(frameName && frameName != ""){
+	if(frameName && frameName !== ""){
 		prefix = window.frames[frameName].document;
 	}
-	else if(!frameName || frameName == ""){
+	else if(!frameName || frameName === ""){
 		prefix = document;
 	}
 	oldElement = prefix.getElementById(elementId);
-	if (oldElement == null) {
+	if (oldElement === null) {
 		newElement = prefix.createElement(tagName);
 		newElement = prefix.getElementsByTagName(appendAtTagName)[0].appendChild(newElement);
 	}



More information about the Mapbender_commits mailing list