<commit_before>var {{ tableVar }}_table = $('#{{ tableId }}').DataTable({
    'ajax': '{{ path }}',
    'serverSide': true,
    'order': [
        {% set first = true %}
        {%- for column in table.columns %}
        {% if column.options.order is not null %}
            {% if not first %} ,{% endif %}[{{ loop.index0 }}, '{{ column.options.order }}']
            {% set first = false %}
        {% endif %}
        {% endfor -%}
    ],
    'columns': [{% for column in table.columns %}

        {
            'data': '{{ column.name }}',
            'name': '{{ column.name }}',
            {% if column.options.abbr is not null -%}
            'title': '<abbr title="{{ column.label }}">{{ column.options.abbr }}</abbr>',
            {%- endif %}
            {% if column.options.width is not null -%}
            'width': '{{ column.options.width }}',
            {%- endif %}
            'orderable': {% if column.options.sortable %}true{% else %}false{% endif %},
            'searchable': {% if column.options.searchable %}true{% else %}false{% endif %}
        }
        {%- if not loop.last %},
        {% endif %}
        {% endfor %}

    ],

    'stateSave': {% if table.options.stateSave %}true{% else %}false{% endif %},
    'stateDuration': {{ table.options.stateDuration }},
    'stateLoaded': function (settings, data) {
        $(data.columns).each(function(index, item) {
            var value = item.search.search;
            if (0 === value.length) {
                return true;
            }

            var $input = $('#{{ tableId }}_' + settings.aoColumns[index].name + '_filter');
            var $inputEmpty = $('#{{ tableId }}_' + settings.aoColumns[index].name + '_filter_empty');
            if (0 < $inputEmpty.length) {
                if ('|empty=true' == value.substring(value.length - 11)) {
                    $inputEmpty.prop('checked', true);
                    value = value.substring(0, value.length - 11);
                } else if ('|empty=false' == value.substring(value.length - 12)) {
                    $inputEmpty.prop('checked', false);
                    value = value.substring(0, value.length - 12);
                }
            }

            if (1 === $input.length) {
                $input.val(value);
                $input.closest('th').addClass('filtered');
                //$input.closest('thead').addClass('filtered');
            }
        });
    }

    {%- if options is defined %}
    ,
    {% for key, value in options %}
    '{{ key }}': {{ value | raw }},
    {% endfor %}
    {% endif %}
});

{% for column in table.columns %}

    {% if column.options.filter_empty %}
    var {{ tableId }}_{{ column.name }}_filter_empty = $('#{{ tableId }}_{{ column.name }}_filter_empty').is(':checked')

    $('#{{ tableId }}_{{ column.name }}_filter_empty').on('change', function() {
        {{ tableId }}_{{ column.name }}_filter_empty = $(this).is(':checked');

        {% if column.options.filter == false %}
        var value = '|empty=' + {{ tableId }}_{{ column.name }}_filter_empty.toString();
        {{ tableVar }}_table.column({{ loop.index0 }})
                .search(value)
                .draw();
        {% else %}
        $('#{{ tableId }}_{{ column.name }}_filter').trigger('change');
        {% endif %}
    });
    {% endif %}


    {% if column.options.filter == 'text' %}
    var throttle = null;
    var onTextChange = function($input) {
        if (throttle != null) {
            window.clearTimeout(throttle);
            throttle = null;
        }

        var value = $input.val();
        {% if column.options.filter_empty %}
        value += '|empty=' + {{ tableVar }}_{{ column.name }}_filter_empty.toString();
        {% endif %}

        var empty = (value == '' || value == '|empty=false');
        if (empty) {
            $(this).closest('th').removeClass('filtered');
        } else {
            $(this).closest('th').addClass('filtered');
        }

        if ({{ tableVar }}_table.column({{ loop.index0 }}).search() !== value) {
            throttle = window.setTimeout(function() {
                {{ tableVar }}_table.column({{ loop.index0 }})
                        .search(value)
                        .draw();
            }, 200);
        }
    };

    $('#{{ tableId }}_{{ column.name }}_filter').on('change', function() {
        onTextChange($(this));
    });
    $('#{{ tableId }}_{{ column.name }}_filter').on('keyup', function(event) {
        if ('Enter' == event.key || 13 == event.keyCode) {
            event.preventDefault();
        }
        onTextChange($(this));
    });

    {% elseif column.options.filter == 'select' %}
    $('#{{ tableId }}_{{ column.name }}_filter').on('change', function() {
        var value = $(this).val();
        {% if column.options.filter_empty %}
        value += '|empty=' + {{ tableId }}_{{ column.name }}_filter_empty.toString();
        {% endif %}

        var empty = (value == '' || value == '|empty=false');
        if (empty) {
            $(this).closest('th').removeClass('filtered');
        } else {
            $(this).closest('th').addClass('filtered');
        }

        {{ tableVar }}_table.column({{ loop.index0 }})
            .search(value)
            .draw();
    });
    {% endif %}


