diff js/lineoverlay_edit_form_populate.js @ 0:b57c7821382f

initial
author Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
date Thu, 28 May 2015 10:28:12 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/js/lineoverlay_edit_form_populate.js	Thu May 28 10:28:12 2015 +0200
@@ -0,0 +1,32 @@
+(function ($) {
+    Drupal.behaviors.mpiwg_geobrowser_lineoverlay_edit = {
+        attach: function(context, settings) {
+            var datasets = [];
+            $("body").find(".mpiwg_geobrowser_dataSource .block-title").each(function() {
+                var datasetDescription = $(this).html().replace("datasource: ", "");
+                var fields = [];
+                $(GeoTemConfig.datasets).each(function() {
+                    if (this.label == datasetDescription) {
+                        if (this.objects.length > 0) {
+                            for (var i=0; i<Object.keys(this.objects[0]).length; i++) {
+                                fields.push(Object.keys(this.objects[0])[i]);
+                            }
+                        }
+                    }
+                });
+                datasets[datasetDescription] = fields;
+            });
+            var htmlList = '<p class="mpiwg_geobrowser_overlay_datasets_info">here u see the available datasources and their respective available fields. u have to manually copy ur preferred items and paste them into the respective text field below.</p>';
+            htmlList += '<ul class="mpiwg_geobrowser_overlay_datasets">';
+            for (var dataset in datasets) {
+                htmlList += '<li>'+dataset+': ';
+                for (var i=0; i<Object.keys(datasets[dataset]).length; i++) {
+                    htmlList += datasets[dataset][i]+', ';
+                }
+                htmlList += '</li>';
+            }
+            htmlList += '</ul>';
+            $("#datasets_placeholder").html(htmlList);
+        }
+    }
+})(jQuery);
\ No newline at end of file