PageSourceSearch

https://wheelingcvb.com/wp-content/themes/visitwheelingwv/js/functions.js?ver=1.1.17

js wheelingcvb.com collected 2026-10-02 10:11:56 UTC 12,436 bytes, 528 lines download raw bytes

1function onLoad()
2{
3	redraw();
4	handleLinkClick('.gateway-project-link');
5
6
7}
8window.addEventListener('load', onLoad);
9
10function handleLinkClick(containerSelector) {
11    const container = document.querySelector(containerSelector);
12
13    if (!container) return;
14
15    container.addEventListener('click', function(event) {
16        let target = event.target;
17
18        while (target && target !== container) {
19            if (target.tagName === 'A' && target.href) {
20                event.preventDefault();
21                window.location.href = target.href; // Redirige el navegador
22                break;
23            }
24            target = target.parentElement; // Sigue subiendo en el DOM
25        }
26    });
27}
28
29
30function getQueryVar(name)
31{
32	var url = window.location.href;
33    name = name.replace(/[\[\]]/g, '\\$&');
34    var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
35        results = regex.exec(url);
36    if (!results) return null;
37    if (!results[2]) return '';
38    return decodeURIComponent(results[2].replace(/\+/g, ' '));
39}
40
41function dump(obj) {
42    var out = '';
43    for (var i in obj) {
44        out += i + ": " + obj[i] + "\n";
45    }
46    alert(out);
47}
48
49function hookCoolDropdowns()
50{
51	var dropdowns = document.querySelectorAll('.cool-dropdown a');
52
53	for (var i = 0; i < dropdowns.length; i++)
54	{
55		dropdowns[i].addEventListener('click', function(e)
56		{
57			var dropdown = e.target;
58			while (!dropdown.classList.contains('cool-dropdown'))
59			{
60				dropdown = dropdown.parentNode;
61			}
62			if (dropdown.classList.contains('expanded'))
63			{
64				dropdown.classList.remove('expanded');
65			}
66			else
67			{
68				dropdown.classList.add('expanded');
69			}
70
71			jQuery('.cool-dropdown').each(function()
72			{
73				if (this != dropdown)
74				{
75					this.classList.remove('expanded');
76				}
77			});
78		});
79	}
80
81	jQuery('.cool-dropdown li a').click(function()
82	{
83		var dropdown = this;
84		while (!dropdown.classList.contains('cool-dropdown'))
85		{
86			dropdown = dropdown.parentNode;
87		}
88
89		dropdown.querySelector('.cool-dropdown-value').innerHTML = this.innerHTML;
90		dropdown.dataset.value = this.dataset.value;
91	});
92}
93
94function sliderNext(slider)
95{
96	var slides = slider.querySelectorAll('.slider-page');
97	var nextIndex = getCurrentSlide(slider) + 1;
98	slides[nextIndex].classList.remove('next');
99	slides[nextIndex].classList.add('current');
100	slides[nextIndex - 1].classList.remove('current');
101	slides[nextIndex - 1].classList.add('previous');
102	if (nextIndex >= slides.length - 1)
103	{
104		slider.querySelector('.slider-next').style.display = "none";
105	}
106	if (nextIndex > 0)
107	{
108		slider.querySelector('.slider-previous').style.display = "";
109	}
110}
111
112function sliderPrevious(slider)
113{
114	var slides = slider.querySelectorAll('.slider-page');
115	var previousIndex = getCurrentSlide(slider) - 1;
116	slides[previousIndex].classList.remove('previous');
117	slides[previousIndex].classList.add('current');
118	slides[previousIndex + 1].classList.remove('current');
119	slides[previousIndex + 1].classList.add('next');
120	if (previousIndex <= slides.length)
121	{
122		slider.querySelector('.slider-next').style.display = "";
123	}
124	if (previousIndex <= 0)
125	{
126		slider.querySelector('.slider-previous').style.display = "none";
127	}
128}
129
130function getCurrentSlide(slider)
131{
132	var slides = slider.querySelectorAll('.slider-page');
133	for (var i = 0; i < slides.length; i++)
134	{
135		if (slides[i].classList.contains('current'))
136		{
137			return i;
138		}
139	}
140}
141
142function showPopup(title, body, buttons)
143{
144	if (typeof buttons == 'undefined')
145	{
146		buttons = [{title: "Close", url: "javascript:hidePopup();"}];
147	}
148	var popup = document.createElement("div");
149	popup.className = "popup";
150	var popupBox = document.createElement("div");
151	popupBox.className = "popup-box";
152	popup.append(popupBox);
153
154	var popupContent = document.createElement("div");
155	popupContent.className = "popup-content";
156	popupContent.innerHTML = "<h3>" + title + "</h3>" + body;
157	popupBox.appendChild(popupContent);
158
159	for (var i = 0; i < buttons.length; i++)
160	{
161		var button = document.createElement("a");
162		button.className = "button";
163		button.innerHTML = buttons[i].title;
164		button.setAttribute("href", buttons[i].url);
165		if (typeof buttons[i].target != 'undefined')
166		{
167			button.target = buttons[i].target;
168		}
169		popupBox.appendChild(button);
170	}
171	document.body.appendChild(popup);
172}
173
174function hidePopup()
175{
176	var popup = document.querySelector(".popup");
177	popup.parentNode.removeChild(popup);
178}
179
180window.addEventListener('DOMContentLoaded', function()
181{
182	var tables = document.querySelectorAll('.directory-table-container');
183	for (var i = 0; i < tables.length; i++)
184	{
185		tables[i].querySelector('tr:first-child').addEventListener('click', function(e)
186		{
187			var container = e.target;
188			while (!container.className.includes('directory-table-container'))
189			{
190				container = container.parentNode;
191			}
192			if (container.className == "directory-table-container")
193			{
194				container.className = "directory-table-container expanded";
195			}
196			else
197			{
198				container.className = "directory-table-container";
199			}
200		});
201	}
202
203	var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
204
205	if (iOS)
206	{
207
208	}
209	else
210	{
211
212	}
213
214	var menuItems = document.querySelectorAll('#mobile-menu-container ul li a');
215	for (var i = 0; i < menuItems.length; i++)
216	{
217		menuItems[i].addEventListener('click', function(e)
218		{
219			if (window.innerWidth <= 1000)
220			{
221				if (!e.target.parentNode.querySelector('li'))
222				{
223					toggleMobileMenu();
224				}
225			}
226		});
227	}
228	document.body.addEventListener('click', function(e)
229	{
230		var isMenu = false;
231		var parent = e.target;
232		while (parent)
233		{
234			if (parent.classList && parent.classList.contains('menu-item') && parent.parentNode.id == "menu-primary-menu") isMenu = true;
235			parent = parent.parentNode;
236		}
237		if (!isMenu)
238		{
239			var menuButtons = document.querySelectorAll('#menu-primary-menu > li > a');
240			for (var i = 0; i < menuButtons.length; i++)
241			{
242				menuButtons[i].className = "";
243			}
244		}
245	});
246
247	hookMenus();
248	hookCoolDropdowns();
249
250	jQuery('.sub-menu .button').each(function()
251	{
252		this.dataset.role = "button";
253	});
254
255	jQuery('.unmute').click(function()
256	{
257		jQuery(this).prev()[0].currentTime = 0;
258		jQuery(this).prev().prop('muted', false);
259		jQuery(this).hide();
260	});
261});
262
263function createExperience()
264{
265	var category = document.getElementById('category-dropdown').dataset.value;
266	var season = document.getElementById('season-dropdown').dataset.value;
267	if (category && season)
268	{
269		window.location = "events/?category=" + category + "&season=" + season;
270	}
271}
272
273function hookMenus()
274{
275	var menuButtons = document.querySelectorAll('.menu-primary-menu-container > ul > li');
276
277	for(var i = 0; i < menuButtons.length; i++)
278	{
279		menuButtons[i].addEventListener('click', function(e)
280		{
281			if (window.innerWidth > 1000)
282			{
283				isSubmenu = false;
284				var parent = e.target;
285				while (parent != null) {
286					if (parent.className == "sub-menu") {
287						isSubmenu = true;
288						break;
289					}
290					parent = parent.parentNode;
291				}
292				if (!isSubmenu && !e.target.classList.contains("menu-item-has-children"))
293				{
294					var topLevelButton = e.target;
295					while (topLevelButton.parentNode.className != "menu")
296					{
297						topLevelButton = topLevelButton.parentNode;
298					}
299					topLevelButton = topLevelButton.querySelector("a:first-child");
300					if (topLevelButton == e.target && window.innerWidth > 1000)
301					{
302						e.preventDefault();
303					}
304					for(var i = 0; i < menuButtons.length; i++)
305					{
306						var button = menuButtons[i].querySelector('a:first-child');
307						if (button != topLevelButton)
308						{
309							button.className = "";
310						}
311					}
312					topLevelButton.className = topLevelButton.className == "selected" ? "" : "selected";
313				}
314			}
315		});
316	}
317}
318
319function redraw()
320{
321	var pageContent = document.getElementById('page-content');
322	if (pageContent)
323	{
324		var sections = pageContent.querySelectorAll('.section');
325		sections[sections.length - 1].style.minHeight = "";
326		sections[sections.length - 1].style.minHeight = (window.innerHeight - document.body.clientHeight) + sections[sections.length - 1].clientHeight + "px";
327	}
328
329	var highlights = document.querySelector(".highlights");
330	if (highlights)
331	{
332		if (window.innerWidth > 800)
333		{
334			homogenizeHeights(".highlight-title");
335		}
336		else
337		{
338			releaseHeights(".highlight-title");
339		}
340	}
341
342	/*if (window.innerWidth > 1000)
343	{
344		homogenizeHeights('.sub-menu');
345	}
346	else
347	{
348		releaseHeights('.sub-menu');
349	}*/
350
351	jQuery('.sub-menu li[data-role=button]').each(function()
352	{
353		if (window.innerWidth > 1000)
354		{
355			jQuery(this).addClass('button');
356		}
357		else
358		{
359			jQuery(this).removeClass('button');
360		}
361	});
362
363	var postThumbnails = document.querySelector(".post-thumbnail");
364	if (postThumbnails)
365	{
366		if (window.innerWidth > 800)
367		{
368			var eventThumbnailHeight = (homogenizeHeights(".post-thumbnail") + 40) + "px";
369			if (document.querySelector('.video-thumbnail'))
370			{
371				var videoThumbnailHeight = (document.querySelector('.video-thumbnail').clientHeight + 40) + "px";
372			}
373			if (window.innerWidth > 1000)
374			{
375				if (document.querySelector(".events-slider"))
376				{
377					document.querySelector(".events-slider").style.height = eventThumbn
377ailHeight;
378				}
379				if (document.querySelector(".video-slider"))
380				{
381					document.querySelector(".video-slider").style.height = videoThumbnailHeight;
382				}
383			}
384			else
385			{
386				if (document.querySelector(".events-slider"))
387				{
388					document.querySelector(".events-slider").style.height = "";
389				}
390				if (document.querySelector(".video-slider"))
391				{
392					document.querySelector(".video-slider").style.height = "";
393				}
394			}
395		}
396		else
397		{
398			releaseHeights(".post-thumbnail");
399			if (document.querySelector(".events-slider"))
400				{
401					document.querySelector(".events-slider").style.height = "";
402				}
403				if (document.querySelector(".video-slider"))
404				{
405					document.querySelector(".video-slider").style.height = "";
406				}
407		}
408	}
409
410	if (getQueryVar("embedded") == "true")
411    {
412        var height = document.getElementById('content').offsetHeight;
413        parent.postMessage(height, '*');
414    }
415
416}
417window.addEventListener('resize', redraw);
418
419
420function onScroll()
421{
422	if (document.documentElement.scrollTop > 120 || document.body.scrollTop >120)
423	{
424		document.getElementsByTagName('header')[0].className = "floating";
425	}
426	else
427	{
428		document.getElementsByTagName('header')[0].className = "";
429	}
430}
431window.addEventListener('scroll', onScroll);
432
433
434function toggleMobileMenu()
435{
436	if (document.getElementById('mobile-menu-container').style.display == "block")
437	{
438		document.getElementById('mobile-menu-container').style.display = "";
439		document.getElementById('mobile-menu-container').style.zIndex = "";
440		document.getElementById('mobile-menu-button').style.backgroundColor = "";
441	}
442	else
443	{
444		document.getElementById('mobile-menu-container').style.display = "block";
445		document.getElementById('mobile-menu-container').style.zIndex = "1000";
446		document.getElementById('mobile-menu-button').style.backgroundColor = "#6fb9e6";
447	}
448}
449
450function homogenizeHeights(selector, heightAdjust)
451{
452	if (typeof heightAdjust == 'undefined')
453	{
454		heightAdjust = 0;
455	}
456
457	var tallest = getTallest(selector).clientHeight + heightAdjust;
458
459	var elements = document.querySelectorAll(selector);
460
461	for (var i = 0; i < elements.length; i++)
462	{
463		elements[i].style.height = tallest + "px";
464	}
465
466	return tallest;
467}
468
469function releaseHeights(selector)
470{
471	getTallest(selector); //a hacky way to do it
472}
473
474
475function getTallest(selector)
476{
477	var elements = document.querySelectorAll(selector);
478
479	var tallest;
480	for (var i = 0; i < elements.length; i++)
481	{
482		elements[i].style.height = "";
483
484		if (tallest == null || elements[i].clientHeight > tallest.clientHeight)
485		{
486			tallest = elements[i];
487		}
488	}
489
490	return tallest;
491}
492
493function arraysIntersect(array1, array2)
494{
495	for (var i = 0; i < array1.length; i++)
496	{
497		for (var x = 0; x < array2.length; x++)
498		{
499			if (array1[i] == array2[x])
500			{
501				return true;
502			}
503		}
504	}
505	return false;
506}
507
508function createElementFromHTML(html)
509{
510	var div = document.createElement('div');
511	div.innerHTML = html;
512	return div.firstChild;
513}
514
515function toggleSearchForm()
516{
517	var searchForm = document.getElementById('search-form');
518	if (searchForm.className == "search-form")
519	{
520		searchForm.className = "search-form search-form-active";
521		document.getElementById("search-field").focus();
522		document.getElementById("search-field").select();
523	}
524	else
525	{
526		searchForm.className = "search-form";
527	}
528}

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.