summaryrefslogtreecommitdiff
path: root/searx/static/plugins/js/infinite_scroll.js
blob: db84a690880f95a5db0ea2db20b96af3bd6ddb34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$(document).ready(function() {
    var win = $(window);
    win.scroll(function() {
        if ($(document).height() - win.height() - win.scrollTop() < 150) {
            var formData = $('#pagination form:last').serialize();
            if (formData) {
                $('#pagination').html('<div class="loading-spinner"></div>');
                $.ajax({
                    type: "POST",
                    url: './',
                    data: formData,
                    dataType: 'html',
                    success: function(data) {
                        var body = $(data);
                        $('#pagination').remove();
                        $('#main_results').append('<hr/>');
                        $('#main_results').append(body.find('.result'));
                        $('#main_results').append(body.find('#pagination'));
                    }
                });
            }
        }
    });
});