PageSourceSearch

https://agiledefense.com/wp-content/themes/palermo/js/ajax-filters.js?ver=7.1.2

js agiledefense.com collected 2026-10-03 19:53:12 UTC 4,947 bytes, 192 lines download raw bytes

1jQuery.noConflict();
2
3jQuery(document).ready(function ($) {
4	$.fn.extend({
5		setPage: function (page) {
6			$(this).find("[name='hidden_page']").val(page);
7			return $(this);
8		},
9		customSerializeArray: function () {
10			const formData = this.serializeArray();
11			formData.forEach((item, index) => {
12				const altName = $('[name="' + item.name + '"]').attr('altname');
13				altName && (formData[index].altname = altName);
14			});
15			return formData;
16		},
17		initListing: function (callback, preAction) {
18			const frm = $(this);
19			let searchText = "";
20
21			frm.find("[data-is-filter]").on("change", function () {
22				const frm = $(this).parents("form");
23				frm.find("[name='hidden_page']").val(1);
24
25				$(this).attr("submit-on-change") && frm.submit();
26			});
27
28			frm.find(":submit").on('click', function () {
29				const frm = $(this).parents("form");
30				frm.find("[name='hidden_page']").val(1);
31			});
32
33			frm.find(".js-clear-filters").on('click', function () {
34				frm.find('select.select2-hidden-accessible').each(function () {
35					const val = $(this).data('default') ?? null;
36					$(this).val(val).trigger('change');
37				});
38
39				frm.find("[data-is-filter]").each(function () {
40					const el = $(this), type = el[0].type;
41					type === 'text' && el.val('');
42					type === 'select-one' && el.val('');
43				});
44
45				frm.setPage(1);
46				frm.submit();
47			});
48
49			//  capture submit
50			frm.unbind("submit").submit(function (e) {
51				e.preventDefault();
52
53				const frm = $(this),
54					container = frm.find(".js-results"),
55					loader = `<div class="js-loading"></div>`,
56					hash = window.location.hash ?? '';
57				frm.find(".js-load-more").hide();
58				container.addClass("js-loading");
59				console.log(preAction);
60				preAction && preAction(frm);
61
62				//  capture if search text has change for reset page number
63				const searchEl = frm.find("[type='search']");
64				searchEl.length && [(searchText = searchEl.val())];
65
66				let queryString = [],
67					args = [],
68					filters = [],
69					params = frm.customSerializeArray();
70
71				//  add filters to query string
72				params.forEach(
73					(item) =>
74						item.name.includes("hidden_") ||
75						item.name.includes("wp") ||
76						item.value.length == 0 ||
77						[
78							queryString.push((item.altname ?? item.name) + "=" + item.value),
79							filters.push(item.name + "=" + item.value)
80						]
81				);
82
83				window.history.pushState(
84					"",
85					"",
86					queryString.length ? "?" + queryString.join("&") + hash : "?all" + hash
87				);
88
89				params.forEach(
90					(item) =>
91						(args[item.name.replace("hidden_", "")] = item.value)
92				);
93				args.pager === "pagenavi"
94					? container.html(loader)
95					: args.page === 1
96						? container.html(loader)
97						: container.append(loader);
98
99				$.ajax({
100					type: "POST",
101					url: BRACKET.ajax_url,
102					dataType: "JSON",
103					data: {
104						action: "load_listing_results",
105						...args,
106						filters: filters.join("&"),
107					},
108					success: (response) => {
109						const results = frm.find(".js-results");						
110						frm.find("[name='hidden_page']").val(
111							response.success ? response.data.nextpage : 1
112						);
113
114						response.data.pager_type === "pagenavi"
115							? results.html(loader)
116							: response.data.currentpage === 1
117								? results.html(loader)
118								: results.append(loader);
119
120						results
121						.removeClass("js-loading")
122						.find(".js-loading")
123						.remove();
124
125						const tmp = document.createElement('div');
126						tmp.innerHTML = response.data.content;
127
128						response.data.currentpage === 1
129							? results.html(tmp.innerHTML)
130							: results.append(tmp.innerHTML);
131
132						response.data.lastpage === false &&
133							frm.find(".js-load-more").show();
134						frm.find(".js-pager").html(response.data.pager ?? '');
135
136						//  wp pagenavi
137						frm.find(".js-pager a")
138							.unbind("click")
139							.on("click", function (e) {
140								e.preventDefault();
141								const el = $(this),
142									frm = el.parents("form"),
143									page = parseInt(
144										el
145											.attr("href")
146											.replace(
147												BRACKET.ajax_url + "?paged=",
148												""
149											)
150									);
151
152								jQuery("html, body").animate({
153									scrollTop: jQuery(".filters-content__form").offset().top - 70,
154								});
155								setTimeout(function () {
156									frm.setPage(page);
157									frm.submit();
158								}, 600);
159
160								frm.setPage(page);
161								frm.submit();
162								return false;
163							});
164
165						//  load more
166						frm.find(".js-load-more")
167							.unbind("click")
168							.on("click", function (e) {
169								e.preventDefault();
170								frm.submit();
171								return false;
172							});
173
174						callback && eval(callback)(response.data);
175					},
176				});
177
178				return false;
179			});
180
181			frm.submit();
182		},
183	});
184
185	$("form.bracket-ajax-filters .js-datepicker").datepicker({
186		minDate: 0,
187	});
188
189	$("form.bracket-ajax-filters").each(function () {
190		$(this).initListing($(this).data("callback"), $(this).data("precallback"));
191	});
192});

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.