PageSourceSearch

https://skal.fi/wp-content/themes/skal/assets/js/ajax-load-more.js?ver=1790890602

js skal.fi collected 2026-10-02 06:40:50 UTC 3,097 bytes, 68 lines download raw bytes

1(function($){ // use jQuery code inside this to avoid "$ is not defined" error
2    console.log('loadmore init');
3	$(document).ready(function(){
4        $('.loadmore').click(function(e){
5            load_posts(e);
6        });
7    });
8    function load_posts(btn_src) {
9        var button = $(btn_src.target);
10        var block_id = button.attr('data-blockid');
11        var data = {
12            'action': 'loadmore',
13            'post_type': button.attr('data-posttype'),
14            'posts_per_page': parseInt(button.attr('data-cols'))
15        };
16        console.log(data);
17        if (typeof loadmore_params.args == 'object') { // we have multiple loops
18            data.query = loadmore_params.args[block_id].posts;
19            data.page = loadmore_params.args[block_id].current_page;
20        }
21        else {
22            data.query = loadmore_params.posts;
23            data.page = loadmore_params.current_page;
24        }
25        if ($('.education-type-filters [type="radio"]:checked').length > 0) {
26            data.edu_type = $('.education-type-filters [type="radio"]:checked').val();
27        }
28        // console.log(data.query);
29        $.ajax({ // you can also use $.post here
30            url : loadmore_params.ajaxurl, // AJAX handler
31            data : data,
32            type : 'POST',
33            beforeSend : function ( xhr ) {
34                button.text(loadmore_params.lang.loading); // change the button text, you can also add a preloader image
35            },
36            success : function( data ){
37                if( data ) {
38                    button.text(loadmore_params.lang.load_more);
39                    button.parent().prev('.news-loop').append(data);
40                    if (typeof loadmore_params.args == 'object') {
41                        loadmore_params.args[block_id].current_page++;
42                        if ( loadmore_params.args[block_id].current_page == loadmore_params.args[block_id].max_page ) {
43                            button.remove(); // if last page, remove the button
44                        }
45                    }
46                    else {
47                        loadmore_params.current_page++;
48                        if ( loadmore_params.current_page == loadmore_params.max_page ) {
49                            button.remove(); // if last page, remove the button
50                        }
51                    }
52                    loadmore_params.current_page++;
53                    if ( loadmore_params.current_page == loadmore_params.max_page ) {
54                        button.remove(); // if last page, remove the button
55                    }
56                    // you can also fire the "post-load" event here if you use a plugin that requires it
57                    // $( document.body ).trigger( 'post-load' );
58                } else {
59                    console.log('success, but no data');
60                    button.remove(); // if no data, remove the button as well
61                }
62            },
63            error: function(){
64                console.log("posts could not be fetched");
65            }
66        });
67    }
68})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.