<commit_before>var view_index = view_index || {};

(function ($) {
    /**
     * View Index Logic.
     *
     * @param {object} options
     */
    function ViewIndex()
    {}

    /**
     * Initialize method.
     *
     * @return {undefined}
     */
    ViewIndex.prototype.init = function (options) {
        this.options = options;
        this.api_url = options.hasOwnProperty('api_url') ? options.api_url : null;
        this.api_ext = options.hasOwnProperty('api_ext') ? options.api_ext : null;
        this.api_token = options.hasOwnProperty('api_token') ? options.api_token : null;
        this.table_id = options.hasOwnProperty('table_id') ? options.table_id : null;
        this.menus = options.hasOwnProperty('menus') ? options.menus : false;
        this.format = options.hasOwnProperty('format') ? options.format : {};
        this.extras = options.hasOwnProperty('extras') ? options.extras : {};
        this.state_duration = options.hasOwnProperty('state_duration') ? options.state_duration : 0;

        var table = this.datatable();
        this._handleDeleteLinks(table);
        this._batchActions();
    };

    ViewIndex.prototype._batchActions = function () {
        var that = this;
        $(this.options.batch.delete_id).click(function (e) {
            e.preventDefault();
            if (!confirm('Are you sure you want to delete the selected records?')) {
                return;
            }

            that._createAndSubmitBatchForm('delete');
        });
        $(this.options.batch.edit_id).click(function (e) {
            e.preventDefault();

            that._createAndSubmitBatchForm('edit');
        });
    };

    ViewIndex.prototype._createAndSubmitBatchForm = function (type) {
        var $form = $('<form method="post" action="' + this.options.batch.url + '/' + type + '"></form>');

        $form.append('<input type="hidden" name="_method" value="' + type.toUpperCase() + '" />');
        $(this.options.table_id + ' tr.selected').each(function () {
            $form.append('<input type="text" name="batch[ids][]" value="' + $(this).attr('data-id') + '">');
        });

        $form.submit();
    };

    /**<commit_msg>Remove hidden method input (task #812)<commit_after>var view_index = view_index || {};

(function ($) {
    /**
     * View Index Logic.
     *
     * @param {object} options
     */
    function ViewIndex()
    {}

    /**
     * Initialize method.
     *
     * @return {undefined}
     */
    ViewIndex.prototype.init = function (options) {
        this.options = options;
        this.api_url = options.hasOwnProperty('api_url') ? options.api_url : null;
        this.api_ext = options.hasOwnProperty('api_ext') ? options.api_ext : null;
        this.api_token = options.hasOwnProperty('api_token') ? options.api_token : null;
        this.table_id = options.hasOwnProperty('table_id') ? options.table_id : null;
        this.menus = options.hasOwnProperty('menus') ? options.menus : false;
        this.format = options.hasOwnProperty('format') ? options.format : {};
        this.extras = options.hasOwnProperty('extras') ? options.extras : {};
        this.state_duration = options.hasOwnProperty('state_duration') ? options.state_duration : 0;

        var table = this.datatable();
        this._handleDeleteLinks(table);
        this._batchActions();
    };

    ViewIndex.prototype._batchActions = function () {
        var that = this;
        $(this.options.batch.delete_id).click(function (e) {
            e.preventDefault();
            if (!confirm('Are you sure you want to delete the selected records?')) {
                return;
            }

            that._createAndSubmitBatchForm('delete');
        });
        $(this.options.batch.edit_id).click(function (e) {
            e.preventDefault();

            that._createAndSubmitBatchForm('edit');
        });
    };

    ViewIndex.prototype._createAndSubmitBatchForm = function (type) {
        var $form = $('<form method="post" action="' + this.options.batch.url + '/' + type + '"></form>');

        $(this.options.table_id + ' tr.selected').each(function () {
            $form.append('<input type="text" name="batch[ids][]" value="' + $(this).attr('data-id') + '">');
        });

        $form.submit();
    };

    /**
{'fraction_non_alphanumeric': 0.15911214953271027, 'fraction_numerical': 0.0011682242990654205, 'mean_word_length': 2.4748376623376624, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '2326980', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1224, 'n_words': 210}