<commit_before>'use strict';

var InfiniteScroll = angular.module('converge.modules.infinitescroll', []);

var pageBottomCallbacks = [];

var $InfiniteScroll = {
    addPageBottomCallback: function (callback) {
        pageBottomCallbacks.push(callback);

        return function () {
            pageBottomCallbacks = _.filter(pageBottomCallbacks, function (cb) {
                return cb != callback;
            });
        };
    }
};

InfiniteScroll.value('$InfiniteScroll', $InfiniteScroll);

var strgrsdeds = _.debounce(function (e) {
    // Yes, always re-calc these values
    // The user may have resized windows, we may have added items, etc.
    var $window = $(window);

    var visibleHeight = $window.innerHeight();
    var docHeight = $(document).innerHeight();

    var currentScrollPosition = $window.scrollTop();
    var scrollHeight = docHeight - visibleHeight;

    if ((scrollHeight - currentScrollPosition) < 100) {
        for (var i = pageBottomCallbacks.length - 1; i >= 0; i--) {
            pageBottomCallbacks[i]();
        };
    }
}, 300);

$(window).scroll(strgrsdeds);
<commit_msg>adding comments<commit_after>'use strict';

var InfiniteScroll = angular.module('converge.modules.infinitescroll', []);

var pageBottomCallbacks = [];

var $InfiniteScroll = {
    addPageBottomCallback: function (callback) {
        pageBottomCallbacks.push(callback);

        // TODO: Test this function. I don't remember JavaScript well enough to
        //       know whether `cb != callback` actually works.
        // Consideration: Have the callback remove only this specific instance,
        //                or have it remove *all* instances?
        return function () {
            pageBottomCallbacks = _.filter(pageBottomCallbacks, function (cb) {
                return cb != callback;
            });
        };
    }
};

InfiniteScroll.value('$InfiniteScroll', $InfiniteScroll);

var strgrsdeds = _.debounce(function (e) {
    // Yes, always re-calc these values
    // The user may have resized windows, we may have added items, etc.
    var $window = $(window);

    var visibleHeight = $window.innerHeight();
    var docHeight = $(document).innerHeight();

    var currentScrollPosition = $window.scrollTop();
    var scrollHeight = docHeight - visibleHeight;

    if ((scrollHeight - currentScrollPosition) < 100) {
        for (var i = pageBottomCallbacks.length - 1; i >= 0; i--) {
            pageBottomCallbacks[i]();
        };
    }
}, 300);

$(window).scroll(strgrsdeds);

{'fraction_non_alphanumeric': 0.12360890302066772, 'fraction_numerical': 0.006359300476947536, 'mean_word_length': 2.7906626506024095, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4802364', 'n_tokens_mistral': 723, 'n_tokens_neox': 696, 'n_words': 185}