PageSourceSearch

https://www.downtowntc.com/assets/js/common.js?1779381120

js downtowntc.com collected 2026-10-02 10:03:17 UTC 17,508 bytes, 443 lines download raw bytes

1// window.addEventListener("load", function (){ 
2// 	var allVideos = document.querySelectorAll("iframe[src*='//www.youtube.com']");
3
4//     if(allVideos.length >= 1){
5// 	   allVideos.forEach(element => {
6//             width = element.getAttribute('width');
7//             height = element.getAttribute('height')
8//             element.removeAttribute('height');
9//             element.removeAttribute('width');
10//     		element.style.aspectRatio = width / height;
11//     	});
12//     }
13// });
14
15/***********************/
16
17window.addEventListener("resize", function (){
18  windowsize = window.innerWidth;
19  if (windowsize > 800) {
20	    menuCloseAll(document.getElementById("nav"),false);
21  }
22});
23
24  /***********************/
25 /****** Lightbox *******/
26/***********************/
27
28function openLightBox(id) {
29    document.querySelector('main').style.zIndex = "4";
30    document.getElementById("lightbox-" + id).style.display = "block";
31    document.querySelector("#lightbox-" + id + ' a:first-of-type').focus();
32}
33
34function closeLightBox(id) {
35    document.querySelector('main').style.zIndex = "1";
36    document.getElementById("lightbox-" + id).style.display = "none";
37}
38
39function plusSlides(id, n) {
40    var slideIndex = getSlideIndex(id);
41    showSlides(id, slideIndex, slideIndex + n);
42}
43
44function currentLighboxSlide(id, n) {
45    var slideIndex = getSlideIndex(id);
46    showSlides(id, slideIndex, n);
47}
48
49function showSlides(id, slideIndex, n) {
50    var i;
51    var slides = document.querySelectorAll('#lightbox-' + id + ' .slide');
52    if (n > slides.length) {n = 1}
53    if (n < 1) {n = slides.length}
54    for (i = 0; i < slides.length; i++) {
55        slides[i].style.display = "none";
56    }
57    slides[n-1].style.display = "block";
58
59    for (const child of slides[n-1].children) {
60        if(child.tagName == "IMG" && child.src == ''){
61            child.src = child.dataset['lightbox'];
62        }
63    }
64}
65
66function getSlideIndex(id){
67    var index = 1;
68    var slides = document.querySelectorAll('#lightbox-' + id + ' .slide');
69    for (i = 0; i < slides.length; i++) {
70        if(slides[i].style.display == "block")
71            index = i+1;
72    }
73    return index;
74}
75
76/**********************/
77                    
78window.addEventListener("load", function (){ 
79    document.onkeyup = PresTab;
80 
81   function PresTab(e)
82   {
83       var keycode = (window.event) ? event.keyCode : e.keyCode;
84       if (keycode == 9){
85            nav_hover = false;
86
87            if(document.querySelector('a:focus') != null && document.querySelector('a:focus').parentElement != null && document.querySelector('a:focus').parentElement.parentElement != null && document.querySelector('a:focus').parentElement.parentElement.parentElement != null){
88                if(document.querySelector('a:focus').parentElement.parentElement.parentElement.classList.contains('main-nav')) nav_hover = true;
89
90                if(document.querySelector('a:focus').parentElement.parentElement.parentElement.parentElement != null && document.querySelector('a:focus').parentElement.parentElement.parentElement.parentElement.parentElement != null){
91                    if(document.querySelector('a:focus').parentElement.parentElement.parentElement.parentElement.parentElement.classList.contains('main-nav')) nav_hover = true;
92
93                    if(document.querySelector('a:focus').parentElement.parentElement.parentElement.parentElement.parentElement.parentElement != null && document.querySelector('a:focus').parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement != null){
94                        if(document.querySelector('a:focus').parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.classList.contains('main-nav')) nav_hover = true;
95                    }
96                }
97            }      
98          
99           if(nav_hover){ 
100               if(document.querySelector('a:focus').parentElement.parentElement.classList.contains('level-1') && 
101                document.querySelector('nav>ul>li.hover') != undefined &&
102                document.querySelector('nav>ul>li.hover').classList.contains('hover')){
103                    document.querySelector('nav>ul>li.hover').classList.remove('hover');
104               }
105
106               if(document.querySelector('a:focus').parentElement.parentElement.classList.contains('level-2') &&
107                document.querySelector('nav>ul>li>ul>li.hover') != undefined &&
108                document.querySelector('nav>ul>li>ul>li.hover').classList.contains('hover')){
109                    document.querySelector('nav>ul>li>ul>li.hover').classList.remove('hover');
110               }
111
112                document.querySelector('a:focus').parentElement.classList.add('hover');
113
114                if(document.querySelector('a:focus').parentElement.parentElement.classList.contains('level-2')){
115                    document.querySelector('a:focus').parentElement.parentElement.parentElement.classList.add('hover');
116                }
117
118                if(document.querySelector('a:focus').parentElement.parentElement.classList.contains('level-3')){
119                    document.querySelector('a:focus').parentElement.parentElement.parentElement.classList.add('hover');
120                    document.querySelector('a:focus').parentElement.parentElement.parentElement.parentElement.parentElement.classList.add('hover');
121                }
122                
123               
124           } else {
125                if(document.querySelector('header li.hover') != null){
126                    if(document.querySelector('header li.hover').classList != null){
127                        document.querySelector('header li.hover').classList.remove('hover');
128                    }
129                }
130           }
131       }
132   }
133});
134
135/**********************/
136
137var banner_settings = [];
138var bannerContainers = null;
139var requestIds = [];
140
141window.addEventListener("load", function (){ 
142    bannerContainers = document.querySelectorAll('.scrolling-banner');
143    initalizeBanner();
144});
145
146window.addEventListener("resize", function (){
147   requestIds.forEach(id => {
148      window.cancelAnimationFrame(id);
149    });
150    requestIds = [];
151    initalizeBanner();
152});
153
154function initalizeBanner(){
155    bannerContainers.forEach(banner => {
156        banner_settings[banner.id] = []
157        banner_settings[banner.id]['space'] = parseInt(banner.dataset.space);
158        banner_settings[banner.id]['l'] = banner_settings[banner.id]['space'];
159        banner_settings[banner.id]['speed'] = parseFloat(banner.dataset.speed);
160        banner_settings[banner.id]['stack'] = [];
161        banner_settings[banner.id]['pause'] = false;
162
163        banner.classList.add("initialized");
164
165        let total_width = 0;
166        document.querySelectorAll('.scrolling-banner#' + banner.id + ' div').forEach(element => {
167            total_width += element.offsetWidth + banner_settings[banner.id]['space'];
168        });
169
170        if(total_width <= window.innerWidth + 300){
171            var items = document.querySelectorAll('.scrolling-banner#' + banner.id + ' div');
172            var clones = [];
173            items.forEach(function (element, index) {
174                clone = element.cloneNode(true)
175                clone.classList.add("clone");
176                clone.setAttribute('aria-hidden', 'true');
177                clones[index] = clone;
178            });
179            for (var i = 0; i < Math.ceil((window.screen.width + 300) / total_width); i++) {
180                items = [...items, ...clones];;
181            }
182            var items = Array.prototype.reduce.call(items, function(html, node) {
183                return html + ( node.outerHTML || node.nodeValue );
184            }, "");
185
186            banner.innerHTML = items;
187        }
188
189        document.querySelectorAll('.scrolling-banner#' + banner.id + ' div').forEach(element => {
190            const width = element.offsetWidth + banner_settings[banner.id]['space'];
191            element.style.left = `${banner_settings[banner.id]['l']}px`;
192            banner_settings[banner.id]['l'] += width;
193            banner_settings[banner.id]['stack'].push(element);
194        });
195
196        banner.addEventListener('mouseover', () => {
197            banner_settings[banner.id]['pause'] = true;
198        });
199        banner.addEventListener('mouseout', () => {
200            banner_settings[banner.id]['pause'] = false;
201        });
202    });
203
204    var id = requestAnimationFrame(moveBannerText);
205    requestIds.push(id);
206}
207
208function moveBannerText() {
209    bannerContainers.forEach(banner => {
210        if (!banner_settings[banner.id]['pause']) {
211            document.querySelectorAll('.scrolling-banner#' + banner.id + ' div').forEach(element => {
212                const currentLeft = parseFloat(getComputedStyle(element).left);
213                const newLeft = currentLeft - banner_settings[banner.id]['speed'];
214                element.style.left = `${newLeft}px`;
215
216                if (newLeft + element.offsetWidth < -130) {
217                    const firstElement = banner_settings[banner.id]['stack'].shift();
218                    const lastElement = banner_settings[banner.id]['stack'][banner_settings[banner.id]['stack'].length - 1];
219                    element.style.left = `${parseFloat(getComputedStyle(lastElement).left) + lastElement.offsetWidth + banner_settings[banner.id]['space']}px`;
220                    banner_settings[banner.id]['stack'].push(element);
221                }
222            });
223        }
224     });
225    var id = requestAnimationFrame(moveBannerText);
226    requestIds.push(id);
227}
228
229/**********************/
230
231// https://pawelgrzybek.github.io/siema/
232// 
233
234var timeoutIds = [];
235var siemas = [];
236
237function initializeSiema(id, buttons = false, dots = false,  perPage = 1, speed = 6000, autoplay = true){
238    siemas[id] = new Siema({
239          selector: '#' + id + ' .track',
240          duration: 1000,
241          easing: 'ease',
242          perPage: perPage, // responsive example https://codepen.io/pawelgrzybek/pen/dWbGyZ
243          startIndex: 0,
244          draggable: document.querySelector('#' + id + ' .track').dataset.length > 1 ? true : false,
245          multipleDrag: document.querySelector('#' + id + ' .track').dataset.length > 1 ? true : false,
246          threshold: 20,
247          loop: true,
248          rtl: false,
249          onInit: () => {
250            if(autoplay)
251                timeoutIds[id] = setTimeout(() => siemas[id].next(), 6000);
252          },
253          onChange: () => {
254            if(autoplay){
255                clearTimeout(timeoutIds[id]);
256                timeoutIds[id] = setTimeout(() => siemas[id].next(), 6000);
257                if(dots)
258                    activeDot(id, siemas[id].currentSlide);
259            }
260          },
261        })
262
263    if(buttons){
264        if(document.querySelector('#' + id + ' .prev'))
265            document.querySelector('#' + id + ' .prev').addEventListener('click', () => siemas[id].prev(1, function(){
266                
267            }));
268        if(document.querySelector('#' + id + ' .next'))
269            document.querySelector('#' + id + ' .next').addEventListener('click', () => siemas[id].next(1, function(){
270                
271            }));
272    }
273
274    if(dots){
275        for (let i = 0; i < document.querySelector('#' + id + ' .track').dataset.length; i++) {
276            const btn = document.createElement('button');
277            btn.textContent = i+1;
278            btn.addEventListener('click', () => siemas[id].goTo(i));
279            if(i == 0)
280                btn.classList.add('on');
281            document.querySelector('#' + id + ' .dots-container').appendChild(btn);
282          }
283    }
284}
285
286function activeDot(id, i){
287    remove = document.querySelector('#' + id + ' .dots-container > button.on:not(:nth-child(' + (i+1) + '))');
288    addOnClass = document.querySelector('#' + id + ' .dots-container > button:nth-child(' + (i+1) + ')');
289
290    if(remove != null)
291        remove.className = '';
292    if(addOnClass != null)
293        addOnClass.className = 'on';
294}
295
296/**********************/
297
298function setCookie(name, value, expires, path, domain, secure) {
299    var expires_date = new Date();
300    if (expires) expires_date.setTime(expires_date.getTime() + (expires * 1000 * 60 * 60 * 24));
301    document.cookie = name + "=" + escape(value) + (expires ? ";expires=" + expires_date.toGMTString() : "") + (path ? ";path=" + path : "") + (domain ? ";domain=" + domain : "") + (secure ? ";secure" : "");
302}
303
304function getCookie(check_name) {
305    var cookies = document.cookie.split(';');
306    for (i = 0; i < cookies.length; i++) {
307        var parts = cookies[i].split('=');
308        if (check_name == parts[0].replace(/^\s+|\s+$/g, '')) {
309            if (parts.length > 1) return unescape(parts[1].replace(/^\s+|\s+$/g, ''));
310            return true;
311        }
312    }
313    return null;
314}
315
316/**********************/
317
318function showAlertOverlay(id){
319    document.getElementById(id).classList.add('active');
320    document.querySelector('html').style.overflow = 'hidden';
321    document.querySelector('body').style.overflow = 'hidden';
322}
323
324function hideAlertOverlay(id){
325    document.getElementById(id).classList.remove('active');
326    document.querySelector('html').style.overflow = '';
327    document.querySelector('body').style.overflow = '';
328
329    setCookie(id, 1, 1, '/');
330}
331
332/**********************/
333
334function loadMoreGalleryItems(n, index, total){
335
336    document.querySelectorAll('#gallery-' + n + ' .chunk-' + index).forEach(element => {
337        element.style.display = 'block';
338    });
339
340    button = document.querySelector('#gallery-' + n + ' + .button-container a');
341
342    if(index == total-1){
343        button.remove();
344    } else {
345        button.href = 'javascript:loadMoreGalleryItems("' + n + '", ' + (index+1) + ', ' + total + ');';
346    }
347
348    LazyLoader.prototype.checkScrollPositionOnScrollThrottled();
349}
350
351/**********************/
352
353function nextFocusable(el){
354    el.parentNode.childNodes[1].childNodes[0].childNodes[0].focus();
355}
356
357/**********************/
358
359document.addEventListener('DOMContentLoaded', function() {
360    updateSelectedAccordion();
361});
362
363window.addEventListener("hashchange", function() {
364    updateSelectedAccordion();
365});
366
367function updateSelectedAccordion(){
368    var userUrl = window.location.href.split( '#' )[1];
369    if(userUrl != undefined && userUrl != ''){
370
371        accordions = document.querySelectorAll('.accordion-module .accordion-container');
372        for (var i = 0; i < accordions.length; i++) {
373            value = accordions[i];
374
375            if (value.getAttribute('name') == userUrl.toLowerCase()) {
376                value.classList.add('open');
377
378                value.scrollIntoView({ 
379                    behavior: "auto", 
380                    block: "start",
381                    inline: "start",
382                });
383
384            }
385        }
386    }
387}
388
389/**********************/
390
391
392function activateFooterNav(node){
393    document.getElementById('list-' + node).classList.add("on");
394}
395
396/**********************/
397
398function toggleDropdown(id){
399    if(document.querySelector('.drop-down-container.on:not(#' + id + ')') != null)
400        document.querySelector('.drop-down-container.on:not(#' + id + ')').classList.remove('on');
401    document.querySelector('#' + id).classList.toggle('on');
402}
403
404document.addEventListener("click", function(event) {
405    el = event.target;
406
407    if(!((el.parentElement != null && el.parentElement.classList.contains('drop-down-container'))
408      || (el.parentElement.parentElement != null && 
409            el.parentElement.parentElement.classList.contains('drop-down-container'))
410      || (el.parentElement.parentElement.parentElement != null && 
411            el.parentElement.parentElement.parentElement.classList.contains('drop-down-container')) 
412      || (el.parentElement.parentElement.parentElement.parentElement  != null && 
413        el.parentElement.parentElement.parentElement.parentElement.classList.contains('drop-down-container')))){
414        if(document.querySelector(".drop-down-container.on") != null)
415           document.querySelector(".drop-down-container.on").classList.remove('on');
416    }
417
418    if(el.id != 'datePosted' && document.querySelector("#datePosted.on") != null){
419        document.querySelector("#datePosted.on").classList.remove('on');
420    }
421});
422
423function toggleSelect(el){
424    if(document.querySelector('.drop-down-container.on:not(#' + el.id + ')') != null)
425        document.querySelector('.drop-down-container.on:not(#' + el.id + ')').classList.remove('on');
426}
427
428function searchList(id){
429    search = document.querySelector('#search-list-' + id).value;
430    search = search.toLowerCase()
431
432    if(document.querySelectorAll('#' + id + ' ul li:not(.search-list-container):not(.heading) label') != null){
433        document.querySelectorAll('#' + id + ' ul li:not(.search-list-container):not(.heading) label').forEach(element => {
434            text =  element.textContent;
435            text = text.toLowerCase()
436            if(!text.includes(search)){
437                element.parentElement.style.display = "none";
438            } else {
439                element.parentElement.style.display = "block";
440            }
441        });
442    }
443}

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.