PageSourceSearch

https://wheelingcvb.com/wp-content/themes/visitwheelingwv/js/postThumbnailSearch.js?ver=1.1702657994

js wheelingcvb.com collected 2026-10-02 10:12:08 UTC 7,911 bytes, 251 lines download raw bytes

1var refreshResultsTimeout;
2
3window.addEventListener('DOMContentLoaded', function (e) {
4	document.querySelector('.filter-group-search .search-field').addEventListener('input', function (e) {
5		clearTimeout(refreshResultsTimeout);
6		refreshResultsTimeout = setTimeout(refreshResults, 500);
7	});
8
9	jQuery('.filter-group-categories input[type="checkbox"]').change(function (e) {
10		clearTimeout(refreshResultsTimeout);
11		refreshResultsTimeout = setTimeout(refreshResults, 500);
12	});
13
14	if (typeof miniCalendars != 'undefined') {
15		miniCalendars[0].onChange(function () {
16			clearTimeout(refreshResultsTimeout);
17			refreshResultsTimeout = setTimeout(refreshResults, 500);
18		});
19	}
20
21	var category = Number(getQueryVar('category'));
22	if (category) {
23		document.querySelector('input[data-category-id="' + category + '"]').checked = true;
24	}
25
26	const today = new Date();
27
28	var season = getQueryVar('season');
29	if (season && typeof miniCalendars != 'undefined') {
30		var seasons = { "spring": null, "summer": null, "fall": null, "winter": null };
31		var refYear;
32		refYear = today.getFullYear();
33		while (seasons["spring"] == null || seasons["spring"].endDate < today) {
34			seasons["spring"] = {
35				startDate: new Date(refYear, 2, (refYear % 4 === 0) ? 19 : 20),
36				endDate: new Date(refYear, 5, (refYear % 4 === 0) ? 19 : 20)
37			};
38			refYear++;
39		}
40		refYear = today.getFullYear();
41		while (seasons["summer"] == null || seasons["summer"].endDate < today) {
42			seasons["summer"] = {
43				startDate: new Date(refYear, 5, (refYear % 4 === 0) ? 20 : 21),
44				endDate: new Date(refYear, 8, (refYear % 4 === 0) ? 21 : 22)
45			};
46			refYear++;
47		}
48
49		refYear = today.getFullYear();
50		while (seasons["fall"] == null || seasons["fall"].endDate < today) {
51			seasons["fall"] = {
52				startDate: new Date(refYear, 8, (refYear % 4 === 0) ? 22 : 23),
53				endDate: new Date(refYear, 11, (refYear % 4 === 0) ? 19 : 20)
54			};
55			refYear++;
56		}
57
58		refYear = today.getFullYear();
59		while (seasons["winter"] == null || seasons["winter"].endDate < today) {
60			seasons["winter"] = {
61				startDate: new Date(refYear, 11, (refYear % 4 === 0) ? 20 : 21),
62				endDate: new Date(refYear + 1, 2, (refYear % 4 === 0) ? 18 : 19)
63			};
64			refYear++;
65		}
66
67		season = season.replace(/\W/g, '');
68		miniCalendars[0].startDate = miniCalendars[0].selectionStart = seasons[season].startDate;
69		miniCalendars[0].endDate = miniCalendars[0].selectionEnd = seasons[season].endDate;
70		miniCalendars[0].redrawMonth(seasons[season].startDate.getMonth(), seasons[season].startDate.getFullYear());
71	}
72
73	if (getQueryVar('period') == "weekend") {
74		var weekend = getNextWeekend(today);
75
76		miniCalendars[0].startDate = miniCalendars[0].selectionStart = weekend.startDate;
77		miniCalendars[0].endDate = miniCalendars[0].selectionEnd = weekend.endDate;
78		miniCalendars[0].redrawMonth(weekend.startDate.getMonth(), weekend.startDate.getFullYear());
79	}
80
81	refreshResults();
82
83
84	/*————————————————————————————————————————————————————*\
85		●❱ AutoFilter Events by GET parameters
86	\*————————————————————————————————————————————————————*/
87	/**
88		agricultural
89		antiques
90		art
91		capitol-theatre
92		dance
93		educational
94		family-fun
95		festivals
96		free-events
97		holiday
98		motorcycle-car
99		music
100		parade
101		sports
102		theater
103		virtual-events
104	*/
105
106	function getParameterByName(name, url) {
107		if (!url) url = window.location.href;
108		name = name.replace(/[\[\]]/g, "\\$&");
109		var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
110			results = regex.exec(url);
111		if (!results) return null;
112		if (!results[2]) return '';
113		return decodeURIComponent(results[2].replace(/\+/g, " "));
114	}
115
116	function selectCheckboxById(id) {
117		var checkbox = document.getElementById(id);
118		clearTimeout(refreshResultsTimeout);
119		refreshResultsTimeout = setTimeout(refreshResults, 500);
120
121		if (checkbox) {
122			checkbox.checked = true;
123		}
124	}
125
126	var typeParam = getParameterByName('type');
127
128	if (typeParam) {
129		selectCheckboxById(typeParam);
130	}
131});
132
133function getNextWeekend(date) {
134	var weekend = { startDate: new Date(date.getFullYear(), date.getMonth(), date.getDate()), endDate: new Date(date.getFullYear(), date.getMonth(), date.getDate()) };
135	weekend.startDate.setDate(weekend.startDate.getDate() + (5 + 7 - weekend.startDate.getDay()) % 7);
136	weekend.endDate.setDate(weekend.endDate.getDate() + (0 + 7 - weekend.endDate.getDay()) % 7);
137	return weekend;
138}
139
140function clearFilters() {
141	if (typeof miniCalendars != 'undefined') {
142		miniCalendars[0].reset();
143	}
144	jQuery('.filter-group-categories input[type="checkbox"]').each(function (e) {
145		jQuery(this).prop('checked', false);
146	});
147
148	document.querySelector('.filter-group-search .search-field').value = "";
149	clearTimeout(refreshResultsTimeout);
150	refreshResultsTimeout = setTimeout(refreshResults, 500);
151	if (window.innerWidth <= 1000) {
152		toggleSearchFilters();
153	}
154}
155
156function filterFormSubmitted() {
157	if (window.innerWidth <= 1000) {
158		toggleSearchFilters();
159	}
160	event.preventDefault();
161	return false;
162}
163
164function toggleSearchFilters() {
165	var searchFilters = document.querySelector('.post-thumbnail-search-filters');
166	if (searchFilters.style.display == "") {
167		searchFilters.style.display = "block";
168	}
169	else {
170		searchFilters.style.display = "";
171	}
172}
173
174function refreshResults() {
175	var resultsWindow = document.querySelector('.post-thumbnail-search-results-thumbnails');
176	resultsWindow.innerHTML = "";
177
178	var categories = [];
179	jQuery('.filter-group-categories input[type="checkbox"]').each(function (e) {
180		if (jQuery(this).prop('checked')) {
181			categories.push(jQuery(this).val());
182		}
183	});
184
185	var query = document.querySelector('.filter-group-search .search-field').value;
186
187	if (query) {
188		query = query.replace(',', ' or ').toLowerCase().split(' or ');
189	}
190
191	var numResults = 0;
192
193	for (var i = 0; i < postThumbnails.length; i++) {
194		if (typeof miniCalendars != 'undefined') {
195			var startDate = new Date(postThumbnails[i].startDate);
196			var endDate = new Date(postThumbnails[i].endDate);
197
198			if (postThumbnails[i].startDate2) {
199				var startDate2 = new Date(postThumbnails[i].startDate2);
200			}
201			if (postThumbnails[i].endDate2) {
202				var endDate2 = new Date(postThumbnails[i].endDate2);
203			}
204
205
206			//check to make sure the event falls within the selected start and end date on the mini calendar
207			if (((miniCalendars[0].endDate && startDate > miniCalendars[0].endDate) || (miniCalendars[0].startDate && endDate < miniCalendars[0].startDate)) &&
208				((!startDate2 && !endDate2) || ((miniCalendars[0].endDate && startDate2 > miniCalendars[0].endDate) || (miniCalendars[0].startDate && endDate2 < miniCalendars[0].startDate)))) {
209				continue;
210			}
211
212			//check for days of the week that the event doesn't occur on
213			if (postThumbnails[i].notOccur && postThumbnails[i].notOccur.length > 0) {
214				var shouldOccur = false;
215				for (var n = 0; n < miniCalendars[0].selectedDaysOfWeek.length; n++) {
216					if (!postThumbnails[i].notOccur.includes(miniCalendars[0].selectedDaysOfWeek[n])) {
217						shouldOccur = true;
218					}
219				}
220
221				if (!shouldOccur) continue;
222			}
223
224		}
225
226		if (categories.length > 0 && !arraysIntersect(categories, postThumbnails[i].categories)) continue;
227
228		if (query) {
229			var match = false;
230			for (var q = 0; q < query.length; q++) {
231				if (query[q].trim() != "") {
232					if (postThumbnails[i].title.toLowerCase().includes(query[q]) || postThumbnails[i].description.toLowerCase().includes(query[q])) {
233						match = true;
234						break;
235					}
236				}
237			}
238
239			if (!match) continue;
240		}
241		numResults++;
242		var postThumbnail = createElementFromHTML(postThumbnails[i].template);
243		resultsWindow.appendChild(postThumbnail);
244	}
245
246	if (numResults == 0) {
247		resultsWindow.innerHTML = "<p>No items match your search criteria.</p>";
248	}
249
250	redraw();
251}

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.