PageSourceSearch

https://be-fibre.co.uk/wp-content/themes/befibre2022/js/app.js?4921

js be-fibre.co.uk collected 2026-09-30 09:53:48 UTC 9,970 bytes, 270 lines download raw bytes

1(function () {
2    let cookie = {
3        ignore_url_pattern: ['politica-de-cookies', 'aviso-legal', 'politica-de-privacidad'],
4        init: function () {
5            let show_alert = false;
6            if (!cookie.isMessageHiddenByUser()) {
7                show_alert = true;
8                for (let i = 0; i < cookie.ignore_url_pattern.length; i++) {
9                    if ((location.href + '').split(cookie.ignore_url_pattern[i]).length > 1) {
10                        show_alert = false;
11                    }
12                }
13                if (show_alert) {
14                    if (typeof (document.referrer) != 'undefined' && document.referrer.split(location.hostname).length > 1) {
15                        let comes_from_legal_notice = false;
16                        for (let i = 0; i < cookie.ignore_url_pattern.length; i++) {
17                            if (document.referrer.split(cookie.ignore_url_pattern[i]).length > 1) {
18                                comes_from_legal_notice = true;
19                            }
20                        }
21                        if (!comes_from_legal_notice) {
22                            cookie.saveCookiesEnabled();
23                        }
24                    }
25                }
26            }
27            if (cookie.areCookiesEnabled()) {
28                let cookieReplaces = document.querySelectorAll('[data-cookie-replace]');
29                for (let i = 0; i < cookieReplaces.length; i++) {
30                    cookieReplaces[i].outerHTML = cookieReplaces[i].getAttribute('data-cookie-replace');
31                }
32                let cookieHints = document.querySelectorAll('[data-cookie-hint]');
33                for (let i = 0; i < cookieHints.length; i++) {
34                    cookieHints[i].removeAttribute('data-cookie-hint');
35                }
36                let cookieScripts = document.querySelectorAll('script[data-cookie-run]');
37                for (let i = 0; i < cookieScripts.length; i++) {
38                    eval(cookieScripts[i].getAttribute('data-cookie-run'));
39                }
40            }
41            if (!show_alert) {
42                cookie.hideMessage();
43            } else {
44                let cookieAccepts = document.querySelectorAll('[data-cookie-accept]');
45                for (let i = 0; i < cookieAccepts.length; i++) {
46                    cookieAccepts[i].addEventListener('click', function () {
47                        cookie.userAcceptanceClick();
48                    });
49                }
50            }
51        },
52        areCookiesEnabled: function () {
53            try {
54                return localStorage.getItem('enable-cookies') === 'true';
55            } catch (e) {
56                return false;
57            }
58        },
59        isMessageHiddenByUser: function () {
60            try {
61                return localStorage.getItem('message-hidden-cookies') === 'true';
62            } catch (e) {
63                return false;
64            }
65        },
66        saveMessageHidden: function () {
67            try {
68                localStorage.setItem('message-hidden-cookies', 'true');
69            } catch (e) {
70                return;
71            }
72        },
73        hideMessage: function () {
74            let cookieAlerts = document.querySelectorAll('[data-cookie-banner]');
75            for (let i = 0; i < cookieAlerts.length; i++) {
76                cookieAlerts[i].parentNode.removeChild(cookieAlerts[i]);
77            }
78        },
79        saveCookiesEnabled: function () {
80            try {
81                localStorage.setItem('enable-cookies', 'true');
82            } catch (e) {
83                return;
84            }
85        },
86        saveCookiesDisabled: function () {
87            try {
88                localStorage.setItem('enable-cookies', 'false');
89            } catch (e) {
90                return;
91            }
92        },
93        userAcceptanceClick: function () {
94            cookie.saveMessageHidden();
95            cookie.hideMessage();
96            if (!cookie.areCookiesEnabled()) {
97                cookie.saveCookiesEnabled();
98                location.reload();
99            }
100        }
101    };
102    cookie.init();
103    window.resetCookieConfiguration = function () {
104        this.localStorage.clear();
105        location.reload();
106    };
107
108    $(document).ready(function () {
109
110        // if mobile
111
112        if ($(window).width() < 768) {
113            const clone = $('#primary-menu').clone();
114
115            clone.find('*').addBack().removeClass().removeAttr('style').removeAttr('x-show').removeAttr('x-data');
116
117            clone.attr('id', 'primary-menu-mobile');
118
119            $('#page').append(clone);
120
121            const menu = new Mmenu( '#primary-menu-mobile', {
122                offCanvas: {
123                    position: 'right'
124                }
125            }, {
126                offCanvas: {
127                    page: {
128                        selector: '#page'
129                    },
130                }
131            });
132            const api = menu.API;
133            let open = false;
134            $('.navbar-toggler').on('click', function () {
135                if (open) {
136                    api.close();
137                    open = false;
138                    $('#header').removeClass('mobile-menu-toggled');
139                    $('.navbar-toggler').removeClass('is-active');
140                } else {
141                    api.open();
142                    open = true;
143                    $('#header').addClass('mobile-menu-toggled');
144                    $('.navbar-toggler').addClass('is-active');
145                }
146                
147            });
148        }
149
150
151
152        const toggleMonths = (months) => {
153            // Show/hide elements based on toggled state
154            $('.bf-loop-item').css('display', 'none');
155            $('.bf-loop-item[data-months="' + months + '"]').css('display', 'flex');
156            
157            // Find the button and its index
158            const button = $('#months_toggler button[data-months="' + months + '"]');
159            const index = button.index();
160        
161            // Calculate the translation percentage based on index and total buttons
162            const totalButtons = $('#months_toggler button').length;
163            const left = (index * 100) / totalButtons + '%';
164            const text = button.text();
165        
166            $('#months_toggler span')
167                .css('left', left)
168                .text(text);
169        };
170        
171        $('#months_toggler button').on('click', function () {
172            const months = $(this).data('months');
173            toggleMonths(months);
174        });
175
176        if ( $('#months_toggler').length ) {
177            toggleMonths(24);
178        }
179
180        $('.bf-loop-item.business-package').css('display', 'flex');
181
182        $(window).on('resize', function () {
183            let addonTitleHeight = 0;
184            $('.addon-title').each(function () {
185                if ($(this).height() > addonTitleHeight) {
186                    addonTitleHeight = $(this).height();
187                }
188            }); 
189            $('.addon-title').height(addonTitleHeight);      
190        });
191
192        $(window).on('resize', resizeProductPanels);
193
194        $('.slick-slider').each(function () {
195            $(this).on('init reInit beforeChange', function (event, slick, currentSlide, nextSlide) {
196                let slidesToShow = slick.options.slidesToShow;
197                let slideCount = slick.slideCount;
198                let slideWidth = 100 / (slideCount - slidesToShow + 1); // Adjust for visible slides
199                let currentSlideIndex = (typeof nextSlide !== 'undefined') ? nextSlide : slick.currentSlide; // Use nextSlide if defined, else use currentSlide
200                let progressWidth = slideWidth * (currentSlideIndex + 1); // Calculate progress considering the current slide
201                let progressBar = $('.slick-progress-bar__inner');
202                
203                progressBar.css('width', `${progressWidth}%`);
204
205                $(window).trigger('resize');
206            });            
207            $(this).slick({
208                slidesToShow: 3,
209                slidesToScroll: 1,
210                arrows: true,
211                dots: false,
212                prevArrow: $('.slick-prev'),
213                nextArrow: $('.slick-next'),
214                responsive: [
215                    {
216                        breakpoint: 768,
217                        settings: {
218                            slidesToShow: 1,
219                            slidesToScroll: 1,
220                        }
221                    }
222                ]  
223            })
224
225        });
226
227    });
228
229    document.addEventListener("DOMContentLoaded", () => {
230        const groups = {};
231    
232        // Collect elements by group
233        document.querySelectorAll('[x-match-height]').forEach(element => {
234            const group = element.getAttribute('x-data-group');
235            if (!groups[group]) groups[group] = [];
236            groups[group].push(element);
237        });
238    
239        // Match heights within each group
240        for (const group in groups) {
241            let maxHeight = 0;
242    
243            // Determine the maximum height in the group
244            groups[group].forEach(element => {
245                element.style.height = 'auto'; // Reset height to calculate properly
246                const elementHeight = element.offsetHeight;
247                if (elementHeight > maxHeight) maxHeight = elementHeight;
248            });
249    
250            // Apply the maximum height to all elements in the group
251            groups[group].forEach(element => {
252                element.style.height = `${maxHeight}px`;
253            });
254        }
255    });
256    
257	function resizeProductPanels() {
258        let productSpeedHeight = 0;
259        $('.product-speed').each(function () {
260            if ($(this).height() > productSpeedHeight) {
261                productSpeedHeight = $(this).height();
262            }
263        });
264			
265		if (productSpeedHeight > 0) {
266			$('.product-speed').height(productSpeedHeight);
267		}
268    }
269
270})();

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.