<commit_before>if (!linz) {
    var linz = {};
}

(function () {

    var resolvedVersionNo;

    $('form').bootstrapValidator({}).on('success.form.bv', function(e) {

        // Prevent form submission
        e.preventDefault();

        // disable submit button
        $(e.target).find('[type="submit"]').attr('disabled','disabled');

    });

    $('form').submit(function () {

        var form = this,
            formValidator = $(form).data('bootstrapValidator'),
            formData = $(form).find(":input").serializeArray(),
            formUrl = $(this).attr('action').replace('save','change');


        if (resolvedVersionNo) {
            formUrl += '/' + resolvedVersionNo;
        }

        $.ajax({
            method: 'post',
            url: formUrl,
            dataType: 'json',
            data: formData
        })
        .done(function(data, textStatus, jqXHR) {

            if (!data.hasChanged) {

                if (formValidator.isValid()) {

                    // since there are no change, submit the form, proceed with normal save operation
                    return form.submit();

                } else {

                    return formValidator.validate();

                }

            }

            // since there is a change, lets load a modal to highlight the changes and provide user with options for the next step
            $('#linzModal').modal().load('/admin/merge-data-conflict-guide');

            Object.keys(data.diff).forEach(function (fieldName) {

                var formField = $(form).find(':input[name="' + fieldName + '"]');

                if (!formField.length) {
                    // exit if field is not found!
                    return;
                }

                linz[formField.attr('data-linz-conflict-handler')](fieldName, data.diff[fieldName], formField, data, form, formValidator);

            });

        })
        .fail(function(res) {

            var json = res.responseJSON;

            if (json) {

                return alert(json.error);

            }

            alert('An error has occurred while attempting to check if this record has been edited by another user.');

            return false;

        });

        return false;
    });

    function standardInputFieldConflictHandler(fieldName, fieldType, formField, data, form, formValidator) {
<commit_msg>Updated to include error statement.<commit_after>if (!linz) {
    var linz = {};
}

(function () {

    var resolvedVersionNo;

    $('form').bootstrapValidator({}).on('success.form.bv', function(e) {

        // Prevent form submission
        e.preventDefault();

        // disable submit button
        $(e.target).find('[type="submit"]').attr('disabled','disabled');

    });

    $('form').submit(function () {

        var form = this,
            formValidator = $(form).data('bootstrapValidator'),
            formData = $(form).find(":input").serializeArray(),
            formUrl = $(this).attr('action').replace('save','change');


        if (resolvedVersionNo) {
            formUrl += '/' + resolvedVersionNo;
        }

        $.ajax({
            method: 'post',
            url: formUrl,
            dataType: 'json',
            data: formData
        })
        .done(function(data, textStatus, jqXHR) {

            if (!data.hasChanged) {

                if (formValidator.isValid()) {

                    // since there are no change, submit the form, proceed with normal save operation
                    return form.submit();

                } else {

                    return formValidator.validate();

                }

            }

            // since there is a change, lets load a modal to highlight the changes and provide user with options for the next step
            $('#linzModal').modal().load('/admin/merge-data-conflict-guide');

            Object.keys(data.diff).forEach(function (fieldName) {

                var formField = $(form).find(':input[name="' + fieldName + '"]');

                if (!formField.length) {
                    // exit if field is not found!
                    return;
                }

                linz[formField.attr('data-linz-conflict-handler')](fieldName, data.diff[fieldName], formField, data, form, formValidator);

            });

        })
        .fail(function(res) {

            var json = res.responseJSON;

            if (json) {

                return alert('An error has occurred: ' + json.error);

            }

            alert('An error has occurred while attempting to check if this record has been edited by another user.');

            return false;

        });

        return false;
    });

    function standardInputFieldConflictHandler(fieldName, fieldType, formField, data, form, formValidator) {

{'fraction_non_alphanumeric': 0.13173277661795407, 'fraction_numerical': 0.0, 'mean_word_length': 1.7190692395005676, 'pattern_counts': {'":': 2, '<': 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': '6526485', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1169, 'n_words': 298}