<commit_before>
var Pager = function(parent, child, spinner, requestContentCb, last_timestamp, options) {
    options = options || {};
    options.offset = options.offset || 100;
    this.rows_shown = 20;
    this.last_timestamp = last_timestamp;
    this.debounce_hold = false;
    this.requestContentCb = requestContentCb;
    this.parent = parent;
    this.child = child;
    this.spinner = spinner;
    this.done = false;
    this.options = options;

    $(parent).scroll(this.scroll_cb.bind(this));
};
Pager.prototype.success_cb = function(data) {
    this.rows_shown += data.length;
    if (data.length == 0) {
        this.done = true;
    }
};
Pager.prototype.finish_request_cb = function() {
    this.debounce_hold = false;
    this.spinner.hide();
};
Pager.prototype.scroll_cb = function() {
    if (this.parent.scrollTop() > this.child.height() - this.parent.height() - this.options.offset) {
        if (this.debounce_hold == false && this.done != true) {
            var promise = this.requestContentCb();
            this.spinner.show();
            promise.always(this.finish_request_cb.bind(this));
            promise.success(this.success_cb.bind(this));
            this.debounce_hold = true;
        }
    }
};

Pager.make_easy_pager = function(api, $parent, table_selector, body_selector, spinner_selector, template, row_template, preprocess) {
    api().success(function(data){
        if(data.length > 0) {
            var last_timestamp = data[data.length-1].created;
            if(preprocess) {
                data = preprocess(data);
            }
            var html = template(data);
            $parent.html(html);

            new Pager($(table_selector),
                $(body_selector),
                $(spinner_selector),
                function request_next_page() {
                    var that = this; // Pager
                    var promise = api(this.last_timestamp);
                    promise.success(function(data){
                        if(data.length > 0) {
                            that.last_timestamp = data[data.length-1].created;
                            if(preprocess) {
                                data =  preprocess(data);
                            }
                            for (var d in data) {
                                var row = data[d];
                                $(body_selector).append(row_template(row))
                            }
                        }
                    });
                    return promise;
                },
                last_timestamp
            );
        }<commit_msg>fix missing headers when no rows in tables<commit_after>
var Pager = function(parent, child, spinner, requestContentCb, last_timestamp, options) {
    options = options || {};
    options.offset = options.offset || 100;
    this.rows_shown = 20;
    this.last_timestamp = last_timestamp;
    this.debounce_hold = false;
    this.requestContentCb = requestContentCb;
    this.parent = parent;
    this.child = child;
    this.spinner = spinner;
    this.done = false;
    this.options = options;

    $(parent).scroll(this.scroll_cb.bind(this));
};
Pager.prototype.success_cb = function(data) {
    this.rows_shown += data.length;
    if (data.length == 0) {
        this.done = true;
    }
};
Pager.prototype.finish_request_cb = function() {
    this.debounce_hold = false;
    this.spinner.hide();
};
Pager.prototype.scroll_cb = function() {
    if (this.parent.scrollTop() > this.child.height() - this.parent.height() - this.options.offset) {
        if (this.debounce_hold == false && this.done != true) {
            var promise = this.requestContentCb();
            this.spinner.show();
            promise.always(this.finish_request_cb.bind(this));
            promise.success(this.success_cb.bind(this));
            this.debounce_hold = true;
        }
    }
};

Pager.make_easy_pager = function(api, $parent, table_selector, body_selector, spinner_selector, template, row_template, preprocess) {
    api().success(function(data){
        if(data.length > 0) {
            var last_timestamp = data[data.length-1].created;
            if(preprocess) {
                data = preprocess(data);
            }

            new Pager($(table_selector),
                $(body_selector),
                $(spinner_selector),
                function request_next_page() {
                    var that = this; // Pager
                    var promise = api(this.last_timestamp);
                    promise.success(function(data){
                        if(data.length > 0) {
                            that.last_timestamp = data[data.length-1].created;
                            if(preprocess) {
                                data =  preprocess(data);
                            }
                            for (var d in data) {
                                var row = data[d];
                                $(body_selector).append(row_template(row))
                            }
                        }
                    });
                    return promise;
                },
                last_timestamp
            );
        }
        var html = template(data);
        $parent.html(html);
{'fraction_non_alphanumeric': 0.1145374449339207, 'fraction_numerical': 0.003830683777054204, 'mean_word_length': 1.595427435387674, 'pattern_counts': {'":': 0, '<': 3, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2728909', 'n_tokens_mistral': 1466, 'n_tokens_neox': 1404, 'n_words': 251}