PageSourceSearch

https://sapinsider.org/wp-content/themes/sapi2/js/loadmore-news-results.js?ver=1790727220

js sapinsider.org collected 2026-10-01 10:19:07 UTC 1,797 bytes, 68 lines download raw bytes

1jQuery(document).ready(function ($) {
2	function buildNextPagedUrl(currentHref, nextPage) {
3		var url = new URL(currentHref, window.location.origin);
4		url.pathname = url.pathname.replace(/\/page\/\d+\/?$/, '/');
5		if (!url.pathname.endsWith('/')) {
6			url.pathname += '/';
7		}
8		if (nextPage > 1) {
9			url.pathname += 'page/' + nextPage + '/';
10		}
11		return url.toString();
12	}
13
14	$('#load-more-news-results').on('click', function (event) {
15		event.preventDefault();
16		var button = $(this),
17			page = parseInt(button.data('page')),
18			max = parseInt(button.data('max')),
19			text = button.find('.btn-text'),
20			spinner = button.find('.spinner'),
21			clickedUrl = button.attr('href');
22
23		var queryString = $('#news-query-string').val();
24
25		let promoted = document.querySelector('#promoted_ids').value;
26
27		// Show spinner
28		spinner.show();
29		text.text('Loading...');
30
31		$.ajax({
32			url: news_params.ajaxurl,
33			type: 'POST',
34			data: {
35				action: 'load_more_news_posts',
36				page: page,
37				query_string: queryString,
38				promoted_ids: promoted
39			},
40			success: function (data) {
41				$('.loop-news-results').append(data);
42				button.data('page', page + 1);
43				button.attr('data-page', page + 1);
44				if (clickedUrl) {
45					history.pushState({ page: page + 1 }, '', clickedUrl);
46				}
47
48				if (page + 1 >= max) {
49					button.remove(); // no more pages
50				} else {
51					button.attr('href', buildNextPagedUrl(clickedUrl || window.location.href, page + 2));
52				}
53			},
54			complete: function () {
55				// Hide spinner, reset text
56				spinner.hide();
57				text.text('Show More');
58			}
59		});
60	});
61
62	$(window).on('popstate', function (event) {
63		var state = event.originalEvent ? event.originalEvent.state : null;
64		if (state && typeof state.page !== 'undefined') {
65			window.location.reload();
66		}
67	});
68});  

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.