<commit_before>// datatable configuration.

function HQReportDataTables(options) {
    var self = this;
    self.dataTableElem = options.dataTableElem || '.datatable';
    self.paginationType = options.paginationType || 'bootstrap';
    self.defaultRows = options.defaultRows || 10;
    self.startAtRowNum = options.startAtRowNum || 0;
    self.aoColumns = options.aoColumns;
    self.autoWidth = (options.autoWidth != undefined) ? options.autoWidth : true;
    self.customSort = options.customSort;
    self.ajaxParams = options.ajaxParams || new Object();
    self.ajaxSource = options.ajaxSource;

    this.render = function () {

        $('[data-datatable-highlight-closest]').each(function () {
           $(this).closest($(this).attr('data-datatable-highlight-closest')).addClass('active');
        });
        $('[data-datatable-tooltip]').each(function () {
            $(this).tooltip({
                placement: $(this).attr('data-datatable-tooltip'),
                title: $(this).attr('data-datatable-tooltip-text')
            });
        });

        var dataTablesDom = "frt<'row-fluid dataTables_control'<'span5'il><'span7'p>>";
        $(self.dataTableElem).each(function(){
            var params = {
                sDom: dataTablesDom,
                sPaginationType: self.paginationType,
                iDisplayLength: self.defaultRows,
                bAutoWidth: self.autoWidth
            },
                sAjaxSource = self.ajaxSource;

            if(self.ajaxSource) {
                params.bServerSide = true;
                params.sAjaxSource = self.ajaxSource;
                params.bSort = false;
                params.bFilter = $(this).data('filter') || false;
                params.fnServerParams = function ( aoData ) {
                    for (var p in self.ajaxParams) {
                        var currentParam = self.ajaxParams[p];
                        if(_.isObject(currentParam.value)) {
                            for (var j=0; j < currentParam.value.length; j++) {
                                aoData.push({
                                    name: currentParam.name,
                                    value: currentParam.value[j]
                                });
                            }
                        } else {
                            aoData.push(currentParam);
                        }
                    }
                };
            }
            if(self.aoColumns)
                params.aoColumns = self.aoColumns;

            var datatable = $(this).dataTable(params);
            if(self.customSort)
                datatable.fnSort( self.customSort );


            var $dataTablesFilter = $(".dataTables_filter");
            if($dataTablesFilter && $("#extra-filter-info")) {
                $("#extra-filter-info").append($dataTablesFilter);
                $dataTablesFilter.addClass("form-search");
                var $inputField = $dataTablesFilter.find("input"),
                    $inputLabel = $dataTablesFilter.find("label");

                $dataTablesFilter.append($inputField);
                $inputField.attr("id", "dataTables-filter-box");
                $inputField.addClass("search-query").addClass("input-medium");<commit_msg>added loading data indicator<commit_after>// datatable configuration.

function HQReportDataTables(options) {
    var self = this;
    self.dataTableElem = options.dataTableElem || '.datatable';
    self.paginationType = options.paginationType || 'bootstrap';
    self.defaultRows = options.defaultRows || 10;
    self.startAtRowNum = options.startAtRowNum || 0;
    self.aoColumns = options.aoColumns;
    self.autoWidth = (options.autoWidth != undefined) ? options.autoWidth : true;
    self.customSort = options.customSort;
    self.ajaxParams = options.ajaxParams || new Object();
    self.ajaxSource = options.ajaxSource;
    self.loadingText = options.loadingText || "Loading...";
    self.emptyText = options.emptyText || "No data available to display. Please try changing your filters.";

    this.render = function () {

        $('[data-datatable-highlight-closest]').each(function () {
           $(this).closest($(this).attr('data-datatable-highlight-closest')).addClass('active');
        });
        $('[data-datatable-tooltip]').each(function () {
            $(this).tooltip({
                placement: $(this).attr('data-datatable-tooltip'),
                title: $(this).attr('data-datatable-tooltip-text')
            });
        });

        var dataTablesDom = "frt<'row-fluid dataTables_control'<'span5'il><'span7'p>>";
        $(self.dataTableElem).each(function(){
            var params = {
                sDom: dataTablesDom,
                sPaginationType: self.paginationType,
                iDisplayLength: self.defaultRows,
                bAutoWidth: self.autoWidth
            };

            if(self.ajaxSource) {
                params.bServerSide = true;
                params.sAjaxSource = self.ajaxSource;
                params.bSort = false;
                params.bFilter = $(this).data('filter') || false;
                params.fnServerParams = function ( aoData ) {
                    for (var p in self.ajaxParams) {
                        var currentParam = self.ajaxParams[p];
                        if(_.isObject(currentParam.value)) {
                            for (var j=0; j < currentParam.value.length; j++) {
                                aoData.push({
                                    name: currentParam.name,
                                    value: currentParam.value[j]
                                });
                            }
                        } else {
                            aoData.push(currentParam);
                        }
                    }
                };
            }
            params.oLanguage = {
                sProcessing: self.loadingText,
                sLoadingRecords: self.loadingText,
                sZeroRecords: self.emptyText
            };

            if(self.aoColumns)
                params.aoColumns = self.aoColumns;

            var datatable = $(this).dataTable(params);
            console.log(params);
            if(self.customSort)
                datatable.fnSort( self.customSort );


            var $dataTablesFilter = $(".dataTables_filter");
            if($dataTablesFilter && $("#extra-filter-info")) {
                $("#extra-filter-info").append($dataTablesFilter);
                $dataTablesFilter.addClass("form-search");
                var $inputField = $dataTablesFilter.find("input"),
                    $inputLabel = $dataTablesFilter.find("label");

                $dataTablesFilter.append($inputField);
                $inputField.attr("id", "dataTables-filter-box");
                $inputField.addClass("search-query").addClass("input-medium");
{'fraction_non_alphanumeric': 0.12489070241911979, 'fraction_numerical': 0.0017487612940833576, 'mean_word_length': 1.6447013487475914, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2895599', 'n_tokens_mistral': 1786, 'n_tokens_neox': 1698, 'n_words': 267}