PageSourceSearch

https://www.jsm.com/wp-content/themes/jsm/assets/js/publications.js?ver=1.0.0

js jsm.com collected 2026-10-01 12:38:05 UTC 3,349 bytes, 87 lines download raw bytes

1(function($) {
2    $(document).ready(function() {
3        var taxName =  $('.filter-block').data('tax');
4        const lang = document.documentElement.lang;
5        function publicationsAjax(paged = 1, sortBy = 'most_recent') {
6            $.ajax({
7                url: jsm_ajax_object.ajax_url,
8                type: 'POST',
9                data: {
10                    action: 'load_more_publications',
11                    paged: paged,
12                    sortBy: sortBy,
13                    taxName: taxName,
14                },
15                success: function(response) {
16                    try {
17                        const data = JSON.parse(response);
18                        if (data.paged === 1) {
19                            $('.insights-list').html(data.html);
20                        } else {
21                            $('.insights-list').append(data.html);
22                        }
23
24                        // Hide load more button if no more results
25                        if (data.paged >= data.max_num_pages || data.real_total_results < 9) {
26                            $('.pub-load-more-container').hide();
27                        } else {
28                            $('.pub-load-more-container').show();
29                        }
30
31                        // Display results count
32                        const currentPage = data.current_page || 0;
33                        const postsPerPage = data.posts_per_page || 0; 
34                        const totalPosts = data.total_posts || 0; 
35                        const currentResultsCount = postsPerPage * (currentPage - 1) + (data.html.match(/class="insight-item"/g) || []).length;
36                        let resultsCount;
37                        if (lang === 'zh-CN') {
38                            resultsCount = translations.resultsCount.replace('%s', totalPosts).replace('%s', currentResultsCount);
39                        } else {
40                            resultsCount = translations.resultsCount.replace('%s', currentResultsCount).replace('%s', totalPosts);
41                        }
42                        $('.results-count-pub').text(resultsCount);
43
44                    } catch (e) {
45                        console.error("Error parsing JSON:", e);
46                    }
47
48                }
49
50            });
51        }
52
53        $('.pub-load-more-btn').on('click', function(e) {
54            e.preventDefault();
55
56            const button = $(this);
57            const currentPage = parseInt(button.data('paged')) || 1;
58            const nextPage = currentPage + 1;
59            
60            button.data('paged', nextPage);
61            
62            publicationsAjax(nextPage);
63            
64        });
65
66        // Handle sorting
67        $('.sort-button').on('click', function() {
68            if($('.result-container .insights-list').length == 0) {
69                var sortBy = $(this).data('sort');
70                $('.sort-button').removeClass('active'); 
71                $(this).addClass('active'); 
72
73                $('.pub-load-more-btn').data('paged', 1);
74                publicationsAjax(1, sortBy);
75            }
76        });
77
78        $('.sortby.pub-sort').on('change', function() {
79            const sortBy = $(this).find(":selected").val();
80            publicationsAjax(1, sortBy); 
81            //console.log(sortBy);
82        });
83
84        
85    });
86})(jQuery);
87

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.