<commit_before>(function($) {

    $.notify.defaults( { globalPosition: 'top left', style: 'bootstrap'} );
    /**
     * Regular Expression to get checked if string should be translated
     *
     * @type {RegExp}
     */
    var translationReg = /^trans:\w+\.(\w|-|\.\w+)+\w+$/;

    /**
     * Translate digitizer keywords
     * @param title
     * @param withoutSuffix
     * @returns {*}
     */
    function translate(title, withoutSuffix) {
        return Mapbender.trans(withoutSuffix ? title : "mb.digitizer." + title);
    }

    /**
     * Translate object
     *
     * @param items
     * @returns object
     */
    function translateObject(items) {
        for (var k in items) {
            if(!items.hasOwnProperty(k)){
                continue;
            }
            var item = items[k];
            if(typeof item === "string" && item.match(translationReg)) {
                items[k] = translate(item.split(':')[1], true);
            } else if(typeof item === "object") {
                translateObject(item);
            }
        }
        return item;
    }

    /**
     * Check and replace values recursive if they should be translated.
     * For checking used "translationReg" variable
     *
     *
     * @param items
     */
    function translateStructure(items) {
        var isArray = items instanceof Array;
        for (var k in items) {
            if(isArray || k == "children") {
                translateStructure(items[k]);
            } else {
                if(typeof items[k] == "string" && items[k].match(translationReg)) {
                    items[k] = translate(items[k].split(':')[1], true);
                }
            }
        }
    }

    //noinspection JSDuplicatedDeclaration
    /**
     * Digitizing tool set
     *
     * @author <NAME> <<EMAIL>>
     * @author <NAME> <<EMAIL>>
     *
     * @copyright 20.04.2015 by WhereGroup GmbH & Co. KG
     */
    $.widget("mapbender.mbSearch", {
        options: {
            // Default option values
            allowDigitize:     false,
            allowDelete:       false,
            allowEditData:     true,
            openFormAfterEdit: true,
            maxResults:        5001,
            pageLength:        10,
            oneInstanceEdit:   true,
            searchType:        "currentExtent",
            inlineSearch:      true,
            useContextMenu:    true,
            clustering:        [{
                scale:    5000000,
                distance: 30
            }]
        },
        map:                    null,
        currentSettings:        null,
        featureEditDialogWidth: "423px",

        /**
         * Dynamic loaded styles
         */
        _styles:          null,
        _schemas:         null,
        _styleMaps:       null,
        _queries:         {},
        _originalQueries: {},

        /**
         * Constructor.
         *
         * At this moment not all elements (like a OpenLayers) are avaible.
         *
         * @private
         */
        _create: function() {
            var widget = this;
            var element = widget.element;
            var options = widget.options;
            var target = options.target = $(".olMap").attr("id");

            if(!Mapbender.checkTarget("mbSearch", target)) {
                return;
            }

            widget.elementUrl = Mapbender.configuration.application.urls.element + '/' + element.attr('id') + '/';
            Mapbender.elementRegistry.onElementReady(target, function() {

                widget.map = $('#' + options.target).data('mapbenderMbMap').map.olMap;

                element.generateElements({
                    type:     'fieldSet',
                    children: [{
                        type:     'button',
                        title:    'Abfrage',
                        cssClass: 'btn new-query',
                        css:      {width: '33%'},
                        click:    function() {
                            widget.openCreateDialog();
                        }
                    }, {
                        type:     'button',
                        title:    'Thema',
                        cssClass: 'btn new-query',
                        css:      {width: '33%'},
                        click:    function() {
                            widget.openStyleMapManager({id: null}, widget._styles);
                        }
                    }, {
                        type:     'button',
                        title:    'Stil',
                        cssClass: 'btn new-query',
                        css:      {width: '30%'},
                        click:    function() {
                            widget.openStyleEditor();
                        }
                    }]
                });

                element.generateElements({
                    type: 'html',
                    html: '<div class="queries"></div>'
                });

                // widget.activateContextMenu();

                //widget.map.resetLayersZIndex();
                widget._trigger('ready');

                // Check position and react by
                var containerInfo = new MapbenderContainerInfo(widget, {
                    onactive:   function() {
                        widget.enable();
                    },
                    oninactive: function() {
                        widget.disable();
                    }
                });
            });

            widget.refreshSchemas().done(function(){
                widget.refreshStyles().done(function(){
                    widget.refreshStyleMaps().done(function(){
                        widget.refreshQueries().done(function(){
                        });
                    });
                });
            });
        },

        /**
         * Activate widget
         */
        enable: function() {
            var widget = this;
            _.each(widget._queries, function(query) {
                var isActive = query.hasOwnProperty("isActive") && query.isActive;
                query.layer.setVisibility(isActive);
            });
        },
<commit_msg>Add query schema group filter #7625<commit_after>(function($) {

    $.notify.defaults( { globalPosition: 'top left', style: 'bootstrap'} );
    /**
     * Regular Expression to get checked if string should be translated
     *
     * @type {RegExp}
     */
    var translationReg = /^trans:\w+\.(\w|-|\.\w+)+\w+$/;

    /**
     * Translate digitizer keywords
     * @param title
     * @param withoutSuffix
     * @returns {*}
     */
    function translate(title, withoutSuffix) {
        return Mapbender.trans(withoutSuffix ? title : "mb.digitizer." + title);
    }


    /**
     * Digitizing tool set
     *
     * @author <NAME> <<EMAIL>>
     * @author <NAME> <<EMAIL>>
     *
     * @copyright 20.04.2015 by WhereGroup GmbH & Co. KG
     */
    $.widget("mapbender.mbSearch", {
        options: {
            // Default option values
            allowDigitize:     false,
            allowDelete:       false,
            allowEditData:     true,
            openFormAfterEdit: true,
            maxResults:        5001,
            pageLength:        10,
            oneInstanceEdit:   true,
            searchType:        "currentExtent",
            inlineSearch:      true,
            useContextMenu:    true,
            clustering:        [{
                scale:    5000000,
                distance: 30
            }]
        },
        map:                    null,
        currentSettings:        null,
        featureEditDialogWidth: "423px",

        /**
         * Dynamic loaded styles
         */
        _styles:          null,
        _schemas:         null,
        _styleMaps:       null,
        _queries:         {},
        _originalQueries: {},

        /**
         * Constructor.
         *
         * At this moment not all elements (like a OpenLayers) are avaible.
         *
         * @private
         */
        _create: function() {
            var widget = this;
            var element = widget.element;
            var options = widget.options;
            var target = options.target = $(".olMap").attr("id");

            if(!Mapbender.checkTarget("mbSearch", target)) {
                return;
            }

            widget.elementUrl = Mapbender.configuration.application.urls.element + '/' + element.attr('id') + '/';
            Mapbender.elementRegistry.onElementReady(target, function() {

                widget.map = $('#' + options.target).data('mapbenderMbMap').map.olMap;

                element.generateElements({
                    type:     'fieldSet',
                    children: [{
                        type:    'select',
                        name:    'typeFilter',
                        css:    {width: '55%'},
                        change: function(e) {
                            var select = $(e.target);
                            var schemaId = select.val();

                            _.each(widget._queries, function(query) {
                                var titleView = query.titleView;
                                var resultView = query.resultView;
                                var querySchemaId = query.schemaId;
                                var queryLayer =  query.layer;

                                if(schemaId == -1 || querySchemaId == schemaId) {
                                    titleView.show(0);
                                    if(query.isActive) {
                                        resultView.show(0);
                                        queryLayer.setVisibility(true);
                                    }
                                } else {
                                    titleView.hide(0);
                                    resultView.hide(0);
                                    queryLayer.setVisibility(false);
                                }
                            });
                        }
                    }, {
                        type:     'button',
                        title:    'Abfrage',
                        cssClass: 'btn new-query',
                        css:      {width: '15%'},
                        click:    function() {
                            widget.openCreateDialog();
                        }
                    }, {
                        type:     'button',
                        title:    'Thema',
                        cssClass: 'btn new-query',
                        css:      {width: '15%'},
                        click:    function() {
                            widget.openStyleMapManager({id: null}, widget._styles);
                        }
                    }, {
                        type:     'button',
                        title:    'Stil',
                        cssClass: 'btn new-query',
                        css:      {width: '15%'},
                        click:    function() {
                            widget.openStyleEditor();
                        }
                    }]
                });

                element.generateElements({
                    type: 'html',
                    html: '<div class="queries"></div>'
                });

                // widget.activateContextMenu();

                //widget.map.resetLayersZIndex();
                widget._trigger('ready');

                // Check position and react by
                var containerInfo = new MapbenderContainerInfo(widget, {
                    onactive:   function() {
                        widget.enable();
                    },
                    oninactive: function() {
                        widget.disable();
                    }
                });
            });

            widget.refreshSchemas().done(function() {
                widget.refreshStyles().done(function() {
                    widget.refreshStyleMaps().done(function() {
                        widget.refreshQueries().done(function(r) {
                            widget.renderSchemaFilterSelect();
                        });
                    });
                });
            });
        },

        /**
         * Render object type filter
         */
        renderSchemaFilterSelect: function() {
            var widget = this;
            var queries = widget._queries;
            var schemas = widget._schemas;
            var element = widget.element;
            var filterSelect = element.find('[name="typeFilter"]');

            element.find('option').remove();

            filterSelect.append('<option value="-1">Alle Objekttypen</option>');
            _.each(_.unique(_.pluck(queries, 'schemaId')), function(schemaId) {
                var schema = schemas[schemaId];
                filterSelect.append('<option value="' + schemaId + '">' + schema.title + '</option>');
            });
            filterSelect.val(-1);
        },

        /**
         * Activate widget
         */
        enable: function() {
            var widget = this;
            _.each(widget._queries, function(query) {
                var isActive = query.hasOwnProperty("isActive") && query.isActive;
                query.layer.setVisibility(isActive);
            });
        },

{'fraction_non_alphanumeric': 0.11235107826873775, 'fraction_numerical': 0.005956869250490122, 'mean_word_length': 1.032020836525203, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1877018', 'n_tokens_mistral': 3276, 'n_tokens_neox': 3035, 'n_words': 611}