<commit_before>niclabs.insight.filter.LayerSelector = (function($) {


    /**
     * Construct a layer for the dashboard
     *
     * The layer selector provides an option to switch between layers of the dashboard
     *
     * @class niclabs.insight.filter.LayerSelector
     * @augments niclabs.insight.filter.Filter
     * @param {niclabs.insight.Dashboard} dashboard - dashboard that this filter belongs to
     * @param {Object} options - configuration options for the filter
     */
    var LayerSelector = function(dashboard, options) {
        var view = niclabs.insight.filter.Filter(dashboard, options);

        var layers = {};

        // Configure the view
        var select = $('<select>');

        // Hide the selector if there are no elements
        select.hide();

        select.on('change', function() {
            dashboard.active($(this).val());
        });

        // Add the selector to the view
        view.$.append(select);

        /**
         * Add a layer to the selector
         *
         * @memberof niclabs.insight.filter.LayerSelector
         * @param {string} id - id for the layer
         * @param {name} name - name of the layer
         */
        view.add = function(id, name) {
            layers[id] = name;
            select.append($('<option>').attr('value', id).text(name));

            // Show the selector if there is more than one layer
            if (layers.length > 1)
                select.show();
        };

        return view;
    };

    // Register the handler
    niclabs.insight.handler('layer-selector', 'filter', LayerSelector);

    return LayerSelector;<commit_msg>Fix layer selector bug not working properly<commit_after>niclabs.insight.filter.LayerSelector = (function($) {


    /**
     * Construct a layer for the dashboard
     *
     * The layer selector provides an option to switch between layers of the dashboard
     *
     * @class niclabs.insight.filter.LayerSelector
     * @augments niclabs.insight.filter.Filter
     * @param {niclabs.insight.Dashboard} dashboard - dashboard that this filter belongs to
     * @param {Object} options - configuration options for the filter
     */
    var LayerSelector = function(dashboard, options) {
        var view = niclabs.insight.filter.Filter(dashboard, options);

        var layers = {};

        // Configure the view
        var select = $('<select>');

        // Hide the selector if there are no elements
        select.hide();

        select.on('change', function() {
            dashboard.active($(this).val());
        });

        // Add the selector to the view
        view.$.append(select);

        /**
         * Add a layer to the selector
         *
         * @memberof niclabs.insight.filter.LayerSelector
         * @param {string} id - id for the layer
         * @param {name} name - name of the layer
         */
        view.add = function(id, name) {
            layers[id] = name;
            select.append($('<option>').attr('value', id).text(name));

            // Show the selector if there is more than one layer
            // Note: layers.length returns undefined
            if (Object.keys(layers).length > 1)
                select.show();
        };

        return view;
    };

    // Register the handler
    niclabs.insight.handler('layer-selector', 'filter', LayerSelector);

    return LayerSelector;
{'fraction_non_alphanumeric': 0.11324659964518037, 'fraction_numerical': 0.0005913660555884093, 'mean_word_length': 2.031362007168459, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4545514', 'n_tokens_mistral': 921, 'n_tokens_neox': 881, 'n_words': 269}