view js/dataset_fields_loader.js @ 4:1b6cde0e4b83 default tip

merger
author Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
date Mon, 12 Oct 2015 08:38:25 +0200
parents b57c7821382f
children
line wrap: on
line source

(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_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_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);