<commit_before>'use strict';

define([
    'plugins',
    'lib/utils'
], function(plugins, utils) {
    plugins.pagination = function(config) {
        utils.dispatcher.once('initialize.posts-view', function(view) {

            // Set pagination params
            view.collection.clearPaginationParams();
            if (liveblog.limit) {
                view.collection.syncParams.pagination.limit = parseInt(liveblog.limit, 10);
            }

            view.flags.loadingNextPage = false;

            view.topPage = function() {
                view.collection.clearPaginationParams();
                delete view.collection.syncParams.pagination['order.end'];
                return view.collection.fetchPage();
            };

            view.nextPage = function() {
                if (view.flags.loadingNextPage || !view.hasNextPage()) {
                    return;
                }
                utils.dispatcher.trigger('loading.posts-view', view);
                view.flags.loadingNextPage = true;

                var options = {
                    data: {
                        offset: view.collection.syncParams.pagination.offset + view.collection.syncParams.pagination.limit
                    }
                };

                return view.collection.fetchPage(options).done(function(data) {
                    view.flags.loadingNextPage = false;
                    utils.dispatcher.trigger('loaded.posts-view', view);
                });
            };

            view.hasNextPage = function() {
                return view.collection.length < view.collection.filterProps.total;
            };

            // True if the blog was accessed through a permanent link to a specific post
            // (ex: http://newspaper.de/very-important-liveblog/?liveblog=78)
            view.hasTopPage = function() {
                if (this.flags.hasTopPage) {
                    return true;
                }
                return false;
            };
        });
    };
    return plugins.pagination;
});<commit_msg>Minor pagination plugin refactor: use 'this' instead of 'view'<commit_after>'use strict';

define([
    'plugins',
    'lib/utils'
], function(plugins, utils) {
    plugins.pagination = function(config) {
        utils.dispatcher.once('initialize.posts-view', function(view) {

            // Set pagination params
            view.collection.clearPaginationParams();
            if (liveblog.limit) {
                view.collection.syncParams.pagination.limit = parseInt(liveblog.limit, 10);
            }

            view.flags.loadingNextPage = false;

            view.topPage = function() {
                this.collection.clearPaginationParams();
                delete this.collection.syncParams.pagination['order.end'];
                return this.collection.fetchPage();
            };

            view.nextPage = function() {
                if (this.flags.loadingNextPage || !this.hasNextPage()) {
                    return;
                }
                utils.dispatcher.trigger('loading.posts-view', this);
                this.flags.loadingNextPage = true;

                var options = {
                    data: {
                        offset: this.collection.syncParams.pagination.offset + this.collection.syncParams.pagination.limit
                    }
                };

                var self = this;
                return this.collection.fetchPage(options).done(function(data) {
                    self.flags.loadingNextPage = false;
                    utils.dispatcher.trigger('loaded.posts-view', self);
                });
            };

            view.hasNextPage = function() {
                return this.collection.length < this.collection.filterProps.total;
            };

            // True if the blog was accessed through a permanent link to a specific post
            // (ex: http://newspaper.de/very-important-liveblog/?liveblog=78)
            view.hasTopPage = function() {
                if (this.flags.hasTopPage) {
                    return true;
                }
                return false;
            };
        });
    };
    return plugins.pagination;
});
{'fraction_non_alphanumeric': 0.10746768788894208, 'fraction_numerical': 0.0019147917663954045, 'mean_word_length': 1.4919499105545617, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '405839', 'n_tokens_mistral': 1055, 'n_tokens_neox': 991, 'n_words': 175}