{% endfor %}
<commit_msg>suppress 'enter'.<commit_after>var {{ tableVar }}_table = $('#{{ tableId }}').DataTable({
    'ajax': '{{ path }}',
    'serverSide': true,
    'order': [
        {% set first = true %}
        {%- for column in table.columns %}
        {% if column.options.order is not null %}
            {% if not first %} ,{% endif %}[{{ loop.index0 }}, '{{ column.options.order }}']
            {% set first = false %}
        {% endif %}
        {% endfor -%}
    ],
    'columns': [{% for column in table.columns %}

        {
            'data': '{{ column.name }}',
            'name': '{{ column.name }}',
            {% if column.options.abbr is not null -%}
            'title': '<abbr title="{{ column.label }}">{{ column.options.abbr }}</abbr>',
            {%- endif %}
            {% if column.options.width is not null -%}
            'width': '{{ column.options.width }}',
            {%- endif %}
            'orderable': {% if column.options.sortable %}true{% else %}false{% endif %},
            'searchable': {% if column.options.searchable %}true{% else %}false{% endif %}
        }
        {%- if not loop.last %},
        {% endif %}
        {% endfor %}

    ],

    'stateSave': {% if table.options.stateSave %}true{% else %}false{% endif %},
    'stateDuration': {{ table.options.stateDuration }},
    'stateLoaded': function (settings, data) {
        $(data.columns).each(function(index, item) {
            var value = item.search.search;
            if (0 === value.length) {
                return true;
            }

            var $input = $('#{{ tableId }}_' + settings.aoColumns[index].name + '_filter');
            var $inputEmpty = $('#{{ tableId }}_' + settings.aoColumns[index].name + '_filter_empty');
            if (0 < $inputEmpty.length) {
                if ('|empty=true' == value.substring(value.length - 11)) {
                    $inputEmpty.prop('checked', true);
                    value = value.substring(0, value.length - 11);
                } else if ('|empty=false' == value.substring(value.length - 12)) {
                    $inputEmpty.prop('checked', false);
                    value = value.substring(0, value.length - 12);
                }
            }

            if (1 === $input.length) {
                $input.val(value);
                $input.closest('th').addClass('filtered');
                //$input.closest('thead').addClass('filtered');
            }
        });
    }

    {%- if options is defined %}
    ,
    {% for key, value in options %}
    '{{ key }}': {{ value | raw }},
    {% endfor %}
    {% endif %}
});

{% for column in table.columns %}

    {% if column.options.filter_empty %}
    var {{ tableId }}_{{ column.name }}_filter_empty = $('#{{ tableId }}_{{ column.name }}_filter_empty').is(':checked')

    $('#{{ tableId }}_{{ column.name }}_filter_empty').on('change', function() {
        {{ tableId }}_{{ column.name }}_filter_empty = $(this).is(':checked');

        {% if column.options.filter == false %}
        var value = '|empty=' + {{ tableId }}_{{ column.name }}_filter_empty.toString();
        {{ tableVar }}_table.column({{ loop.index0 }})
                .search(value)
                .draw();
        {% else %}
        $('#{{ tableId }}_{{ column.name }}_filter').trigger('change');
        {% endif %}
    });
    {% endif %}


    {% if column.options.filter == 'text' %}
    var throttle = null;
    var onTextChange = function($input) {
        if (throttle != null) {
            window.clearTimeout(throttle);
            throttle = null;
        }

        var value = $input.val();
        {% if column.options.filter_empty %}
        value += '|empty=' + {{ tableVar }}_{{ column.name }}_filter_empty.toString();
        {% endif %}

        var empty = (value == '' || value == '|empty=false');
        if (empty) {
            $(this).closest('th').removeClass('filtered');
        } else {
            $(this).closest('th').addClass('filtered');
        }

        if ({{ tableVar }}_table.column({{ loop.index0 }}).search() !== value) {
            throttle = window.setTimeout(function() {
                {{ tableVar }}_table.column({{ loop.index0 }})
                        .search(value)
                        .draw();
            }, 200);
        }
    };

    $('#{{ tableId }}_{{ column.name }}_filter').on('change', function() {
        onTextChange($(this));
    });
    $('#{{ tableId }}_{{ column.name }}_filter').on('keypress keyup', function(event) {
        if ('Enter' == event.key || 13 == event.keyCode) {
            event.preventDefault();
        }
        onTextChange($(this));
    });
    {% elseif column.options.filter == 'select' %}
    $('#{{ tableId }}_{{ column.name }}_filter').on('change', function() {
        var value = $(this).val();
        {% if column.options.filter_empty %}
        value += '|empty=' + {{ tableId }}_{{ column.name }}_filter_empty.toString();
        {% endif %}

        var empty = (value == '' || value == '|empty=false');
        if (empty) {
            $(this).closest('th').removeClass('filtered');
        } else {
            $(this).closest('th').addClass('filtered');
        }

        {{ tableVar }}_table.column({{ loop.index0 }})
            .search(value)
            .draw();
    });
    {% endif %}


{% endfor %}

{'fraction_non_alphanumeric': 0.20001886080724254, 'fraction_numerical': 0.004337985665786495, 'mean_word_length': 1.8825767871704266, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '216709', 'n_tokens_mistral': 3280, 'n_tokens_neox': 3008, 'n_words': 602}