[Mapbender-commits] r6191 - trunk/mapbender/http/plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed May 12 05:32:55 EDT 2010


Author: verenadiewald
Date: 2010-05-12 05:32:55 -0400 (Wed, 12 May 2010)
New Revision: 6191

Modified:
   trunk/mapbender/http/plugins/mb_metadata_showOriginal.js
Log:
originalLayer Metadata

Modified: trunk/mapbender/http/plugins/mb_metadata_showOriginal.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_showOriginal.js	2010-05-12 09:32:16 UTC (rev 6190)
+++ trunk/mapbender/http/plugins/mb_metadata_showOriginal.js	2010-05-12 09:32:55 UTC (rev 6191)
@@ -4,6 +4,7 @@
 
 var ShowOriginalApi = function() {
 	var that = this;
+	var layerName;
 	
 	this.events = {
 		replaceMetadata : new Mapbender.Event()
@@ -36,34 +37,34 @@
 		var differenceFound = false;
 		for(metadataAttr in currentObj) {
 			var origMetadataAttr = "original_" + metadataAttr;
+			
+			//some attr are excluded from check
 			if(metadataAttr != "wms_id" &&
 				metadataAttr != "wms_timestamp" && 
 				metadataAttr != "wms_timestamp_create" && 
 				metadataAttr != "wms_keywords" && 
-				metadataAttr != "wms_termsofuse") {
-				//check if both fields are filled
-				if(currentObj[metadataAttr] != "" && originalObj[origMetadataAttr] != "") {
-					if(currentObj[metadataAttr] == originalObj[origMetadataAttr]) {
-						$("#" + origMetadataAttr).parent().hide();
-					}
-					else {
-						//mark all attr in main form which are different
-						$("#" + metadataAttr).addClass("differentFromOriginal");
-						(function () {
-							var clickedAttr = metadataAttr;
-							var attrValue = $("#" + origMetadataAttr).val();
-							$("#" + origMetadataAttr).parent().append("<input type='button' value='Replace' id='replaceRecord_"+origMetadataAttr+"' />");
-							$("#replaceRecord_" +origMetadataAttr).addClass("ui-state-default ui-corner-all");
-							$("#replaceRecord_" +origMetadataAttr).bind("click", function () {
-								replaceMetadata(clickedAttr, attrValue);
-							});
-						})();
-						var differenceFound = true;
-					}
+				metadataAttr != "wms_termsofuse" &&
+				metadataAttr != "layer_name" &&
+				metadataAttr != "layer_id" &&
+				metadataAttr != "changeEPSG" &&
+				metadataAttr != "scaleSelect") {
+				
+				if(currentObj[metadataAttr] == originalObj[origMetadataAttr]) {
+					$("#" + origMetadataAttr).parent().hide();
 				}
-				//if both fields are empty, hide the html
 				else {
-					$("#" + origMetadataAttr).parent().hide();
+					//mark all attr in main form which are different
+					$("#" + metadataAttr).addClass("differentFromOriginal");
+					(function () {
+						var clickedAttr = metadataAttr;
+						var attrValue = $("#" + origMetadataAttr).val();
+						$("#" + origMetadataAttr).parent().append("<input type='button' value='Replace' id='replaceRecord_"+origMetadataAttr+"' />");
+						$("#replaceRecord_" +origMetadataAttr).addClass("ui-state-default ui-corner-all");
+						$("#replaceRecord_" +origMetadataAttr).bind("click", function () {
+							replaceMetadata(clickedAttr, attrValue);
+						});
+					})();
+					var differenceFound = true;
 				}
 			}
 		}
@@ -87,20 +88,24 @@
 		}
 	};
 	
-	var getOriginalMetadata = function (currentWmsId, currentWmsData) {
+	var getOriginalMetadata = function (isWmsOrLayer, currentId, currentData) {
+		if(isWmsOrLayer == "layer") {
+			layerName = currentData.layer_name;
+		} 
 		// get original metadata from server
 		var req = new Mapbender.Ajax.Request({
 			url: "../plugins/mb_original_metadata_server.php",
 			method: "getOriginalMetadata",
 			parameters: {
-				"id": currentWmsId
+				"id": currentId,
+				"layerName": layerName
 			},
 			callback: function (obj, result, message) {
 				if (!result) {
 					return;
 				}
 				fillForm(obj);
-				mergeOriginalWithCurrentMetadata(obj,currentWmsData);
+				mergeOriginalWithCurrentMetadata(obj,currentData);
 			}
 		});
 		req.send();	
@@ -137,9 +142,16 @@
 	this.init = function (obj) {
 		$originalMetadataPopup.dialog("close");
 		$originalMetadataForm.load("../plugins/mb_metadata_showOriginal.html", function () {
-			getOriginalMetadata(obj.wmsId, obj.wmsData);
+			getOriginalMetadata("wms", obj.wmsId, obj.wmsData);
 		});
 	}
+	
+	this.initLayer = function (obj) {
+		$originalMetadataPopup.dialog("close");
+		$originalMetadataForm.load("../plugins/mb_metadata_showOriginalLayer.html", function () {
+			getOriginalMetadata("layer",obj.wmsId, obj.layerData);
+		});
+	}
 };
 
 $showOriginalDiv.mapbender(new ShowOriginalApi());
\ No newline at end of file



More information about the Mapbender_commits mailing list