<commit_before>YUI.add('moodle-core-formautosubmit',
    function(Y) {
        // The CSS selectors we use
        var CSS = {
            AUTOSUBMIT : 'autosubmit'
        };

        var FORMAUTOSUBMITNAME = 'core-formautosubmit';

        var FORMAUTOSUBMIT = function() {
            FORMAUTOSUBMIT.superclass.constructor.apply(this, arguments);
        }

        //  We only want to initialize the module fully once
        var INITIALIZED = false;

        Y.extend(FORMAUTOSUBMIT, Y.Base, {

            /**
              * Initialize the module
              */
            initializer : function(config) {
                // We only apply the delegation once
                if (!INITIALIZED) {
                    INITIALIZED = true;
                    var applyto = Y.one('body');

                    // We don't listen for change events by default as using the keyboard triggers these too.
                    applyto.delegate('key', this.process_changes, 'press:13', 'select.' + CSS.AUTOSUBMIT, this);
                    applyto.delegate('click', this.process_changes, 'select.' + CSS.AUTOSUBMIT, this);

                    if (Y.UA.os == 'macintosh' && Y.UA.webkit) {
                        // Macintosh webkit browsers like change events, but non-macintosh webkit browsers don't.
                        applyto.delegate('change', this.process_changes, 'select.' + CSS.AUTOSUBMIT, this);
                    }
                    if (Y.UA.ios) {
                        // IOS doesn't trigger click events because it's touch-based.
                        applyto.delegate('change', this.process_changes, 'select.' + CSS.AUTOSUBMIT, this);
                    }
                }

                // Assign this select items 'nothing' value and lastindex (current value)
                if (this.get('selectid')) {
                    var thisselect = Y.one('select#' + this.get('selectid'));
                    if (thisselect) {
                        if (this.get('nothing')) {
                            thisselect.setData('nothing', this.get('nothing'));
                        }
                        thisselect.setData('startindex', thisselect.get('selectedIndex'));
                    } else {
                        Y.log("Warning: A single_select element was renderered, but the output is not displayed on the page.");
                    }
                }
            },

            /**
             * Check whether the select element was changed
             */
            check_changed : function(e) {
                var select = e.target.ancestor('select.' + CSS.AUTOSUBMIT, true);
                if (!select) {
                    return false;
                }

                var nothing = select.getData('nothing');
                var startindex = select.getData('startindex');
                var currentindex = select.get('selectedIndex');

                var previousindex = select.getAttribute('data-previousindex');
                select.setAttribute('data-previousindex', currentindex);
                if (!previousindex) {
                    previousindex = startindex;
                }

                // Check whether the field has changed, and is not the 'nothing' value
                if ((nothing===false || select.get('value') != nothing) && startindex != select.get('selectedIndex') && currentindex != previousindex) {
                    return select;
                }
                return false;
            },

            /**
             * Process any changes
             */
            process_changes : function(e) {
                var select = this.check_changed(e);
                if (select) {
                    var form = select.ancestor('form', true);
                    form.submit();<commit_msg>MDL-37366 Fix JS Lint issues with moodle-core-formautosubmit<commit_after>YUI.add('moodle-core-formautosubmit',
    function(Y) {
        var CSS,
            FORMAUTOSUBMITNAME = 'core-formautosubmit',
            FORMAUTOSUBMIT,
            INITIALIZED = false;

        // The CSS selectors we use
        CSS = {
            AUTOSUBMIT : 'autosubmit'
        };

        FORMAUTOSUBMIT = function() {
            FORMAUTOSUBMIT.superclass.constructor.apply(this, arguments);
        };

        Y.extend(FORMAUTOSUBMIT, Y.Base, {

            /**
              * Initialize the module
              */
            initializer : function() {
                // Set up local variables
                var applyto,
                    thisselect;
                // We only apply the delegation once
                if (!INITIALIZED) {
                    INITIALIZED = true;
                    applyto = Y.one('body');

                    // We don't listen for change events by default as using the keyboard triggers these too.
                    applyto.delegate('key', this.process_changes, 'press:13', 'select.' + CSS.AUTOSUBMIT, this);
                    applyto.delegate('click', this.process_changes, 'select.' + CSS.AUTOSUBMIT, this);

                    if (Y.UA.os === 'macintosh' && Y.UA.webkit) {
                        // Macintosh webkit browsers like change events, but non-macintosh webkit browsers don't.
                        applyto.delegate('change', this.process_changes, 'select.' + CSS.AUTOSUBMIT, this);
                    }
                    if (Y.UA.ios) {
                        // IOS doesn't trigger click events because it's touch-based.
                        applyto.delegate('change', this.process_changes, 'select.' + CSS.AUTOSUBMIT, this);
                    }
                }

                // Assign this select items 'nothing' value and lastindex (current value)
                if (this.get('selectid')) {
                    thisselect = Y.one('select#' + this.get('selectid'));
                    if (thisselect) {
                        if (this.get('nothing')) {
                            thisselect.setData('nothing', this.get('nothing'));
                        }
                        thisselect.setData('startindex', thisselect.get('selectedIndex'));
                    } else {
                        Y.log("Warning: A single_select element was renderered, but the output is not displayed on the page.");
                    }
                }
            },

            /**
             * Check whether the select element was changed
             */
            check_changed : function(e) {
                var select,
                    nothing,
                    startindex,
                    currentindex,
                    previousindex;
                select = e.target.ancestor('select.' + CSS.AUTOSUBMIT, true);
                if (!select) {
                    return false;
                }

                nothing = select.getData('nothing');
                startindex = select.getData('startindex');
                currentindex = select.get('selectedIndex');

                previousindex = select.getAttribute('data-previousindex');
                select.setAttribute('data-previousindex', currentindex);
                if (!previousindex) {
                    previousindex = startindex;
                }

                // Check whether the field has changed, and is not the 'nothing' value
                if ((nothing===false || select.get('value') !== nothing)
                        && startindex !== select.get('selectedIndex') && currentindex !== previousindex) {
                    return select;
                }
                return false;
            },

            /**
             * Process any changes
             */
            process_changes : function(e) {
                var select = this.check_changed(e),
                    form;
                if (select) {
                    form = select.ancestor('form', true);
                    form.submit();
{'fraction_non_alphanumeric': 0.10266159695817491, 'fraction_numerical': 0.0011406844106463879, 'mean_word_length': 1.2899013348810215, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1445641', 'n_tokens_mistral': 1990, 'n_tokens_neox': 1847, 'n_words': 455}