<commit_before>/*** datatable[{{id}}]: ***/
$(document).ready(function(){
    function getId() { return "{{id}}"; };
    function getWrapper() { return  "#{{id}}_wrapper"; };
    var s = getWrapper();
    var multiple = {% if multiple %} true {% else %} false {% endif %};
    var multiple_rawhtml = '';
    {% if multiple %}
        var multiple_rawhtml = '\
                <label class="dataTables_multiple">\
                <span style="margin:0 40px 0 0px;">\
                    Execute\
                    <select name="dataTables[select]" class="form-control input-sm">\
                        {% for key,item in multiple %}\
                        <option value="{{ path(item.route) }}">{{item.title}}</option>\
                        {% endfor %}\
                    </select>\
                    <button class="btn-datatable-multiple  btn btn-default btn-sm">OK</button>\
                <span>\
                </label>';
    {% endif %}
    var $js_conf = {{ js_conf | raw }};
    var $js = {};
    for(key in $js_conf) { 
        if ($js_conf.hasOwnProperty(key)) {
            eval ( ' $js["'+key+'"] = ' + $js_conf[key]+ ' ; ' ); 
        }
    }
    var $options = {{ js | raw }};
    var $opts = {};
    for(key in $options) {
        if ($options.hasOwnProperty(key)) {
            $opts[key] = $options[key];
            try{
                var type = typeof (eval (' tmp = ' + $options[key] + ' ; '));
                if (type == 'object' || type == 'function'){
                    eval (' $opts["' + key + '"] = ' + $options[key] + ' ; ');
                }
            }catch (e){ }
        }
    }
    $options = $opts;
    var $aoColumnDefs = new Array();
    {% if multiple %}
    $aoColumnDefs.push({ 'bSortable': false, 'aTargets': [ 0 ] });
    {% endif %}
    {% if action and not action_twig %} 
    $aoColumnDefs.push({
        "mRender": function ( data, type, full ) {
            var $edit_url = "{{ path(edit_route , { 'id': "xx" }) }}".replace("xx", data);
            var $link_edit = "<a  style='float:right; margin-right:10px' class='dialog' title='edit' ";
            $link_edit += "href='"+$edit_url+"'>";
            $link_edit += '<span class="glyphicon glyphicon-edit" aria-hidden="true"></span></a>';
            var $delete_url = "{{ path(delete_route, { 'id': "xx" }) }}".replace("xx", data);
            var $link_delete = "<form style='float:right' class='form' action='"+$delete_url+"' method='post'>";
            $link_delete += '{{ form_widget(delete_form) }}'.replace("_id_", data);
            $link_delete += "<a class='button-delete' title='delete' href type='submit'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span></a>";
            $link_delete += " </form>";
            var $out = $link_delete+ " " + $link_edit ;
            if (data == null )
            {
                $out = "<div style='float:right'>{{ 'ali.common.no_action'|trans() }}</div>";
            }
            return $out
        },
        "aTargets": [ multiple ? {{fields|length}} : ({{fields|length}} -1)  ]
    });
    {% endif %} 
    var $defaults = {
        "bJQueryUI": false,
        "sPaginationType": "full_numbers",
        "aLengthMenu": [[5,10, 25, 50, -1], [5,10, 25, 50, "All"]],
        "iDisplayLength": 10,
        "bServerSide": true,
        "bProcessing": true,
        "sAjaxSource": null,
        "bPaginate": true,
        {% if sort %}
        "aaSorting": [[ {{sort[0]}}, "{{sort[1]}}" ]],
        {% endif %}
        "bLengthChange": true,
        "aoColumnDefs": $aoColumnDefs,
        "fnDrawCallback": function(oSettings) {
            var s = getWrapper();
            if( multiple && $('.dataTables_multiple',$(s)).length==0){
                $(s+' .dataTables_length').prepend(multiple_rawhtml);
            }
        },
        "bSort": true,
        "bFilter": {% if search %} true {% else %} false {% endif %},
        "oLanguage": {
            "sProcessing":     '{{ 'ali.common.sProcessing' | trans() }}',
            "sLengthMenu":     '{{ 'ali.common.sLengthMenu' | trans() }}',
            "sZeroRecords":    '{{ 'ali.common.sZeroRecords' | trans() }}',
            "sInfo":           '{{ 'ali.common.sInfo' | trans() }}',
            "sInfoEmpty":      '{{ 'ali.common.sInfoEmpty' | trans() }}',
            "sInfoFiltered":   '{{ 'ali.common.sInfoFiltered' | trans() }}',
            "sInfoPostFix":    '{{ 'ali.common.sInfoPostFix' | trans() }}',
            "sSearch":         '{{ 'ali.common.sSearch' | trans() }}',
            "sLoadingRecords": '{{ 'ali.common.sLoadingRecords' | trans() }}',
            "sUrl":            "",
            "oPaginate": {
                "sFirst":    '{{ 'ali.common.sFirst' | trans() }}',
                "sPrevious": '{{ 'ali.common.sPrevious' | trans() }}',
                "sNext":     '{{ 'ali.common.sNext' | trans() }}',
                "sLast":     '{{ 'ali.common.sLast' | trans() }}'
            }
        },
        "bAutoWidth" : false
    };
    $.extend($defaults,$js);
    $.extend($defaults,$options);
    $('#{{id}}').trigger('datatables_init', $defaults );
    eval("var "+ "oTable_"+'{{id}}'.split('-').join('_') + "  = $('#{{id}}').dataTable($defaults)");
    $(s).on('click','.button-delete:parent',function(e){
        if (!confirm('{{ 'ali.common.confirm_delete'|trans()  }}')) {
            return false;
        }
        $(this).parents('form:eq(0)').submit();
    });

    if (multiple===true) { 
        var chbox =  'input:checkbox[name="dataTables[actions][]"]';
        var chbox_all = 'input:checkbox[name="datatable_action_all"]';
        $(s).on('click','.btn-datatable-multiple:not(.search_init)',function(e){
            if($('input:focus',$(s)).length > 0){
                return false;
            }
            e.preventDefault();
            if($(chbox+':checked').length > 0){
                if (!confirm('Are you sure ?')) {
                    return false;
                }
                var form = $(this).parents('form:eq(0)');
                var action = $('select[name="dataTables[select]"]',$(s)).val();
                $.ajax({
                    type: "POST",
                    url: action,
                    data: form.serialize(),
                    success: function(msg) {
                        $('#'+getId()).dataTable().fnDraw();
                        if ($.isFunction($.fn.unblockpage)){
                            $.unblockpage();
                        }
                    },
                    beforeSend: function() {
                        if ($.isFunction($.fn.blockpage)){
                            $.blockpage({
                                msg: 'saving data'
                            });
                        }
                    }
                });
            } else {
                alert('You need to select at least one element.');
            }
        });
        $(s).on('click',chbox_all,function(e){
            if($(this).is(':checked')) {
                $(chbox,$(s)).attr("checked",false).click();
            } else {
                $(chbox,$(s)).attr("checked",true).click();
            }
        });
    }

    {% if search %}
    $(".dataTables_filter").remove();
    var search_selector = "#{{id}} input[searchable=true]";
    var timeout;
    $(search_selector).keyup( function (e) {
        if ($.inArray(e.which, [9, 16]) == -1) {
            var index = $(this).attr('index');
            var self = this;
            clearTimeout(timeout);
            timeout = setTimeout(function () {
                var oTable = eval('oTable_{{id}}'.split('-').join('_'));
                console.log(self.value);
                console.log(self);
                oTable.fnFilter(
                    self.value,
                    oTable.oApi._fnVisibleToColumnIndex(
                        oTable.fnSettings(),
                        index
                    )
                );
            }, 700);
        }
    }).each( function (i) {
        this.initVal = this.value;
    }).focus( function () {
        if ( this.className.match(/\bsearch_init\b/) ){
            this.className.replace(/\bsearch_init\b/g, '').trim();
        }
    }).blur( function (i) {
        if ( this.value == "" ){
            this.className = (this.className.match(/\bsearch_init\b/)) ? this.className : this.className.trim() + " search_init";
            this.value = this.initVal;
        }
    });
    {% endif %}
});<commit_msg>cleanup debug commands<commit_after>/*** datatable[{{id}}]: ***/
$(document).ready(function(){
    function getId() { return "{{id}}"; };
    function getWrapper() { return  "#{{id}}_wrapper"; };
    var s = getWrapper();
    var multiple = {% if multiple %} true {% else %} false {% endif %};
    var multiple_rawhtml = '';
    {% if multiple %}
        var multiple_rawhtml = '\
                <label class="dataTables_multiple">\
                <span style="margin:0 40px 0 0px;">\
                    Execute\
                    <select name="dataTables[select]" class="form-control input-sm">\
                        {% for key,item in multiple %}\
                        <option value="{{ path(item.route) }}">{{item.title}}</option>\
                        {% endfor %}\
                    </select>\
                    <button class="btn-datatable-multiple  btn btn-default btn-sm">OK</button>\
                <span>\
                </label>';
    {% endif %}
    var $js_conf = {{ js_conf | raw }};
    var $js = {};
    for(key in $js_conf) { 
        if ($js_conf.hasOwnProperty(key)) {
            eval ( ' $js["'+key+'"] = ' + $js_conf[key]+ ' ; ' ); 
        }
    }
    var $options = {{ js | raw }};
    var $opts = {};
    for(key in $options) {
        if ($options.hasOwnProperty(key)) {
            $opts[key] = $options[key];
            try{
                var type = typeof (eval (' tmp = ' + $options[key] + ' ; '));
                if (type == 'object' || type == 'function'){
                    eval (' $opts["' + key + '"] = ' + $options[key] + ' ; ');
                }
            }catch (e){ }
        }
    }
    $options = $opts;
    var $aoColumnDefs = new Array();
    {% if multiple %}
    $aoColumnDefs.push({ 'bSortable': false, 'aTargets': [ 0 ] });
    {% endif %}
    {% if action and not action_twig %} 
    $aoColumnDefs.push({
        "mRender": function ( data, type, full ) {
            var $edit_url = "{{ path(edit_route , { 'id': "xx" }) }}".replace("xx", data);
            var $link_edit = "<a  style='float:right; margin-right:10px' class='dialog' title='edit' ";
            $link_edit += "href='"+$edit_url+"'>";
            $link_edit += '<span class="glyphicon glyphicon-edit" aria-hidden="true"></span></a>';
            var $delete_url = "{{ path(delete_route, { 'id': "xx" }) }}".replace("xx", data);
            var $link_delete = "<form style='float:right' class='form' action='"+$delete_url+"' method='post'>";
            $link_delete += '{{ form_widget(delete_form) }}'.replace("_id_", data);
            $link_delete += "<a class='button-delete' title='delete' href type='submit'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span></a>";
            $link_delete += " </form>";
            var $out = $link_delete+ " " + $link_edit ;
            if (data == null )
            {
                $out = "<div style='float:right'>{{ 'ali.common.no_action'|trans() }}</div>";
            }
            return $out
        },
        "aTargets": [ multiple ? {{fields|length}} : ({{fields|length}} -1)  ]
    });
    {% endif %} 
    var $defaults = {
        "bJQueryUI": false,
        "sPaginationType": "full_numbers",
        "aLengthMenu": [[5,10, 25, 50, -1], [5,10, 25, 50, "All"]],
        "iDisplayLength": 10,
        "bServerSide": true,
        "bProcessing": true,
        "sAjaxSource": null,
        "bPaginate": true,
        {% if sort %}
        "aaSorting": [[ {{sort[0]}}, "{{sort[1]}}" ]],
        {% endif %}
        "bLengthChange": true,
        "aoColumnDefs": $aoColumnDefs,
        "fnDrawCallback": function(oSettings) {
            var s = getWrapper();
            if( multiple && $('.dataTables_multiple',$(s)).length==0){
                $(s+' .dataTables_length').prepend(multiple_rawhtml);
            }
        },
        "bSort": true,
        "bFilter": {% if search %} true {% else %} false {% endif %},
        "oLanguage": {
            "sProcessing":     '{{ 'ali.common.sProcessing' | trans() }}',
            "sLengthMenu":     '{{ 'ali.common.sLengthMenu' | trans() }}',
            "sZeroRecords":    '{{ 'ali.common.sZeroRecords' | trans() }}',
            "sInfo":           '{{ 'ali.common.sInfo' | trans() }}',
            "sInfoEmpty":      '{{ 'ali.common.sInfoEmpty' | trans() }}',
            "sInfoFiltered":   '{{ 'ali.common.sInfoFiltered' | trans() }}',
            "sInfoPostFix":    '{{ 'ali.common.sInfoPostFix' | trans() }}',
            "sSearch":         '{{ 'ali.common.sSearch' | trans() }}',
            "sLoadingRecords": '{{ 'ali.common.sLoadingRecords' | trans() }}',
            "sUrl":            "",
            "oPaginate": {
                "sFirst":    '{{ 'ali.common.sFirst' | trans() }}',
                "sPrevious": '{{ 'ali.common.sPrevious' | trans() }}',
                "sNext":     '{{ 'ali.common.sNext' | trans() }}',
                "sLast":     '{{ 'ali.common.sLast' | trans() }}'
            }
        },
        "bAutoWidth" : false
    };
    $.extend($defaults,$js);
    $.extend($defaults,$options);
    $('#{{id}}').trigger('datatables_init', $defaults );
    eval("var "+ "oTable_"+'{{id}}'.split('-').join('_') + "  = $('#{{id}}').dataTable($defaults)");
    $(s).on('click','.button-delete:parent',function(e){
        if (!confirm('{{ 'ali.common.confirm_delete'|trans()  }}')) {
            return false;
        }
        $(this).parents('form:eq(0)').submit();
    });

    if (multiple===true) { 
        var chbox =  'input:checkbox[name="dataTables[actions][]"]';
        var chbox_all = 'input:checkbox[name="datatable_action_all"]';
        $(s).on('click','.btn-datatable-multiple:not(.search_init)',function(e){
            if($('input:focus',$(s)).length > 0){
                return false;
            }
            e.preventDefault();
            if($(chbox+':checked').length > 0){
                if (!confirm('Are you sure ?')) {
                    return false;
                }
                var form = $(this).parents('form:eq(0)');
                var action = $('select[name="dataTables[select]"]',$(s)).val();
                $.ajax({
                    type: "POST",
                    url: action,
                    data: form.serialize(),
                    success: function(msg) {
                        $('#'+getId()).dataTable().fnDraw();
                        if ($.isFunction($.fn.unblockpage)){
                            $.unblockpage();
                        }
                    },
                    beforeSend: function() {
                        if ($.isFunction($.fn.blockpage)){
                            $.blockpage({
                                msg: 'saving data'
                            });
                        }
                    }
                });
            } else {
                alert('You need to select at least one element.');
            }
        });
        $(s).on('click',chbox_all,function(e){
            if($(this).is(':checked')) {
                $(chbox,$(s)).attr("checked",false).click();
            } else {
                $(chbox,$(s)).attr("checked",true).click();
            }
        });
    }

    {% if search %}
    $(".dataTables_filter").remove();
    var search_selector = "#{{id}} input[searchable=true]";
    var timeout;
    $(search_selector).keyup( function (e) {
        if ($.inArray(e.which, [9, 16]) == -1) {
            var index = $(this).attr('index');
            var self = this;
            clearTimeout(timeout);
            timeout = setTimeout(function () {
                var oTable = eval('oTable_{{id}}'.split('-').join('_'));
                oTable.fnFilter(
                    self.value,
                    oTable.oApi._fnVisibleToColumnIndex(
                        oTable.fnSettings(),
                        index
                    )
                );
            }, 700);
        }
    }).each( function (i) {
        this.initVal = this.value;
    }).focus( function () {
        if ( this.className.match(/\bsearch_init\b/) ){
            this.className.replace(/\bsearch_init\b/g, '').trim();
        }
    }).blur( function (i) {
        if ( this.value == "" ){
            this.className = (this.className.match(/\bsearch_init\b/)) ? this.className : this.className.trim() + " search_init";
            this.value = this.initVal;
        }
    });
    {% endif %}
});
{'fraction_non_alphanumeric': 0.19602390391101118, 'fraction_numerical': 0.004733447724986687, 'mean_word_length': 1.641763050953423, 'pattern_counts': {'":': 64, '<': 47, '<?xml version=': 0, '>': 51, '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': '5095329', 'n_tokens_mistral': 5155, 'n_tokens_neox': 4906, 'n_words': 868}