<commit_before>// This script, and the YUI libraries that it needs, are inluded by
// the $PAGE->requires->js calls in question_get_html_head_contributions in lib/questionlib.php.

M.core_question_flags = {
    flagattributes: null,
    actionurl: null,
    listeners: [],

    init: function(Y, actionurl, flagattributes) {
        M.core_question_flags.flagattributes = flagattributes;
        M.core_question_flags.actionurl = actionurl;

        Y.all('div.questionflag').each(function(flagdiv, i) {
            var checkbox = flagdiv.one('input.questionflagcheckbox');
            if (!checkbox) {
                return;
            }

            var input = Y.Node.create('<input type="hidden" />');
            input.set('id', checkbox.get('id'));
            input.set('name', checkbox.get('name'));
            input.set('value', checkbox.get('checked') ? 1 : 0);

            // Create an image input to replace the img tag.
            var image = Y.Node.create('<input type="image" class="questionflagimage" />');
            M.core_question_flags.update_flag(input, image);

            checkbox.remove();
            flagdiv.one('label').remove();
            flagdiv.append(input);
            flagdiv.append(image);
        });

        Y.delegate('click', function(e) {
            var input = this.previous('input');
            input.set('value', 1 - input.get('value'));
            M.core_question_flags.update_flag(input, this);
            var postdata = this.previous('input.questionflagpostdata').get('value') +
                    input.get('value')

            e.halt();
            Y.io(M.core_question_flags.actionurl , {method: 'POST', 'data': postdata});
            M.core_question_flags.fire_listeners(postdata);
        }, document.body, 'input.questionflagimage');

    },

    update_flag: function(input, image) {
        image.setAttrs(M.core_question_flags.flagattributes[input.get('value')]);
    },

    add_listener: function(listener) {
        M.core_question_flags.listeners.push(listener);<commit_msg>fixed unterminated JS statements<commit_after>// This script, and the YUI libraries that it needs, are inluded by
// the $PAGE->requires->js calls in question_get_html_head_contributions in lib/questionlib.php.

M.core_question_flags = {
    flagattributes: null,
    actionurl: null,
    listeners: [],

    init: function(Y, actionurl, flagattributes) {
        M.core_question_flags.flagattributes = flagattributes;
        M.core_question_flags.actionurl = actionurl;

        Y.all('div.questionflag').each(function(flagdiv, i) {
            var checkbox = flagdiv.one('input.questionflagcheckbox');
            if (!checkbox) {
                return;
            }

            var input = Y.Node.create('<input type="hidden" />');
            input.set('id', checkbox.get('id'));
            input.set('name', checkbox.get('name'));
            input.set('value', checkbox.get('checked') ? 1 : 0);

            // Create an image input to replace the img tag.
            var image = Y.Node.create('<input type="image" class="questionflagimage" />');
            M.core_question_flags.update_flag(input, image);

            checkbox.remove();
            flagdiv.one('label').remove();
            flagdiv.append(input);
            flagdiv.append(image);
        });

        Y.delegate('click', function(e) {
            var input = this.previous('input');
            input.set('value', 1 - input.get('value'));
            M.core_question_flags.update_flag(input, this);
            var postdata = this.previous('input.questionflagpostdata').get('value') +
                    input.get('value');

            e.halt();
            Y.io(M.core_question_flags.actionurl , {method: 'POST', 'data': postdata});
            M.core_question_flags.fire_listeners(postdata);
        }, document.body, 'input.questionflagimage');

    },

    update_flag: function(input, image) {
        image.setAttrs(M.core_question_flags.flagattributes[input.get('value')]);
    },

    add_listener: function(listener) {
        M.core_question_flags.listeners.push(listener);
{'fraction_non_alphanumeric': 0.14004854368932038, 'fraction_numerical': 0.0014563106796116505, 'mean_word_length': 2.4514237855946397, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '1022061', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1145, 'n_words': 210}