<commit_before>OutputPanel = OpenLayers.Class({

    /**
    * Constructor: OutputPanel
    *
    * Parameters:
    * options - {Object} Options for panel.
    */
    initialize: function(options) {
        this.layers = options.layers;
        this.activities = options.activities;
        this.div = jQuery(options.div);
        this.events = new OpenLayers.Events(this, this.div.get(0), null, true);
    },

    getActivity: function() {
        return this._activity;
    },

    _setActivity: function(activity) {
        this._activity = activity;
        this.events.triggerEvent("activitychange", {activity: this.getActivity()});
        return this.getActivity();
    },

    /**
    * Method: draw
    *
    * Returns:
    * {DOMElement} A reference to the DIV DOMElement containing the panel.
    */
    draw: function() {

        var panel = this;

        var tmpl = jQuery('#outputTmpl').html();
        var model = {"layers": this.layers, "activities": this.activities};
        var panelHtml = jQuery.mustache(tmpl, jQuery.extend(model, FISH_MAP.tmplView));
        this.div.append(panelHtml);

        this.drawActivityLayers();

        this.div.delegate('h3', 'click', function() {
            jQuery(this).toggleClass('collapsed').siblings().toggle();
        });

        this.div.find('h3').click().first().click();

        this.div.delegate('input', 'change', function() {
            // Ensure only one activity layer is visible at a time
            if (jQuery(this).parents().hasClass('activity') && this.checked) {
                var that = this;
                panel.div.find('.activity input:checkbox:checked').filter(function() {
                    // return (jQuery(this).val().match(panel.getActivity()) && this !== that);
                    return (this !== that);
                }).each(function() {
                    this.checked = false;
                    panel.events.triggerEvent("layerchange", {layer: this.value, state: this.checked});
                });
            }
            panel.events.triggerEvent("layerchange", {layer: this.value, state: this.checked});
        });

        this.div.find('select').change(function() {
            panel._setActivity(this.value);
            panel.syncActivityLayers();
        }).change();

        jQuery('a.new_scenario', panel.div).click(function() {
            panel.events.triggerEvent("newscenario");
            return false;
        });

        jQuery('input[name=clear_scenario]', panel.div).click(function() {
            panel.events.triggerEvent("clearscenario");
            return false;
        });

        jQuery('input[name=show_scenario]', panel.div).click(function() {
            panel.events.triggerEvent("showscenario");
            return false;
        });

        return this.div;

    },

    syncActivityLayers: function() {
        var panel = this;
        // Only show the intensity, vessels and sensitivity layers for the
        // selected activity
        jQuery('.activity li.layer', this.div).hide().filter(function () {
            var val = jQuery(this).find('input').val();
            return val.match(panel.getActivity()) || val.match(/_project$/);
        }).show();
        // If the user is showing an intensity, vessels or sensitivity
        // layer then hide the old layer and show the one associated with
        // the current activity
        jQuery('.activity li.layer input:checked').each(function() {
            this.checked = false;
            jQuery(this).change();
            var prefix = this.value.match(/^\w+_lvls_/)[0];
            jQuery('input#' + prefix + panel.getActivity()).prop('checked', true).change();
        });
    },

    drawActivityLayers: function() {
        var activityTmpl = jQuery('#activityLayersTmpl').html();
        var activityHtml = jQuery.mustache(activityTmpl, {"layers": this.layers});
        // Clear the existing activity layer tree and append the new version
        this.div.find('.activity-tree').children().detach().end().append(activityHtml);
        this.syncActivityLayers();
    },

    showScenarioForm: function() {
        jQuery('form fieldset', this.div).hide();
        var fields = this.scenarioFields[this.getActivity()];
        for (var i = 0, fld; i < fields.length; i++) {
            fld = fields[i];
            jQuery('form fieldset.' + fld, this.div).show();
        }
        jQuery('form').show();
        jQuery('.new_scenario').parent().hide();
    },

    hideScenarioForm: function() {
        jQuery('form', this.div).hide();
        jQuery('.new_scenario').parent().show();
    },

    /**<commit_msg>Favor enabling the scenairo layer is it's present<commit_after>OutputPanel = OpenLayers.Class({

    /**
    * Constructor: OutputPanel
    *
    * Parameters:
    * options - {Object} Options for panel.
    */
    initialize: function(options) {
        this.layers = options.layers;
        this.activities = options.activities;
        this.div = jQuery(options.div);
        this.events = new OpenLayers.Events(this, this.div.get(0), null, true);
    },

    getActivity: function() {
        return this._activity;
    },

    _setActivity: function(activity) {
        this._activity = activity;
        this.events.triggerEvent("activitychange", {activity: this.getActivity()});
        return this.getActivity();
    },

    /**
    * Method: draw
    *
    * Returns:
    * {DOMElement} A reference to the DIV DOMElement containing the panel.
    */
    draw: function() {

        var panel = this;

        var tmpl = jQuery('#outputTmpl').html();
        var model = {"layers": this.layers, "activities": this.activities};
        var panelHtml = jQuery.mustache(tmpl, jQuery.extend(model, FISH_MAP.tmplView));
        this.div.append(panelHtml);

        this.drawActivityLayers();

        this.div.delegate('h3', 'click', function() {
            jQuery(this).toggleClass('collapsed').siblings().toggle();
        });

        this.div.find('h3').click().first().click();

        this.div.delegate('input', 'change', function() {
            // Ensure only one activity layer is visible at a time
            if (jQuery(this).parents().hasClass('activity') && this.checked) {
                var that = this;
                panel.div.find('.activity input:checkbox:checked').filter(function() {
                    // return (jQuery(this).val().match(panel.getActivity()) && this !== that);
                    return (this !== that);
                }).each(function() {
                    this.checked = false;
                    panel.events.triggerEvent("layerchange", {layer: this.value, state: this.checked});
                });
            }
            panel.events.triggerEvent("layerchange", {layer: this.value, state: this.checked});
        });

        this.div.find('select').change(function() {
            panel._setActivity(this.value);
            panel.syncActivityLayers();
        }).change();

        jQuery('a.new_scenario', panel.div).click(function() {
            panel.events.triggerEvent("newscenario");
            return false;
        });

        jQuery('input[name=clear_scenario]', panel.div).click(function() {
            panel.events.triggerEvent("clearscenario");
            return false;
        });

        jQuery('input[name=show_scenario]', panel.div).click(function() {
            panel.events.triggerEvent("showscenario");
            return false;
        });

        return this.div;

    },

    syncActivityLayers: function() {
        var panel = this;
        // Only show the intensity, vessels and sensitivity layers for the
        // selected activity
        jQuery('.activity li.layer', this.div).hide().filter(function () {
            var val = jQuery(this).find('input').val();
            return val.match(panel.getActivity()) || val.match(/_project$/);
        }).show();
        // If the user is showing an intensity, vessels or sensitivity
        // layer then hide the old layer and show the one associated with
        // the current activity
        jQuery('.activity li.layer input:checked').each(function() {
            this.checked = false;
            jQuery(this).change();
            var prefix = this.value.match(/^\w+_lvls_/)[0];
            // If there is a scenario layer then enable it otherwise fallback
            // to the regular layer
            var lyr = jQuery('input#' + prefix + 'project');
            if (lyr.length === 0) {
                lyr = jQuery('input#' + prefix + panel.getActivity());
            }
            lyr.prop('checked', true).change();
        });
    },

    drawActivityLayers: function() {
        var activityTmpl = jQuery('#activityLayersTmpl').html();
        var activityHtml = jQuery.mustache(activityTmpl, {"layers": this.layers});
        // Clear the existing activity layer tree and append the new version
        this.div.find('.activity-tree').children().detach().end().append(activityHtml);
        this.syncActivityLayers();
    },

    showScenarioForm: function() {
        jQuery('form fieldset', this.div).hide();
        var fields = this.scenarioFields[this.getActivity()];
        for (var i = 0, fld; i < fields.length; i++) {
            fld = fields[i];
            jQuery('form fieldset.' + fld, this.div).show();
        }
        jQuery('form').show();
        jQuery('.new_scenario').parent().hide();
    },

    hideScenarioForm: function() {
        jQuery('form', this.div).hide();
        jQuery('.new_scenario').parent().show();
    },

    /**
{'fraction_non_alphanumeric': 0.15033500837520938, 'fraction_numerical': 0.0011515912897822446, 'mean_word_length': 2.174808906613493, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 3, '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': '5427093', 'n_tokens_mistral': 2604, 'n_tokens_neox': 2505, 'n_words': 542}