PageSourceSearch

https://kimblecouncil.org/TheParishCouncilThemeV1.1/js/extra.js

js kimblecouncil.org collected 2026-09-27 10:30:16 UTC 60,170 bytes, 1,481 lines download raw bytes

1var modalId = $('#image-gallery');
2
3
4$(document)
5    .ready(function ()
6    {
7        var k = 0;
8        $('.flex-control-paging li').each(function () {
9            k++;
10            var newID = 'slide ' + k;
11            $(this).find('a').attr('aria-label', newID);
12            $(this).find('a').attr('href', 'Javascript:void(0);');
13            $(this).val(k);
14        });
15        
16        $(".nav-item ul a").focus(function () {
17            if ($(".dropdown-menu a").find(':focus').length === 0) {
18                $(this).parent().parent().parent().find(".dropdown-menu").addClass("focus");
19                $(this).parent().parent().parent().find(".dropdown-menu .dropdown-menu").removeClass("focus");
20            } else {
21                $(".dropdown-menu").removeClass("focus");
22            }
23        });
24
25        $(".nav-item ul a").blur(function () {
26            $(".dropdown-menu").removeClass("focus");
27        });
28        $(".nav-item.openinner ul li a").focus(function () {
29            if ($(".dropdown-menu a").find(':focus').length === 0) {
30                $(this).parent().parent().parent().parent().parent().find(".dropdown-menu").addClass("focus");
31                $(this).parent().parent().parent().parent().parent().find(".dropdown-menu .dropdown-menu .dropdown-menu").removeClass("focus");
32            } else {
33                $(".dropdown-menu").removeClass("focus");
34            }
35        });
36        $(".nav-item.openinner .nav-item.openinner ul li a ").focus(function () {
37            if ($(".dropdown-menu a").find(':focus').length === 0) {
38                $(this).parent().parent().parent().parent().parent().parent().parent().find(".dropdown-menu").addClass("focus");
39                $(this).parent().parent().parent().parent().parent().parent().parent().find(".dropdown-menu .dropdown-menu .dropdown-menu .dropdown-menu").removeClass("focus");
40            } else {
41                $(".dropdown-menu").removeClass("focus");
42            }
43        });
44        $(".nav-item.openinner .nav-item.openinner .nav-item.openinner ul li a ").focus(function () {
45            if ($(".dropdown-menu a").find(':focus').length === 0) {
46                $(this).parent().parent().parent().parent().parent().parent().parent().parent().parent().find(".dropdown-menu").addClass("focus");
47                $(this).parent().parent().parent().parent().parent().parent().parent().parent().parent().find(".dropdown-menu .dropdown-menu .dropdown-menu .dropdown-menu .dropdown-menu").removeClass("focus");
48            } else {
49                $(".dropdown-menu").removeClass("focus");
50            }
51        });
52        // Toggle dropdown menu on click of trigger element
53        $("#divScreenReaderWrp .dropdown-toggle").click(function () {
54            // Hide other dropdown menus in case of multiple dropdowns
55            $("#divScreenReaderWrp .dropdown-menu").not($(this).next()).slideUp("fast");
56
57            // Toggle the current dropdown menu
58            $(this).next("#divScreenReaderWrp .dropdown-menu").slideToggle("fast");
59        });
60
61        // Hide dropdown menu on click outside
62        $(document).on("click", function (event) {
63            if (!$(event.target).closest("#divScreenReaderWrp .dropdown").length) {
64                $("#divScreenReaderWrp .dropdown-menu").slideUp("fast");
65            }
66        });
67        $(window).scroll(function () {  
68            //myStickyHead()
69            if ($(this).scrollTop() > 100) {
70                $('.scrollup').fadeIn();
71            } else {
72                $('.scrollup').fadeOut();
73            }
74        });   
75        $('.scrollup').click(function () {
76            $("html, body").animate({
77                scrollTop: 0
78            }, 600);
79            return false;
80        });
81        loadGallery(true, 'a.thumbnail');
82
83        if (document.getElementById("selMeetingYear") != null)
84        {
85            var taregetSelect = document.getElementById("selMeetingYear");
86            var thisYear = new Date().getFullYear() + 2;
87            for (var i = 0; i < 12; i++)
88            {
89                var option = document.createElement("option");
90                option.text = thisYear - i;
91                option.value = thisYear - i;
92                taregetSelect.add(option);
93            }
94
95            //pageinate('ulMeetingListWrp', 'divPageControlWrp', 2);
96        }
97        
98
99        //This function disables buttons when needed
100        function disableButtons(counter_max, counter_current) {
101            $('#show-previous-image, #show-next-image')
102                .show();
103            if (counter_max === counter_current) {
104                $('#show-next-image')
105                    .hide();
106            } else if (counter_current === 1) {
107                $('#show-previous-image')
108                    .hide();
109            }
110        }
111        function loadGallery(setIDs, setClickAttr) {
112            var current_image,
113                selector,
114                counter = 0;
115
116            $('#show-next-image, #show-previous-image')
117                .click(function () {
118                    if ($(this)
119                        .attr('id') === 'show-previous-image') {
120                        current_image--;
121                    } else {
122                        current_image++;
123                    }
124
125                    selector = $('[data-image-id="' + current_image + '"]');
126                    updateGallery(selector);
127                });
128
129            function updateGallery(selector) {
130                var $sel = selector;
131                current_image = $sel.data('image-id');
132                $('#image-gallery-title')
133                    .text($sel.data('title'));
134                $('#image-gallery-image')
135                    .attr('src', $sel.data('image'));                                
136                $('#image-gallery-image')
137                    .attr('alt', $sel.data('title'));
138                $('#image-gallery-image')
139                    .attr('aria-label', $sel.data('title'));
140                $('#image-gallery-caption')
141                    .text($sel.data('caption'));
142                disableButtons(counter, $sel.data('image-id'));
143            }
144
145            if (setIDs == true) {
146                $('[data-image-id]')
147                    .each(function () {
148                        counter++;
149                        $(this)
150                            .attr('data-image-id', counter);
151                    });
152            }
153            $(setClickAttr)
154                .on('click', function () {
155                    updateGallery($(this));
156                });
157        }
158
159        var pageName = location.pathname.substring(1).replace("/", "_");
160        if (pageName == "")
161        {
162            pageName = " home"
163        }
164        var existingClasses = document.body.className;
165        document.body.className = existingClasses + ' ' + pageName;
166
167        checkForSearchFeature();
168        toggleContactForms(0);
169
170       //************ Fixes for selectbox and image modal*****************
171        $(".contact-us .field-type-htmlfield select").prepend("<label id='contactForm' style='display: none'>Select Form Option</label>");
172        $(".contact-us .field-type-htmlfield select").attr('aria-labelledby', 'contactForm');
173
174        $("#selReportAuditType").prepend("<label id='AuditType' style='display:none;'>Audit Type</label>");
175        $("#selReportAuditType").attr('aria-labelledby', 'AuditType');
176
177        $('#image-gallery-image').attr('alt', 'Image Gallery');
178        $('#imageModal .thumbnail').attr('href', 'Javascript:void(0);');
179        $('#imageModal .img-thumbnail').attr('alt', 'Image Gallery');
180        $('#show-previous-image').attr('aria-label', 'Show Previous Image');
181        $('#show-next-image').attr('aria-label', 'Show Next Image');
182        $("#imageModal").append("<label id='myModalLabel' style='display:none;'>Image Gallery</label>");
183        $("#image-gallery .modal-header").append("<h3 style='text-align:center'>Image Gallery</h3>");
184
185        stripEmptyHeadings();
186
187        //************** Fix for announcement not displaying full width in V1.1 theme *****************
188        if (document.querySelector(".divAnnouncementOuterWrp")!= null)
189        {
190            var announcementWidgetWrp = document.querySelector(".divAnnouncementOuterWrp");
191            if (announcementWidgetWrp.style.position == "fixed")
192            {
193                document.getElementById("divMainContentWrp").style.zIndex = "auto";
194            }
195        }
196
197        
198        //**********************   WCAG fixes 2024   ***********************//
199
200        $(".fa-search").attr('role','Search');
201        $("#spnRunSiteSearch > i.fa").attr('role','Button');
202        $(".genClickable").attr('role','button');
203        $("#spnRunSiteSearch").attr('role','button');
204        
205        $('#divToolBarWrp').each(function(){
206            $(this).find('.divToolWrp').attr('role', 'button');
207        });
208        $('.divNavGroupLink').attr('role', 'button');
209        
210        $('#customizeCookies').attr('role', 'button');
211    
212        $('.flex-direction-nav a').each(function(){
213            $(this).attr('role', 'button');
214        });
215    
216        $('.flex-control-nav a').each(function(){
217            $(this).attr('role', 'button');
218        });
219    
220        $(".plannerTable tr th").each(function(){
221            var arrowAlt = $(this).text().replace(/([-,.€~!@#$%^*()_+=`{}\[\]\|\\:;'<>])+/g, '');
222            $(this).find('img').attr("alt", "Arrow " + arrowAlt);
223            $(this).attr("scope", "col");
224        });
225    
226        var newsArticle = 0;
227        
228        $(".homeNewsItem .divNewsMoreLinkWrp a").each(function(){
229            newsLinkAlt = this.getAttribute('title');
230            if(newsLinkAlt === null){
231                // not there
232                newsArticle++;
233                $(this).attr("title", "Read more news link " + newsArticle);
234            }else if (newsLinkAlt === '') {
235                // empty
236                newsArticle++;
237                $(this).attr("title", "Read more news link " + newsArticle);
238            } else {      
239                // has value
240                  newsArticle++;
241                $(this).attr('alt', function( idx, originalNewLinkAlt ){
242                  return originalNewLinkAlt + ' Link ' + newsArticle
243                });
244            }
245        });
246    
247        $(".news .blogMainThumb .divNewsMoreLinkWrp a").each(function(){
248            newsLinkAlt = this.getAttribute('title');
249            if(newsLinkAlt === null){
250                // not there
251                newsArticle++;
252                $(this).attr("title", "Read more news link " + newsArticle);
253            }else if (newsLinkAlt === '') {
254                // empty
255                newsArticle++;
256                $(this).attr("title", "Read more news link " + newsArticle);
257            } else {      
258                // has value
259                  newsArticle++;
260                $(this).attr('alt', function( idx, originalNewLinkAlt ){
261                  return originalNewLinkAlt + ' Link ' + newsArticle
262                });
263            }
264        });
265
266        $(".news .blogMainThumb img").each(function(){
267            newsImgAlt = this.getAttribute('alt');
268            if (newsImgAlt === null) {
269                // not there
270                newsArticle++;
271                $(this).attr("alt", "Photo of News" + newsArticle);
272            } else if (newsImgAlt === '') {
273                // empty
274                newsArticle++;
275                $(this).attr("alt", "Photo of News" + newsArticle);
276            } else {        
277              // has value
278                newsArticle++;
279              $(this).attr('alt', function( idx, originalNewImgAlt ){
280                return originalNewImgAlt + ' Photo ' + newsArticle
281              });
282            }
283        });
284    
285        $(".bypass-block-link").attr('href', '#divMainContentWrp');
286
287        $(".slides").attr("role", "none");
288  		function checkForElement() {
289          setTimeout(function() {
290            $(".slides li.clone").each(function() {
291                $(this).attr("role", "none");
292            });
293          }, 1000);
294        }
295        checkForElement();
296  
297  		var slideImage = 0;
298        $(".slides li img").each(function() {
299            slideImgAlt = this.getAttribute('alt');
300            if (slideImgAlt === null) {
301                // not there
302                slideImage++;
303                $(this).attr("alt", "Photo of News" + slideImage);
304            } else if (slideImgAlt === '') {
305                // empty
306                slideImage++;
307                $(this).attr("alt", "Photo of News" + slideImage);
308            } else {        
309              // has value
310              slideImage++;
311              $(this).attr('alt', function( idx, originalSlideImgAlt ){
312                return originalSlideImgAlt + ' Photo ' + slideImage
313              });
314            }
315        });
316
317        $('#imageModal .thumbnail').each(function() {
318            slideImage++;
319            $(this).find('img').attr('alt', function( idx, originalAlt ){
320                return originalAlt + 'Image ' + slideImage
321            });
322        });
323  
324  	   var annualAuditReport = 0;
325        $(".annualAuditReport li a").each(function() {            
326            reportAriaLabel = this.getAttribute('aria-label');
327            if (reportAriaLabel === null) {
328                // not there
329                annualAuditReport++;
330                $(this).attr("aria-label", "Report link" + annualAuditReport);
331            } else if (reportAriaLabel === '') {
332                // empty
333                annualAuditReport++;
334                $(this).attr("aria-label", "Report link" + annualAuditReport);
335            } else {        
336              // has value
337              annualAuditReport++;
338              $(this).attr('aria-label', function( idx, originalReportLabel ){
339                return originalReportLabel + ' Link ' + annualAuditReport
340              });
341            }
342        });
343       
344  
345        var noticeImg = 0;
346        $(".noticeBoardReport").each(function(){
347          noticeImg++;
348          $(this).find('img').attr("alt", "Photo of Notice board " + noticeImg);
349          $(this).find('p a').attr("title", "Notice board link " + noticeImg);
350        });
351
352
353
354        $("a").each(function(){
355            
356            allLinkRole = this.getAttribute('role');
357  			if(allLinkRole === null){
358                // not there
359                $(this).attr('role', 'link');
360            }else if (allLinkRole === '') {
361                // empty
362                $(this).attr('role', 'link');
363            } else {      
364                // has value                
365                $(this).attr('role', 'link');
366            }
367            allLinkAlt = this.getAttribute('aria-label');
368            if(allLinkAlt === null){
369                // not there
370                allLinkText = $(this).text().replace(/([-,.€~!@#$%^*()_+=`{}\[\]\|\\:;'<>])+/g, '');
371                $(this).attr("aria-label", $.trim(allLinkText) + " link");
372                $(this).attr('tabindex', '0');
373            }else if (allLinkAlt === '') {
374                // empty
375                allLinkText = $(this).text().replace(/([-,.€~!@#$%^*()_+=`{}\[\]\|\\:;'<>])+/g, '');
376                $(this).attr("aria-label", $.trim(allLinkText) + " link");
377                $(this).attr('tabindex', '0');
378            } else {      
379                // has value
380                $(this).attr('aria-label', function( idx, originalLinkTxt ){
381                  return originalLinkTxt
382                });
383                $(this).attr('tabindex', '0');
384            }
385        });
386        
387        
388        
389        $(".gdprcookie-intro a").each(function(){
390            allLinkAlt = this.getAttribute('aria-label');
391            if(allLinkAlt === null){
392                // not there
393                allLinkText = $(this).text();
394                $(this).attr("aria-label", allLinkText + " link");
395            }else if (allLinkAlt === '') {
396                // empty
397                allLinkText = $(this).text();
398                $(this).attr("aria-label", allLinkText + " link");
399            } else {      
400                // has value
401                $(this).attr('aria-label', function( idx, originalLinkTxt ){
402                  return originalLinkTxt
403                });
404            }
405        });
406        
407        var allImgLinkTxt = 0;
408        $("img").each(function(){
409            allImgAlt = this.getAttribute('alt');
410            if(allImgAlt === null){
411                // not there
412                allImgLinkTxt++;
413                $(this).attr("alt", "Photo of Image " + allImgLinkTxt);
414            }else if (allImgAlt === '') {
415                // empty
416                allImgLinkTxt++;
417                $(this).attr("alt", "Photo of Image " + allImgLinkTxt);
418            } else {      
419                // has value
420                $(this).attr('alt', function( idx, originalImgAltTxt ){
421                  return originalImgAltTxt
422                });
423            }
424        });
425
426        $(".iconfloatleft a").each(function(){
427            var iconListImg = $(this).text();           
428            $(this).find('img').attr("alt", "Photo of " + iconListImg);        
429        });
430
431        var weatherImg = 0;
432            $(".weatherWrapper img").each(function(){
433            weatherImg++;         
434            $(this).attr("alt", "Photo of weather image " + weatherImg);        
435        });
436
437        
438      $('.nav-link').attr('aria-haspopup', 'true');
439      $(".divToolWrp").attr("tabindex", "0");
440      $(".divNavGroupLink").attr("tabindex", "0");
441      $('#spnRunSiteSearch').attr('tabindex', '0');
442      $('.genClickable').attr('tabindex', '0');
443      $('figure').attr('role', 'none');
444      $('table').attr('role', 'none');
445
446
447
448
449    });
450$('.noticeBoardReport a.viewReport').on('click', function (e) {
451    e.preventDefault();
452    $('#theModal').removeClass('councillorModal');
453    $('#theModal').removeClass('annualAuditReportModal');
454    $('#theModal').addClass('noticeBoardModal');
455    $('#theModal').modal('show').find('.modal-content').load($(this).attr('href'));
456});
457
458function toggleContactForms(formNumber)
459{
460    try
461    { 
462        if (document.querySelectorAll(".contact-us form") != null) {
463            var allForms = document.querySelectorAll(".contact-us form");
464
465            for (var i = 0; i < allForms.length; i++) {
466                allForms[i].style.display = "none";
467            }
468            allForms[formNumber].style.display = "block";
469
470            //***** reset optin labels to include link *****
471            if (document.getElementById("lblOptIn_General") != null) {
472                document.getElementById("lblOptIn_General").innerHTML = "I have read and I accept the <a href=\"/privacy\">privacy policy</a>";
473            }
474            if (document.getElementById("lblOptIn_request") != null) {
475                document.getElementById("lblOptIn_request").innerHTML = "I have read and I accept the <a href=\"/privacy\">privacy policy</a>";
476            }
477            if (document.getElementById("lblOptIn_delete") != null) {
478                document.getElementById("lblOptIn_delete").innerHTML = "I have read and I accept the <a href=\"/privacy\">privacy policy</a>";
479            }
480            if (document.getElementById("lblOptIn_alternative") != null) {
481                document.getElementById("lblOptIn_alternative").innerHTML = "I have read and I accept the <a href=\"/privacy\">privacy policy</a>";
482            }
483
484
485
486            //*****START style optin checkboxes and labels *****
487            if (document.getElementById("cbx_optin_general") != null) {
488                var optinCheckboxGrandParent_general = document.getElementById("cbx_optin_general").parentElement.parentElement;
489                optinCheckboxGrandParent_general.style.width = "45px";
490                optinCheckboxGrandParent_general.style.display = "inline-block";
491            }
492            if (document.getElementById("lblOptIn_General") != null) {
493                var optinLabelParent_general = document.getElementById("lblOptIn_General").parentElement;
494                optinLabelParent_general.style.width = "280px";
495                optinLabelParent_general.style.float = "left";
496                optinLabelParent_general.style.padding = "9px 0 0 15px";
497            }
498
499
500            if (document.getElementById("cbx_optin_request") != null) {
501                var optinCheckboxGrandParent_request = document.getElementById("cbx_optin_request").parentElement.parentElement;
502                optinCheckboxGrandParent_request.style.width = "45px";
503                optinCheckboxGrandParent_request.style.display = "inline-block";
504            }
505            if (document.getElementById("lblOptIn_request") != null) {
506                var optinLabelParent_request = document.getElementById("lblOptIn_request").parentElement;
507                optinLabelParent_request.style.width = "280px";
508                optinLabelParent_request.style.float = "left";
509                optinLabelParent_request.style.padding = "9px 0 0 15px";
510            }
511
512
513            if (document.getElementById("cbx_optin_delete") != null) {
514                var optinCheckboxGrandParent_delete = document.getElementById("cbx_optin_delete").parentElement.parentElement;
515                optinCheckboxGrandParent_delete.style.width = "45px";
516                optinCheckboxGrandParent_delete.style.display = "inline-block";
517            }
518            if (document.getElementById("lblOptIn_delete") != null) {
519                var optinLabelParent_delete = document.getElementById("lblOptIn_delete").parentElement;
520                optinLabelParent_delete.style.width = "280px";
521                optinLabelParent_delete.style.float = "left";
522                optinLabelParent_delete.style.padding = "9px 0 0 15px";
523            }
524
525
526            if (document.getElementById("cbx_optin_alternative") != null) {
527                var optinCheckboxGrandParent_alternative = document.getElementById("cbx_optin_alternative").parentElement.parentElement;
528                optinCheckboxGrandParent_alternative.style.width = "45px";
529                optinCheckboxGrandParent_alternative.style.display = "inline-block";
530            }
531            if (document.getElementById("lblOptIn_alternative") != null) {
532                var optinLabelParent_alternative = document.getElementById("lblOptIn_alternative").parentElement;
533                optinLabelParent_alternative.style.width = "280px";
534                optinLabelParent_alternative.style.float = "left";
535                optinLabelParent_alternative.style.padding = "9px 0 0 15px";
536            }
537            //*****END style optin checkboxes and labels *****
538        }
539    }
540    catch(err)  { }
541}
542
543//$('#theModal').on('hidden.bs.modal', function (e) {
544//    $('.modal-content').empty();
545//});
546function pageinate(contentWrapperId, paginationControlID, itemsPerPage)
547{
548    var pageArray = [];
549    var contentWrapper = document.getElementById(contentWrapperId);
550
551    var allItemsArr = document.querySelectorAll("#" + contentWrapperId + " .divContentItemPaginate")
552    console.log("##" + allItemsArr.length);
553    for (var i = 0; i < allItemsArr.length; i++)
554    {
555        allItemsArr[i].style.display = "none";
556    }
557
558    contentItemsArr = contentWrapper.children;
559    numberOfItems = contentItemsArr.length;
560    var itemGroups = Math.ceil(numberOfItems / itemsPerPage);
561    var buildCount = 0;
562    for (var i = 0; i < itemGroups; i++)
563    {
564        var newArr = [];
565        for (var j = 0; j < itemsPerPage; j++)
566        {
567            if (buildCount < numberOfItems)
568            {
569                newArr.push(contentWrapperId + "#" + buildCount);
570                buildCount++;
571            }
572        }
573        pageArray.push(newArr);
574    }
575
576    var controlWrp = document.getElementById(paginationControlID);
577    var firstPageArr = pageArray[0].toString().split(",", pageArray[0].length)
578    for (var i = 0; i < firstPageArr.length; i++)
579    {
580        var firstItemsArr = firstPageArr[i].split("#", firstPageArr[i].length);
581        contentWrapper.children[firstItemsArr[1]].style.display = "block";
582    }
583
584    for (var i = 0; i < pageArray.length; i++) {
585        var paginationLink = document.createElement("input");
586        paginationLink.type = "button";
587        paginationLink.value = i + 1;
588        paginationLink.id = "btnPaginationControl_" + contentWrapperId + i;
589        paginationLink.className = "btnPaginationControl_" + contentWrapperId;
590        paginationLink.setAttribute("onclick", "showPaginatedPages('" + pageArray[i] + "','" + contentWrapperId + "','" + paginationLink.id + "')");
591        controlWrp.appendChild(paginationLink);
592    }
593    controlWrp.children[0].style.color = "#00FF00";
594}
595function showPaginatedPages(pages, contentWrapperId, thisId)
596{
597    var contentWrapper = document.getElementById(contentWrapperId);
598    var allItemsArr = document.querySelectorAll("#" + contentWrapperId + " .divContentItemPaginate")
599    for (var i = 0; i < allItemsArr.length; i++)
600    {
601        allItemsArr[i].style.display = "none";
602    }
603
604    var pageArr = pages.split(",", pages.length)
605    for (var i = 0; i < pageArr.length; i++)
606    {
607        var itemsArr = pageArr[i].split("#", pageArr[i].length);
608        contentWrapper.children[itemsArr[1]].style.display = "block";
609    }
610
611    var allPaginationControls = document.querySelectorAll(".btnPaginationControl_" + contentWrapperId)
612    for (var i = 0; i < allPaginationControls.length; i++)
613    {
614        allPaginationControls[i].style.color = "#000000";
615    }
616    document.getElementById(thisId).style.color = "#00FF00";
617}
618function filterReportsAndAudits(preFilterType) {
619    
620    var selectedType = "all";
621    if (preFilterType != "" && preFilterType != null) {
622        selectedType = preFilterType;
623    }
624    else {
625        if (document.getElementById("selReportAuditType") != null) {
626            selectedType = document.getElementById("selReportAuditType").value;
627        }
628    }
629    console.log("selectedType: " + selectedType);
630    var postsWprArr = document.querySelectorAll(".reportAuditItem");
631    for (var i = 0; i < postsWprArr.length; i++)
632    {
633        var typeField = postsWprArr[i].querySelector(".reportGroupHead").innerHTML;
634        console.log("typeField: " + typeField);
635        if (typeField == selectedType || selectedType == "all")
636        {
637            postsWprArr[i].style.display = "block";
638        }
639        else
640        {
641            postsWprArr[i].style.display = "none";
642        }
643    }
644}
645function filterMeetings()
646{
647    console.log("testing meeting filtering on load...");
648    var selectedMonth = document.getElementById("selMeetingMonth").value;
649    var selectedYear = document.getElementById("selMeetingYear").value;
650    var selectedType = "all";
651    console.log("selectedYear : " + selectedYear );
652    if (document.getElementById("selMeetingType") != null)
653    {
654        selectedType = document.getElementById("selMeetingType").value;
655    }
656    
657    var elementObjectArr = [];
658    var postsWprArr = document.querySelectorAll(".divMpcItemInnerWrp");
659    for (var i = 0; i < postsWprArr.length; i++)
660    {
661        var dateFieldValue = postsWprArr[i].querySelector(".divMpcItemDateWrp").innerHTML;
662        var dateArr = dateFieldValue.split(" ");
663        var meetingTypeField = "";
664        if (postsWprArr[i].querySelector(".spnMeetingType") != null)
665        {
666            meetingTypeField = postsWprArr[i].querySelector(".spnMeetingType").innerHTML
667        }
668
669        //console.log(dateArr[0] + " * " + dateArr[1] + " * " + meetingTypeField);
670
671        var matchYear = false;
672        var matchMonth = false;
673        var matchType = false;
674        if (selectedYear == "all" || dateArr[1] == selectedYear)
675        {
676            matchYear = true;
677        }
678        if (selectedMonth == "all" || dateArr[0] == selectedMonth)
679        {
680            matchMonth = true;
681        }
682        if (selectedType == "all" || meetingTypeField == selectedType)
683        {
684            matchType = true;
685        }
686
687        if (matchMonth == true && matchYear == true && matchType == true)
688        {
689            postsWprArr[i].style.display = "block";
690        }
691        else
692        {
693            postsWprArr[i].style.display = "none";
694        }
695    }
696}
697function addMobileNavDropdowns()
698{
699    var windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
700    if (windowWidth < 3200)
701    {
702        var targetElemnts = document.querySelectorAll("#navbarResponsive > .navbar-nav > .nav-item");
703        for (var i = 0; i < targetElemnts.length; i++)
704        {
705            var dropdowns = targetElemnts[i].querySelectorAll(".dropdown-menu");
706            if (dropdowns.length > 0)
707            {
708                targetElemnts[i].innerHTML = "<span class=\"fa fa-chevron-down mobileNavToggle\" tabindex=\"0\" role=\"link\" aria-label=\"Toggle Navigation\" onclick=\"toggelNavDropdown(this)\"></span> " + targetElemnts[i].innerHTML ;
709                targetElemnts[i].className = "nav-item open";
710            }
711        }
712        $(".dropdown-menu .dropdown-menu").parent().addClass("openinner");
713        $(".openinner").append("<span class=\'fa fa-chevron-down mobileNavToggle\' role=\"link\" tabindex=\"0\" aria-label=\'Toggle Navigation\' onclick=\'toggelNavDropdown(this)\'></span>");
714    }  
715}
716function toggelNavDropdown(clickSpan)
717{
718    var thisNodeName = clickSpan.className;
719    var targetDropdown = clickSpan.parentNode.querySelector(".dropdown-menu");
720    if (targetDropdown.style.display != "block")
721    {
722        targetDropdown.style.display = "block";
723        clickSpan.className = "fa fa-chevron-up mobileNavToggle";
724    }
725    else
726    {
727        targetDropdown.style.display = "none";
728        clickSpan.className = "fa fa-chevron-down mobileNavToggle";
729    }
730    console.log(thisNodeName);
731}
732function centerAndScaleCarouselImages()
733{
734    var carouselWrp = document.querySelector(".flexslider")
735    var carouselWidth = carouselWrp.clientWidth;
736    var carouseHeight = carouselWrp.clientHeight;
737
738    var slideImages = document.querySelectorAll(".flexslider .img-responsive");
739    for (var i = 0; i < slideImages.length; i++)
740    {
741        var slideImageWidth = slideImages[i].naturalWidth;
742        var slideImageHeight = slideImages[i].naturalHeight;
743
744        if (slideImageWidth > carouselWidth)
745        {
746            if (slideImageHeight > carouseHeight)
747            {
748                slideImages[i].style.width = "100%";
749            }
750            else
751            {
752                slideImages[i].style.height = carouseHeight + "px";
753                slideImages[i].style.left = -((slideImageWidth / 2) - (carouselWidth / 2)) + "px";
754            }
755        }
756        else
757        {
758            if (slideImageHeight > carouseHeight)
759            {               
760                slideImages[i].style.width = carouselWidth + "px";
761                slideImages[i].style.top = -((slideImageHeight / 2) - (carouseHeight / 2)) + "px";
762            }
763            else
764            {
765                slideImages[i].style.width = carouselWidth + "px";
766                var imageHeight = slideImages[i].clientHeight;
767                slideImages[i].style.top = -((imageHeight / 2) - (carouseHeight / 2)) + "px";
768            }
769        }
770    }
771}
772function updateForWcag()
773{
774    if(document.querySelectorAll(".flexslider .slides .clone" != null))
775    {
776        var carouselCloneSlides = document.querySelectorAll(".flexslider .slides .clone");
777        for (var i = 0; i < carouselCloneSlides.length; i++)
778        {
779            carouselCloneSlides[i].setAttribute("tabindex", "-1");
780            //carouselCloneSlides[i].setAttribute("role", "banner");
781            carouselCloneSlides[i].setAttribute("aria-hidden", "false");
782        }
783    }
784
785    if (document.getElementById("txbFullName_general") != null)
786    {
787        document.getElementById("txbFullName_general").setAttribute("aria-label", "Full name");
788    }
789    if (document.getElementById("txbEmail_general") != null)
790    {
791        document.getElementById("txbEmail_general").setAttribute("aria-label", "Email");
792    }
793    if (document.getElementById("txaMessage_general") != null)
794    {
795        document.getElementById("txaMessage_general").setAttribute("aria-label", "Message");
796    }
797    if (document.getElementById("cbx_optin_general") != null)
798    {
799        document.getElementById("cbx_optin_general").setAttribute("aria-label", "I have read and I accept the privacy policy");
800    }
801
802    if (document.getElementById("txbFirstName_request") != null)
803    {
804        document.getElementById("txbFirstName_request").setAttribute("aria-label", "First name");
805    }
806    if (document.getElementById("txbLastName_request") != null)
807    {
808        document.getElementById("txbLastName_request").setAttribute("aria-label", "Last name");
809    }
810    if (document.getElementById("txbEmail_request") != null)
811    {
812        document.getElementById("txbEmail_request").setAttribute("aria-label", "Email");
813    }
814    if (document.getElementById("txaMessage_request") != null)
815    {
816        document.getElementById("txaMessage_request").setAttribute("aria-label", "Message");
817    }
818    if (document.getElementById("cbx_optin_request") != null)
819    {
820        document.getElementById("cbx_optin_request").setAttribute("aria-label", " have read and I accept the privacy policy");
821    }
822
823    if (document.getElementById("txbFirstName_delete") != null)
824    {
825        document.getElementById("txbFirstName_delete").setAttribute("aria-label", "First name");
826    }
827    if (document.getElementById("txbLastName_delete") != null)
828    {
829        document.getElementById("txbLastName_delete").setAttribute("aria-label", "Last name");
830    }
831    if (document.getElementById("txbEmail_delete") != null)
832    {
833        document.getElementById("txbEmail_delete").setAttribute("aria-label", "Email");
834    }
835    if (document.getElementById("txaMessage_delete") != null)
836    {
837        document.getElementById("txaMessage_delete").setAttribute("aria-label", "Message");
838    }
839    if (document.getElementById("cbx_optin_delete") != null)
840    {
841        document.getElementById("cbx_optin_delete").setAttribute("aria-label", " have read and I accept the privacy policy");
842    }
843
844    if (document.getElementById("rdoDescription_0") != null)
845    {
846        document.getElementById("rdoDescription_0").setAttribute("aria-label", "a member of the public");
847    }
848    if (document.getElementById("rdoDescription_1") != null)
849    {
850        document.getElementById("rdoDescription_1").setAttribute("aria-label", "a representative of an organisation ");
851    }
852    if (document.getElementById("rdoDescription_2") != null)
853    {
854        document.getElementById("rdoDescription_2").setAttribute("aria-label", "a legal adviser or representative ");
855    }
856    if (document.getElementById("rdoDescription_3") != null)
857    {
858        document.getElementById("rdoDescription_3").setAttribute("aria-label", "from a central government department, agency or NDPB ");
859    }
860    if (document.getElementById("rdoDescription_4") != null)
861    {
862        document.getElementById("rdoDescription_4").setAttribute("aria-label", "a member or officer of Parliament ");
863    }
864    if (document.getElementById("rdoDescription_5") != null)
865    {
866        document.getElementById("rdoDescription_5").setAttribute("aria-label", "a researcher ");
867    }
868    if (document.getElementById("rdoDescription_6") != null)
869    {
870        document.getElementById("rdoDescription_6").setAttribute("aria-label", "a journalist or representative of the media ");
871    }
872    if (document.getElementById("rdoDescription_7") != null)
873    {
874        document.getElementById("rdoDescription_7").setAttribute("aria-label", "a supplier or service provider ");
875    }
876    if (document.getElementById("rdoDescription_8") != null)
877    {
878        document.getElementById("rdoDescription_8").setAttribute("aria-label", "from outside the UK ");
879    }
880    if (document.getElementById("rdoDescription_9") != null)
881    {
882        document.getElementById("rdoDescription_9").setAttribute("aria-label", "other (please specify): ");
883    }
884    if (document.getElementById("txbOtherDescription") != null)
885    {
886        document.getElementById("txbOtherDescription").setAttribute("aria-label", "Other description");
887    }
888    if (document.getElementById("txbFirtName_alternative") != null)
889    {
890        document.getElementById("txbFirtName_alternative").setAttribute("aria-label", "First name");
891    }
892    if (document.getElementById("txbLastName_alternative") != null)
893    {
894        document.getElementById("txbLastName_alternative").setAttribute("aria-label", "Last name");
895    }
896    if (document.getElementById("txaMessage") != null)
897    {
898        document.getElementById("txaMessage").setAttribute("aria-label", "Message");
899    }
900    if (document.getElementById("txbEmail_alternative") != null)
901    {
902        document.getElementById("txbEmail_alternative").setAttribute("aria-label", "Email");
903    }
904    if (document.getElementById("cbx_optin_alternative") != null)
905    {
906        document.getElementById("cbx_optin_alternative").setAttribute("aria-label", "have read and I accept the privacy policy");
907    }
908
909    if (document.querySelectorAll(".g-recaptcha" != null))
910    {
911    var recaptchaItems = document.querySelectorAll(".g-recaptcha iframe:nth-child(1)");
912        //console.log("recaptchas: " + recaptchaItems.length )
913        for (var i = 0; i < recaptchaItems.length; i++)
914        {
915            recaptchaItems[i].setAttribute("title", "google recaptcha");
916        }
917        var recaptchaTextItems = document.querySelectorAll(".g-recaptcha textarea");
918        //console.log("recaptchas: " + recaptchaTextItems.length )
919        for (var i = 0; i < recaptchaTextItems.length; i++) {
920            recaptchaTextItems[i].setAttribute("aria-label", "google recaptcha");
921        }
922    }
923
924
925    if (document.getElementById("txbEmail") != null)
926    {
927        document.getElementById("txbEmail").setAttribute("aria-label", "Email");
928    }
929    if (document.getElementById("cbx_optIn_newsletter") != null)
930    {
931        document.getElementById("cbx_optIn_newsletter").setAttribute("aria-label", "have read and I accept the privacy policy");
932    }
933    if (document.getElementById("cbx_agree_newsletter") != null)
934    {
935        document.getElementById("cbx_agree_newsletter").setAttribute("aria-label", "I agree to receiving communications from My Parish Council ");
936    }
937}
938function siteSearch()
939{
940    var searchTerms = document.getElementById("txbSiteSearch").value;
941    var searchUrlAndQueryString = "/search?Terms=" + searchTerms.replace(" ", "+")
942    window.location = searchUrlAndQueryString;
943}
944function checkForSearchFeature()
945{
946    console.log("checking for search page status");
947    var xmlhttp = new XMLHttpRequest();
948    xmlhttp.onreadystatechange = function ()
949    {
950        if (xmlhttp.readyState == 4)
951        {
952            if (xmlhttp.status == 200)
953            {
954                document.getElementById("divSearchToolInnerWrp").style.display = "block";
955            }
956        }
957    }
958    xmlhttp.open("GET", "/search", true);
959    xmlhttp.send();
960}
961function setFocus(id)
962{
963    document.getElementById(id).click();
964}
965function buildSitemap()
966{
967    xmlhttp = new XMLHttpRequest();
968    xmlhttp.open("GET", "sitemap.xml", false);
969    xmlhttp.send();
970    xmlDoc = xmlhttp.responseXML;
971
972    var urlArr = xmlDoc.getElementsByTagName("url");
973
974    var linkArr = [];
975    for (i = 0; i < urlArr.length; i++)
976    {
977        var location = urlArr[i].getElementsByTagName("loc")[0].childNodes[0].nodeValue;
978        var domainAndPath = location.substr(location.indexOf("//") + 2)
979        var path = domainAndPath.substr(domainAndPath.indexOf("/") + 1);
980        if (path.indexOf("template-") == -1)
981        {
982            if (path == "")
983            {
984                path = "home";
985            }
986            linkArr.push(path);
987        }
988    }
989    linkArr.sort();
990    var sitemapHtml = "<ul>";
991    for (var i = 0; i < linkArr.length; i++)
992    {
993        var pathBuilder = "";
994        var subItemIndex = linkArr[i].indexOf("/");
995        if (subItemIndex != -1) {
996            var subItemArr = linkArr[i].split("/");
997
998            sitemapHtml += "<li><a href=\"/" + subItemArr[0] + "\">" + capitalise(subItemArr[0]).replace(/-/g, " ") + "</a>"
999            pathBuilder = "/" + subItemArr[0];
1000            for (var j = 1; j < subItemArr.length; j++)
1001            {
1002                pathBuilder += "/" + subItemArr[j];
1003                sitemapHtml += "<ul><li><a href=\"" + pathBuilder + "\">" + capitalise(subItemArr[j]).replace(/-/g, " ") + "</a>";
1004            }
1005            for (var j = 1; j < subItemArr.length; j++)
1006            {
1007                sitemapHtml += "</li></ul>";
1008            }
1009            sitemapHtml += "</li>";
1010        }
1011        else {
1012            sitemapHtml += "<li><a href=\"/" + linkArr[i] + "\">" + capitalise(linkArr[i]).replace(/-/g, " "); + "</li>"
1013        }
1014    }
1015    sitemapHtml += "</ul>";
1016    document.getElementById("divSitemapWrp").innerHTML = sitemapHtml;
1017}
1018function capitalise(inputStr)
1019{
1020    var outputStr = inputStr.charAt(0).toUpperCase() + inputStr.slice(1);
1021    return outputStr;
1022}
1023function sortTable(n)
1024{
1025    var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
1026    table = document.getElementById("tblPlanningApplications");
1027    switching = true;
1028    // Set the sorting direction to ascending:
1029    dir = "asc";
1030    /* Make a loop that will continue until
1031    no switching has been done: */
1032    while (switching)
1033    {
1034        // Start by saying: no switching is done:
1035        switching = false;
1036        rows = table.rows;
1037        /* Loop through all table rows (except the
1038        first, which contains table headers): */
1039        for (i = 1; i < (rows.length - 1); i++)
1040        {
1041            // Start by saying there should be no switching:
1042            shouldSwitch = false;
1043            /* Get the two elements you want to compare,
1044            one from current row and one from the next: */
1045            x = rows[i].getElementsByTagName("TD")[n];
1046            y = rows[i + 1].getElementsByTagName("TD")[n];
1047            /* Check if the two rows should switch place,
1048            based on the direction, asc or desc: */
1049            if (dir == "asc")
1050            {
1051                if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase())
1052                {
1053                    // If so, mark as a switch and break the loop:
1054                    shouldSwitch = true;
1055                    break;
1056                }
1057            } else if (dir == "desc")
1058            {
1059                if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase())
1060                {
1061                    // If so, mark as a switch and break the loop:
1062                    shouldSwitch = true;
1063                    break;
1064                }
1065            }
1066        }
1067        if (shouldSwitch)
1068        {
1069            /* If a switch has been marked, make the switch
1070            and mark that a switch has been done: */
1071            rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
1072            switching = true;
1073            // Each time a switch is done, increase this count by 1:
1074            switchcount++;
1075        }
1076        else
1077        {
1078            /* If no switching has been done AND the direction is "asc",
1079            set the direction to "desc" and run the while loop again. */
1080            if (switchcount == 0 && dir == "asc") {
1081                dir = "desc";
1082                switching = true;
1083            }
1084        }
1085    }
1086}
1087function councilContentPopup(title, longText)
1088{
1089    document.getElementById("h3CouncilContentPopupTitle").innerHTML = title;
1090    document.getElementById("parCouncilContentPopupText").innerHTML = longText;
1091    document.getElementById("divCouncilContentPopupWrp").style.display = "block";
1092}
1093function closeCouncilContentPopup()
1094{
1095    document.getElementById("divCouncilContentPopupWrp").style.display = "none";
1096}
1097function requestPlanningData(searchID, zoomLevel, defaultMapFilterValue,version)
1098{
1099
1100    var xmlhttp = new XMLHttpRequest();
1101    var url = "https://api.kickfire.co.uk/api/planning/getbysearchid";
1102    var data = "id=" + searchID + "";
1103    xmlhttp.onreadystatechange = function () {
1104
1105        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
1106        {
1107            var planningDataJson = JSON.parse(xmlhttp.responseText);
1108            processPlanningData(planningDataJson, zoomLevel, defaultMapFilterValue)
1109        }
1110    }
1111    xmlhttp.open("POST", url, true);
1112    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
1113    xmlhttp.send(data);
1114}
1115var map;
1116var markerArr = [];
1117function processPlanningData(planningDataRaw, zoomLevel, defaultMapFilterValue)
1118{
1119    var latArr = [];
1120    var longArr = [];
1121    for (var i = 0; i < planningDataRaw.length; i++)
1122    {
1123        if (planningDataRaw[i].latitude != null)
1124        {
1125            latArr.push(planningDataRaw[i].latitude);
1126        }
1127        if (planningDataRaw[i].longitude != null)
1128        {
1129            longArr.push(planningDataRaw[i].longitude);
1130        }
1131    }
1132
1133    var latMax = latArr.sort(function (a, b) { return b - a })[0];
1134    var latMin = latArr.sort(function (a, b) { return a - b })[0];
1135    var latCenter = parseFloat(latMin) + ((latMax - latMin) / 2);
1136    var longMax = longArr.sort(function (a, b) { return b - a })[0];
1137    var longMin = longArr.sort(function (a, b) { return a - b })[0];
1138    var longCenter = parseFloat(longMin) + ((longMax - longMin) / 2);
1139
1140    var mapOptions = {
1141        center: new google.maps.LatLng(latCenter, longCenter),
1142        zoom: zoomLevel,
1143        mapTypeId: 'terrain'
1144    };
1145    map = new google.maps.Map(document.getElementById("divPlanningTrackerMap"),
1146        mapOptions);
1147
1148    var planningData = [];
1149    var primaryPlanningData = [];
1150    var secondaryPlanningData = [];
1151    if (defaultMapFilterValue == "")
1152    {
1153        planningData = planningDataRaw;
1154    }
1155    else
1156    {
1157        for (var i = 0; i < planningDataRaw.length; i++)
1158        {
1159            if (planningDataRaw[i].status == defaultMapFilterValue)
1160            {
1161                primaryPlanningData.push(planningDataRaw[i]);
1162            }
1163            else
1164            {
1165                secondaryPlanningData.push(planningDataRaw[i])
1166            }
1167        }
1168        planningData =  primaryPlanningData.concat(secondaryPlanningData);
1169    }
1170
1171    var applictionRowsHTML = "";
1172    var statusArr = [];
1173    for (var i = 0; i < planningData.length; i++)
1174    {
1175        applictionRowsHTML += "<tr>" +
1176            "<td  data-label=\"App. No.\">" + planningData[i].reference_number + "</td>" +
1177            "<td  data-label=\"Location\">" + planningData[i].proposal + "</td>" +
1178            "<td  data-label=\"Proposal\">" + planningData[i].address + "</td>" +
1179            "<td  data-label=\"Validated At\">
1179" + planningData[i].validated_at + "</td>" +
1180            "<td class=\"statusBtn\" data-label=\"App. Status\">" + planningData[i].status + "</td>" +
1181            "<td  data-label=\"Last Updated\">" + ConvertDate(planningData[i].updated_at.date) + "</td>" +
1182            "<td><a href=" + planningData[i].full_details_url + " target=\"_blank\">Full Details <i class=\"fa fa-external-link\"></i></a></td>" +
1183            "</tr>";
1184
1185        if (statusArr.indexOf(planningData[i].status) == -1)
1186        {
1187            statusArr.push(planningData[i].status);
1188        }
1189        
1190
1191        var contentString = planningData[i].reference_number + "<br />" + planningData[i].proposal + "<br />" + planningData[i].address + "<br />" +
1192            " <a href=\"" + planningData[i].full_details_url + "\" target=\"_blank\">Read more</a>";
1193
1194        var marker = new google.maps.Marker({
1195            map: map,
1196            animation: google.maps.Animation.DROP,
1197            position: new google.maps.LatLng(planningData[i].latitude, planningData[i].longitude),
1198            title: planningData[i].status
1199
1200        });
1201        markerArr.push(marker)
1202
1203        var infowindow = new google.maps.InfoWindow()
1204
1205        google.maps.event.addListener(marker, 'click', (function (marker, contentString, infowindow) {
1206            return function () {
1207                infowindow.setContent(contentString);
1208                infowindow.open(map, marker);
1209            };
1210        })(marker, contentString, infowindow));
1211    }
1212    var mapfilterHtml = "<select id=\"slctPlanningMapFilter\" onchange=\"togglePlanningMapMarkers()\">";
1213    if (defaultMapFilterValue == "")
1214    {
1215        mapfilterHtml += "<option value=\"All\" >All</option>";
1216    }
1217    else
1218    {
1219        mapfilterHtml += "<option value=\"" + defaultMapFilterValue + "\" >" + defaultMapFilterValue + "</option>" +
1220                         "<option value=\"All\">All</option>";
1221    }
1222    
1223    for (var i = 0; i < statusArr.length; i++)
1224    {
1225        if (statusArr[i] != defaultMapFilterValue)
1226        {
1227            mapfilterHtml += "<option value=\"" + statusArr[i] + "\">" + statusArr[i] + "</option>";
1228        }
1229    }
1230    mapfilterHtml += "</select>";  
1231
1232    document.getElementById("divPlanningMapFilterWrp").innerHTML = mapfilterHtml;
1233    document.getElementById("tbdyApplications").innerHTML = applictionRowsHTML;
1234    document.getElementById("imgPlanningTrackerPreloader").style.display = "none";
1235    togglePlanningMapMarkers();
1236    
1237}
1238function planingTrackerTab(tabName)
1239{
1240    var listPanel = document.getElementById("divPlaningTrackerListWrp");
1241    var mapPanel = document.getElementById("divPlanningTrackerMapWrp");
1242    var tabWrapper = document.getElementById("divPlanningTrackerTabWrp");
1243    if (tabName == 'list')
1244    {
1245        tabWrapper.getElementsByTagName("button")[0].style.backgroundColor = "#CCCCCC";
1246        tabWrapper.getElementsByTagName("button")[1].style.backgroundColor = "#EFEFEF";
1247        listPanel.style.display = "block";
1248        mapPanel.style.display = "none";
1249    }
1250    else
1251    {
1252        tabWrapper.getElementsByTagName("button")[1].style.backgroundColor = "#CCCCCC";
1253        tabWrapper.getElementsByTagName("button")[0].style.backgroundColor = "#EFEFEF";
1254        listPanel.style.display = "none";
1255        mapPanel.style.display = "block";
1256    }
1257}
1258function togglePlanningMapMarkers()
1259{
1260
1261    var status = document.getElementById("slctPlanningMapFilter").value;
1262
1263    for (var i = 0; i < markerArr.length; i++)
1264    {
1265        markerArr[i].setMap(null);
1266    }
1267
1268    for (var i = 0; i < markerArr.length; i++)
1269    {
1270        if (status == "" || status == "All")
1271        {
1272            markerArr[i].setMap(map);
1273        }
1274        else
1275        {
1276            if (markerArr[i].title == status)
1277            {
1278                markerArr[i].setMap(map);
1279            }
1280        }
1281        
1282    }
1283}
1284function ConvertDate(input)
1285{
1286    var dateTime = new Date(input)
1287    var monthArr = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
1288    var dayArr = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
1289    var dayName = dayArr[dateTime.getDay()];
1290    var day = dateTime.getDate();
1291    var month = monthArr[dateTime.getMonth()];
1292    var year = dateTime.getFullYear();
1293    var output = dayName + " " + day + " " + month + " " + year
1294    return output;
1295}
1296function openAccordianV1Body(id)
1297{
1298    var allAnswers = document.querySelectorAll(".divAccordianBody");
1299    for (var i = 0; i < allAnswers.length; i++)
1300    {
1301        allAnswers[i].style.display = "none";
1302    }
1303    var panel = document.getElementById(id).nextElementSibling.style.display = "block";
1304}
1305
1306var fixMyStreetLatLngArr;
1307function requestFixMyStreetFeed(lat, long, radius, targetElementId, itemsToDisplay, mapZoom)
1308{
1309    var feedURL = "https://www.fixmystreet.com/rss/l/" + lat + "," + long + "/" + radius + "";
1310    
1311    var containerWidth = document.getElementById("divFixMyStreetFeedWrp_" + targetElementId).clientWidth;
1312    var containerResponsiveStyle = "";
1313    if (containerWidth < 540) {
1314        containerResponsiveStyle = "style=\"width:100%;\""
1315    }
1316    fixMyStreetLatLngArr = [];
1317    var xmlhttp = new XMLHttpRequest();
1318    xmlhttp.onreadystatechange = function () {
1319        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
1320        {
1321            xmlDoc = xmlhttp.responseXML;
1322
1323            var feedHeading = xmlDoc.getElementsByTagName("channel").item(0).getElementsByTagName("title")[0].innerHTML;
1324            document.getElementById("divFixMyStreetFeedWrp_" + targetElementId).innerHTML = "<h2 class=\"h2FixMyStreetFeed\">" + feedHeading + "</h2>";
1325            document.getElementById("divFixMyStreetMapHeadingWrp_" + targetElementId).innerHTML = "<h2 class=\"h2FixMyStreetFeed\">" + feedHeading + "</h2>";
1326
1327            var mapOptions = {
1328                center: new google.maps.LatLng(lat, long),
1329                zoom: mapZoom,
1330                mapTypeId: 'terrain'
1331            };
1332            var map = new google.maps.Map(document.getElementById("divFixMyStreetFeedMap_" + targetElementId),
1333                mapOptions)
1334
1335            var itemList = xmlDoc.getElementsByTagName("item");
1336            for (i = 0; i < itemsToDisplay; i++) {
1337                var title = itemList.item(i).getElementsByTagName("title")[0].innerHTML;
1338                var link = itemList.item(i).getElementsByTagName("link")[0].innerHTML;
1339                var description = itemList.item(i).getElementsByTagName("description")[0].innerHTML;
1340                var category = itemList.item(i).getElementsByTagName("category")[0].innerHTML;
1341                var publicationDate = itemList.item(i).getElementsByTagName("pubDate")[0].innerHTML;
1342                var location = itemList.item(i).getElementsByTagName("georss:point")[0].innerHTML;
1343                fixMyStreetLatLngArr.push(location);
1344                var imageElement = "";
1345                var imagPathStartIndex = description.indexOf("src=\"");
1346                var imagPathEndIndex = description.indexOf("\"", (imagPathStartIndex + 5));
1347                var imagePath;
1348                if (imagPathStartIndex != -1) {
1349                    imagePath = description.substring((imagPathStartIndex + 5), imagPathEndIndex);
1350
1351                    imageElement = "<img src=\"" + imagePath + "\" alt=\"" + title + " image\" />";
1352                }
1353                else {
1354                    imageElement = "<img src=\"/TheParishCouncilThemeV1/img/noImageAvailable.jpg\" alt=\"" + title + " image\" />";
1355                }
1356                var descriptionEndIndex = description.indexOf("&lt;br&gt;");
1357                var trimmedDescription = description.substring(0, descriptionEndIndex);
1358                //document.getElementById("divFixMyStreetFeedWrp_" + targetElementId).innerHTML += "<div class=\"divFixMyStreetFeedItem\"><h3>" + title + "</h3>" +
1359                //    "<div class=\"divFixmystreetFeedItemLeft\" " + containerResponsiveStyle + ">" + imageElement + "</div> " +
1360                //    "<div class=\"divFixmystreetFeedItemRight\" " + containerResponsiveStyle + "><p>" + trimmedDescription + "</p>" +
1361                //    "<button  class=\"btn\" onclick=\"showFeedItemOnMap('" + i + "','" + location + "')\">Show on map</button><a class=\"btn\" href=\"" + link + "\" target=\"_blank\">More Details</a></div>" +
1362                //    "<div class=\"divFeedItemMapWrp\" id=\"divFeedItemMapWrp_" + i + "\"><div class=\"divFeedItemMap\" id=\"divFeedItemMap_" + i + "\"></div></div></div><br />";
1363
1364                document.getElementById("divFixMyStreetFeedWrp_" + targetElementId).innerHTML += "<div class=\"divFixMyStreetFeedItem\"><h3>" + title + "</h3>" +
1365                    "<div class=\"divFixmystreetFeedItemLeft\" " + containerResponsiveStyle + ">" + imageElement + "</div> " +
1366                    "<div class=\"divFixmystreetFeedItemRight\" " + containerResponsiveStyle + "><p>" + trimmedDescription + "</p>" +
1367                    "<a class=\"btn\" href=\"" + link + "\" target=\"_blank\">More Details</a></div>" +
1368                    "<div class=\"divFeedItemMapWrp\" id=\"divFeedItemMapWrp_" + i + "\"><div class=\"divFeedItemMap\" id=\"divFeedItemMap_" + i + "\">map</div></div></div><br />";
1369                
1370                var contentString = title + "<br />" + trimmedDescription + "<br />" + "<a href=\"" + link + "\" target=\"_blank\">More Details</a>";
1371                var markerLatLngArr = location.split(" ", location.length)
1372                var marker = new google.maps.Marker({
1373                    map: map,
1374                    animation: google.maps.Animation.DROP,
1375                    position: new google.maps.LatLng(markerLatLngArr[0], markerLatLngArr[1]),
1376
1377                });
1378                var infowindow = new google.maps.InfoWindow()
1379
1380                google.maps.event.addListener(marker, 'click', (function (marker, contentString, infowindow) {
1381                    return function () {
1382                        infowindow.setContent(contentString);
1383                        infowindow.open(map, marker);
1384                    };
1385                })(marker, contentString, infowindow));
1386
1387            }
1388            for (j = 0; j < fixMyStreetLatLngArr.length; j++)
1389            {
1390                showFeedItemOnMap(j, fixMyStreetLatLngArr[j]);
1391            }
1392        }
1393    }
1394    xmlhttp.open("GET", feedURL, true);
1395    xmlhttp.send();
1396}
1397function fixMyStreetTab(tabName, id)
1398{
1399    var listPanel = document.getElementById("divFixMyStreetListViewWrp_" + id);
1400    var mapPanel = document.getElementById("divFixMyStreetMapViewWrp_" + id);
1401    var mapViewButton = document.querySelector(".btnFixMyStreetTabList");
1402    var listViewButton = document.querySelector(".btnFixMyStreetTabMap");
1403    if (tabName == 'list')
1404    {
1405        listPanel.style.display = "block";
1406        mapPanel.style.display = "none";
1407        listViewButton.style.backgroundColor = "#CCCCCC";
1408        mapViewButton.style.backgroundColor = "#EFEFEF";
1409    }
1410    else
1411    {
1412        listPanel.style.display = "none";
1413        mapPanel.style.display = "block";
1414        listViewButton.style.backgroundColor = "#EFEFEF";
1415        mapViewButton.style.backgroundColor = "#CCCCCC";
1416    }
1417}
1418function showFeedItemOnMap(id, location)
1419{
1420    console.log("id: " + id);
1421    console.log("location: " + location);
1422    var test = document.getElementById("divFeedItemMap_" + id).innerHTML;
1423    console.log("test: " + test);
1424    var markerLatLngArr = location.split(" ", location.length)
1425    var mapOptions = {
1426        center: new google.maps.LatLng(markerLatLngArr[0], markerLatLngArr[1]),
1427        zoom: 14,
1428        mapTypeId: 'terrain'
1429    };
1430    var map = new google.maps.Map(document.getElementById("divFeedItemMap_" + id),
1431        mapOptions)
1432    var marker = new google.maps.Marker({
1433        map: map,
1434        animation: google.maps.Animation.DROP,
1435        position: new google.maps.LatLng(markerLatLngArr[0], markerLatLngArr[1]),
1436
1437    });
1438    //document.getElementById("divFeedItemMapWrp_" + id).style.display = "block";
1439}
1440function addToCalendar(startTime, startDate, endTime, endDate, title, location, clerkEmail, parishName) {
1441
1442    var eventStart = startDate + "T" + startTime
1443    var eventEnd = endDate + "T" + endTime;
1444
1445    var data = [];
1446    data.push("BEGIN:VCALENDAR");
1447    data.push("VERSION:2.0");
1448    data.push("PRODID:-//hacksw/handcal//NONSGML v1.0//EN");
1449    data.push("BEGIN:VEVENT");
1450    data.push("UID:" + title.replace(/\s/g, "") + eventStart);
1451    data.push("ORGANIZER; CN=" + parishName + ": MAILTO: " + clerkEmail + "");
1452    data.push("DTSTART:" + eventStart);
1453    data.push("DTEND:" + eventEnd);
1454    data.push("SUMMARY:" + title);
1455    data.push("LOCATION:" + location);
1456    data.push("END:VEVENT");
1457    data.push("END:VCALENDAR");
1458
1459    var csvFile = new Blob([data.join("\n")], { type: "text/calendar" });
1460    var downloadLink = document.createElement("a");
1461    downloadLink.download = title.replace(/\s/g, "_") + ".ics";
1462    downloadLink.href = window.URL.createObjectURL(csvFile);
1463    document.body.appendChild(downloadLink);
1464    downloadLink.click();
1465}
1466function stripEmptyHeadings()
1467{
1468    var tagArr = ["h1", "h2", "h3", "h4", "h5", "h6"]
1469    for (var i = 0; i < tagArr.length; i++)
1470    {
1471        var targetElementArr = document.querySelectorAll(tagArr[i])
1472        for (var j = 0; j < targetElementArr.length; j++)
1473        {
1474            var targetElement = targetElementArr[j];
1475            if (targetElement.textContent == "")
1476            {
1477                targetElement.remove();
1478            }
1479        }
1480    }
1481}

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.