PageSourceSearch

https://www.economicsandpeace.org/wp-content/themes/iep/assets/js/ajax_filter.js?ver=1790843399

js economicsandpeace.org collected 2026-10-01 08:58:32 UTC 6,141 bytes, 277 lines download raw bytes

1(function ($) {
2	function showLoader(elm) {
3		if (elm) {
4			elm.html(`<p class="mt-5 text-center">Loading...</p>`);
5		}
6	}
7	function loadreports(page = 1) {
8		const clContainer = $(".reports-list");
9
10		$(document).on(
11			"change",
12			".filter-wrap.research-report-wrap select",
13			function () {
14				showLoader(clContainer);
15
16				let category =  $('#category').find(":selected").val();
17				let type =  $('#type').find(":selected").val();
18				let year =  $('#year').find(":selected").val();
19				var page = page;
20
21				$.post(
22					mlObj.ajax_url,
23					{
24						action: 'report_filter',
25						type: type,
26						cat: category,
27						year: year,
28						page: page,
29						nonce: mlObj.nonce,
30					},
31					function (response) {
32						clContainer.html(response);
33						console.log(response);
34						// $("html, body").animate({ scrollTop: $('.all_posts').offset().top -100 });
35					}
36				);
37			}
38		);
39		function delay(callback, ms) {
40			var timer = 0;
41			return function() {
42			  var context = this, args = arguments;
43			  clearTimeout(timer);
44			  timer = setTimeout(function () {
45				callback.apply(context, args);
46			  }, ms || 0);
47			};
48		};
49		let searchInput = $('#reports-search');
50		searchInput.keyup(delay(function (e) {
51			var value = $(this).val();
52			var page = page;
53			$.post(
54				mlObj.ajax_url,
55				{
56					action: 'report_filter',
57					search: value,
58					page: page,
59					nonce: mlObj.nonce,
60				},
61				function (response) {
62					clContainer.html(response);
63				}
64			);
65
66		}, 500));
67	}
68
69	function loadCaseStudy(page = 1) {
70		const caseStudyContainer = $(".case-study-list");
71
72		$(document).on(
73			"change",
74			".case-study-filter-wrap.filter-wrap select",
75			function () {
76				showLoader(caseStudyContainer);
77
78				let category =  $('#category').find(":selected").val();
79				let location =  $('#location').find(":selected").val();
80				var page = page;
81
82				$.post(
83					mlObj.ajax_url,
84					{
85						action: 'case_study_filter',
86						cat: category,
87						location: location,
88						nonce: mlObj.nonce,
89					},
90					function (response) {
91						caseStudyContainer.html(response);
92						console.log(response);
93						// $("html, body").animate({ scrollTop: $('.all_posts').offset().top -100 });
94					}
95				);
96			}
97		);
98		function delay(callback, ms) {
99			var timer = 0;
100			return function() {
101			  var context = this, args = arguments;
102			  clearTimeout(timer);
103			  timer = setTimeout(function () {
104				callback.apply(context, args);
105			  }, ms || 0);
106			};
107		};
108		let searchInput1 = $('#case-study-search');
109		searchInput1.keyup(delay(function (e) {
110			var value = $(this).val();
111			var page = page;
112			$.post(
113				mlObj.ajax_url,
114				{
115					action: 'case_study_filter',
116					search: value,
117					page: page,
118					nonce: mlObj.nonce,
119				},
120				function (response) {
121					caseStudyContainer.html(response);
122				}
123			);
124
125		}, 500));
126	}
127
128	function loadEvents(page = 1) {
129		const eventContainer = $(".event-list");
130
131		$(document).on(
132			"change",
133			".event-filter-wrap.filter-wrap select",
134			function () {
135				showLoader(eventContainer);
136
137				let category =  $('#category').find(":selected").val();
138				let location =  $('#location').find(":selected").val();
139				var page = page;
140
141				$.post(
142					mlObj.ajax_url,
143					{
144						action: 'event_filter',
145						cat: category,
146						location: location,
147						nonce: mlObj.nonce,
148					},
149					function (response) {
150						eventContainer.html(response);
151						console.log(response);
152						// $("html, body").animate({ scrollTop: $('.all_posts').offset().top -100 });
153					}
154				);
155			}
156		);
157		function delay(callback, ms) {
158			var timer = 0;
159			return function() {
160			  var context = this, args = arguments;
161			  clearTimeout(timer);
162			  timer = setTimeout(function () {
163				callback.apply(context, args);
164			  }, ms || 0);
165			};
166		};
167		let searchInput1 = $('#event-search');
168		searchInput1.keyup(delay(function (e) {
169			var value = $(this).val();
170			var page = page;
171			$.post(
172				mlObj.ajax_url,
173				{
174					action: 'event_filter',
175					search: value,
176					page: page,
177					nonce: mlObj.nonce,
178				},
179				function (response) {
180					eventContainer.html(response);
181				}
182			);
183
184		}, 500));
185	}
186
187	function handlePagination() {
188
189		const clContainer = $(".reports-list");
190		const caseStudyContainer = $(".case-study-list");
191		const eventContainer = $(".event-list");
192		
193
194		$(document).on("click", ".reports-list .pagination a", function (event) {
195			event.preventDefault();
196
197			var page = $(this).attr("href").split("/").pop();
198				let category =  $('#category').find(":selected").val();
199				let type =  $('#type').find(":selected").val();
200				let year =  $('#year').find(":selected").val();
201
202			$("#current-page").val(page);
203            console.log(page)
204
205			showLoader(clContainer);
206
207			$.post(
208				mlObj.ajax_url,
209				{
210					action: 'report_filter',
211					page: page,
212					type: type,
213					cat: category,
214					year: year,
215					nonce: mlObj.nonce,
216				},
217				function (response) {
218					clContainer.html(response);
219					
220				}
221			);
222			window.scrollTo({top: 600, behavior: 'smooth'});
223		});
224
225		$(document).on("click", ".case-study-list .pagination a", function (event) {
226			event.preventDefault();
227			var page = $(this).attr("href").split("/").pop();
228			$("#current-page").val(page);
229            console.log(page)
230
231			showLoader(caseStudyContainer);
232
233			$.post(
234				mlObj.ajax_url,
235				{
236					action: 'case_study_filter',
237					page: page,
238					nonce: mlObj.nonce,
239				},
240				function (response) {
241					caseStudyContainer.html(response);
242					
243				}
244			);
245			window.scrollTo({top: 600, behavior: 'smooth'});
246		});
247
248		$(document).on("click", ".event-list .pagination a", function (event) {
249			event.preventDefault();
250			var page = $(this).attr("href").split("/").pop();
251			$("#current-page").val(page);
252            console.log(page)
253
254			showLoader(eventContainer);
255
256			$.post(
257				mlObj.ajax_url,
258				{
259					action: 'event_filter',
260					page: page,
261					nonce: mlObj.nonce,
262				},
263				function (response) {
264					eventContainer.html(response);
265					
266				}
267			);
268			window.scrollTo({top: 600, behavior: 'smooth'});
269		});
270	}
271
272	loadreports();
273	loadCaseStudy();
274	loadEvents();
275	handlePagination();
276
277})(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.