<commit_before>{% extends 'layout/admin_page.html' %}
{% from 'forms/_form.html' import form_header, form_rows, form_footer %}

{% block title %}{% trans %}Merge users{% endtrans %}{% endblock %}

{%- block content %}
    {{ form_header(form, id='merge-form') }}
    {{ form_rows(form) }}
    {% call form_footer(form) %}
        <input class="i-button big highlight" type="submit" disabled value="{% trans %}Merge{% endtrans %}">
    {% endcall %}

    <script>
    (function() {
        var FIELDS = {id: 'ID', email: $T('E-mail'), affiliation: $T('Affiliation')};

        function update_data(source, target) {
            function _render_data(data) {
                return $('<ul class="merge-info">').append(
                    _.map(FIELDS, function(caption, field) {
                        return $('<li>').append($('<span class="caption">').text(caption + ': '),
                                                $('<span>').text(data[field]));
                    }));
            }

            $('.form-field .merge-info').remove();
            $('#source_user').closest('.form-field').prepend(_render_data(source));
            $('#target_user').closest('.form-field').prepend(_render_data(target));
        }

        function check_users() {
            var source = JSON.parse($('#source_user').val()),
                target = JSON.parse($('#target_user').val()),
                $form = $('#merge-form'),
                $submit = $form.find('input[type=submit]');

            if (!source.length || !target.length) {
                $submit.prop('disabled', true);
                return;
            }

            $.ajax({
                method: 'GET',
                url: {{ url_for('.users_merge_check') | tojson }},
                data: {
                    source: source[0].id,
                    target: target[0].id
                }
            }).done(function(result) {
                update_data(source[0], target[0]);

                var allow_submit = true,
                    warnings = false;

                $('#flashed-messages').empty();

                function showProblem(problem, isError) {
                    $('#flashed-messages').append(
                        $('<div>', {'class': (isError ? 'error' : 'warning') + '-message-box'}).append(
                            $('<div>', {'class': 'message-text', text: problem})
                        )
                    );

                    if(isError) {
                        allow_submit = false;
                    } else {
                        warnings = true;
                    }
                }

                $(result.warnings).each(function(_, problem) {
                    showProblem(problem, false);<commit_msg>Use fixed-width message box for merge warnings<commit_after>{% extends 'layout/admin_page.html' %}
{% from 'forms/_form.html' import form_header, form_rows, form_footer %}

{% block title %}{% trans %}Merge users{% endtrans %}{% endblock %}

{%- block content %}
    {{ form_header(form, id='merge-form') }}
    {{ form_rows(form) }}
    {% call form_footer(form) %}
        <input class="i-button big highlight" type="submit" disabled value="{% trans %}Merge{% endtrans %}">
    {% endcall %}

    <script>
    (function() {
        var FIELDS = {id: 'ID', email: $T('E-mail'), affiliation: $T('Affiliation')};

        function update_data(source, target) {
            function _render_data(data) {
                return $('<ul class="merge-info">').append(
                    _.map(FIELDS, function(caption, field) {
                        return $('<li>').append($('<span class="caption">').text(caption + ': '),
                                                $('<span>').text(data[field]));
                    }));
            }

            $('.form-field .merge-info').remove();
            $('#source_user').closest('.form-field').prepend(_render_data(source));
            $('#target_user').closest('.form-field').prepend(_render_data(target));
        }

        function check_users() {
            var source = JSON.parse($('#source_user').val()),
                target = JSON.parse($('#target_user').val()),
                $form = $('#merge-form'),
                $submit = $form.find('input[type=submit]');

            if (!source.length || !target.length) {
                $submit.prop('disabled', true);
                return;
            }

            $.ajax({
                method: 'GET',
                url: {{ url_for('.users_merge_check') | tojson }},
                data: {
                    source: source[0].id,
                    target: target[0].id
                }
            }).done(function(result) {
                update_data(source[0], target[0]);

                var allow_submit = true,
                    warnings = false;

                $('#flashed-messages').empty();

                function showProblem(problem, isError) {
                    $('#flashed-messages').append(
                        $('<div>', {'class': (isError ? 'error' : 'warning') + '-message-box fixed-width'}).append(
                            $('<div>', {'class': 'message-text', text: problem})
                        )
                    );

                    if(isError) {
                        allow_submit = false;
                    } else {
                        warnings = true;
                    }
                }

                $(result.warnings).each(function(_, problem) {
                    showProblem(problem, false);
{'fraction_non_alphanumeric': 0.1675997832761423, 'fraction_numerical': 0.0014448257178977786, 'mean_word_length': 1.4990974729241877, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '970610', 'n_tokens_mistral': 1510, 'n_tokens_neox': 1397, 'n_words': 256}