PageSourceSearch

https://www.lakehalliegolf.com/plugins/system/cookiespolicynotific…cy-notification-bar.min.js?v=20260615203937

js lakehalliegolf.com collected 2026-10-04 15:26:27 UTC 129,322 bytes, 3,103 lines download raw bytes

1/* ======================================================
2 # Cookies Policy Notification Bar for Joomla! - v5.0.3 (pro version)
3 # -------------------------------------------------------
4 # For Joomla! CMS (v3.x)
5 # Author: Web357 (Yiannis Christodoulou)
6 # Copyright: (©) 2014-2026 Web357. All rights reserved.
7 # License: GNU/GPLv3, https://www.gnu.org/licenses/gpl-3.0.html
8 # Website: https://www.web357.com
9 # Demo: https://demo-joomla.web357.com/cookies-policy-notification-bar
10 # Support: [email protected]
11 # Last modified: Monday 15 June 2026, 08:39:37 PM
12 ========================================================= */
13
14var categoriesSettingsCookie = {}; // Create array with all categories ID for: modalManager
15var categoriesSettingsCookieOuter = {}; //Create array with first id (outter) and second id (inner)
16var categoriesSettingsCookieInner = {}; //Create array with first id (inner) and second id (outter)
17var m_modalManager_confirmationText = ''; //Modal LOCKED-CHECKBOX Confirmation Alert
18var modalManagerSettings = [];
19
20var afterCategoriesSettingsCookie;
21var afterExpirationCookies;
22var cpnb_renderSettingsOverride = null; // temporary in-memory settings used for rendering scripts
23var settings = typeof cpnb_config !== 'undefined' ? cpnb_config : {};
24
25window.addEventListener(
26    'load',
27    function () {
28        // Default Settings
29        var settings = {
30            w357_joomla_caching: 0,
31            w357_position: 'bottom',
32            w357_show_close_x_icon: 1,
33            w357_hide_after_time: 'yes',
34            w357_duration: 60,
35            w357_animate_duration: 1000,
36            w357_limit: 0,
37            w357_message: null,
38            w357_display_ok_btn: 1,
39            w357_buttonText: "Ok, I've understood!",
40            w357_display_decline_btn: 1,
41            w357_buttonDeclineText: 'Decline',
42            w357_display_cancel_btn: 1,
43            w357_buttonCancelText: 'Cancel',
44            w357_display_settings_btn: 1,
45            w357_buttonSettingsText: 'Settings',
46            w357_buttonMoreText: 'More Info',
47            w357_buttonMoreLink: '',
48            w357_display_more_info_btn: 1,
49            w357_fontColor: '#F1F1F3',
50            w357_linkColor: '#FFF',
51            w357_fontSize: '12px',
52            w357_backgroundColor: '#323A45',
53            w357_borderWidth: 1,
54            w357_body_cover: 1,
55            w357_overlay_state: 0,
56            w357_overlay_color: 'rgba(10,10,10, 0.3)',
57            w357_height: 'auto',
58            w357_cookie_name: 'cookiesDirective',
59            w357_cookie_name_declined: 'cpnbCookiesDeclined',
60            w357_cookie_name_cancelled: 'cpnbCookiesCancelled',
61            w357_link_target: '_self',
62            w357_popup_width: '800',
63            w357_popup_height: '600',
64            w357_customText:
65                'Your custom text for the cookies policy goes here...',
66            w357_more_info_btn_type: 'custom_text',
67            w357_blockCookies: 0,
68            w357_autoAcceptAfterScrolling: 0,
69            w357_numOfScrolledPixelsBeforeAutoAccept: 300,
70            w357_reloadPageAfterAccept: 0,
71            w357_enableConfirmationAlerts: 0,
72            w357_enableConfirmationAlertsForAcceptBtn: 0,
73            w357_enableConfirmationAlertsForDeclineBtn: 0,
74            w357_enableConfirmationAlertsForDeleteBtn: 0,
75            w357_confirm_allow_msg:
76                'Performing this action will enable all cookies set by this website. Are you sure that you want to enable all cookies on this website?',
77            w357_confirm_delete_msg:
78                'Performing this action will remove all cookies set by this website. Are you sure that you want to disable and delete all cookies from your browser?',
79            w357_show_in_iframes: 0,
80            w357_shortcode_is_enabled_on_this_page: 1,
81            w357_base_url: '',
82            w357_base_ajax_url: '',
83            w357_current_url: '',
84            w357_always_display: 0,
85            w357_show_notification_bar: true,
86            w357_expiration_cookies: 365, // days
87            w357_expiration_cookieSettings: 365, // days
88            w357_expiration_cookieAccept: 365, // days
89            w357_expiration_cookieDecline: 180, // days
90            w357_expiration_cookieCancel: 3, // days
91            w357_accept_button_class_notification_bar: 'cpnb-accept-btn',
92            w357_decline_button_class_notification_bar: 'cpnb-decline-btn',
93            w357_cancel_button_class_notification_bar: 'cpnb-cancel-btn',
94            w357_settings_button_class_notification_bar: 'cpnb-settings-btn',
95            w357_moreinfo_button_class_notification_bar: 'cpnb-moreinfo-btn',
96            w357_accept_button_class_notification_bar_modal_window:
97                'cpnb-accept-btn-m',
98            w357_decline_button_class_notification_bar_modal_window:
99                'cpnb-decline-btn-m',
100            w357_save_button_class_notification_bar_modal_window:
101                'cpnb-save-btn-m',
102            w357_buttons_ordering: '',
103        };
104
105        var modalManager = {
106            // base settings
107            w357_m_modalState: 1,
108            w357_m_floatButtonState: 1,
109            w357_m_floatButtonPosition: 'bottom_left',
110            w357_m_HashLink: 'cookies',
111
112            // styling
113            w357_m_modal_menuItemSelectedBgColor: 'rgba(200, 200, 200, 1)',
114            w357_m_saveChangesButtonColorAfterChange: 'rgba(255, 202, 152, 1)',
115            w357_m_floatButtonIconSrc:
116                'media/plg_system_cookiespolicynotificationbar/icons/cpnb-cookies-manager-icon-1-64x64.png',
117            w357_m_FloatButtonIconType: 'image',
118            w357_m_FloatButtonIconFontAwesomeName: 'fas fa-cookie-bite',
119            w357_m_FloatButtonIconFontAwesomeSize: 'fa-lg',
120            w357_m_FloatButtonIconFontAwesomeColor: 'rgba(61, 47, 44, 0.84)',
121            w357_m_FloatButtonIconUikitName: 'cog',
122            w357_m_FloatButtonIconUikitSize: '1',
123            w357_m_FloatButtonIconUikitColor: 'rgba(61, 47, 44, 0.84)',
124
125            // texts
126            w357_m_floatButtonText: 'Cookies Manager',
127            w357_m_modalHeadingText: 'Advanced Cookie Settings',
128            w357_m_checkboxText: 'Enable',
129            w357_m_lockedText: '(Locked)',
130            w357_m_EnableAllButtonText: 'Allow All Cookies',
131            w357_m_DeclineAllButtonText: 'Decline All Cookies',
132            w357_m_SaveChangesButtonText: 'Save Settings',
133            w357_m_confirmationAlertRequiredCookies:
134                "These cookies are strictly necessary for this website. You can't disable this category of cookies. Thank you for understanding!",
135        };
136
137        // var cpnb_config = {};
138
139        // Get data from server, check for each if empty or null then use default settings
140        // EXAMPLE: PHP ECHO SCRIPT -> var newSettings = { .. }
141        var varsToBeParsedInt = [
142            'w357_joomla_caching',
143            'w357_overlay_state',
144            'w357_borderWidth',
145            'w357_body_cover',
146            'w357_expiration_cookies',
147            'w357_expiration_cookieSettings',
148            'w357_expiration_cookieAccept',
149            'w357_expiration_cookieDecline',
150            'w357_expiration_cookieCancel',
151            'w357_duration',
152            'w357_animate_duration',
153            'w357_limit',
154            'w357_display_ok_btn',
155            'w357_display_decline_btn',
156            'w357_display_cancel_btn',
157            'w357_display_settings_btn',
158            'w357_display_more_info_btn',
159            'w357_blockCookies',
160            'w357_autoAcceptAfterScrolling',
161            'w357_numOfScrolledPixelsBeforeAutoAccept',
162            'w357_reloadPageAfterAccept',
163            'w357_enableConfirmationAlerts',
164            'w357_enableConfirmationAlertsForAcceptBtn',
165            'w357_enableConfirmationAlertsForDeclineBtn',
166            'w357_enableConfirmationAlertsForDeleteBtn',
167            'w357_show_in_iframes',
168            'w357_shortcode_is_enabled_on_this_page',
169            'w357_always_display',
170        ];
171        for (var obj in cpnb_config) {
172            if ((cpnb_config[obj] !== null) & (cpnb_config[obj] !== '')) {
173                if (varsToBeParsedInt.indexOf(obj) >= 0) {
174                    var rawValue = cpnb_config[obj];
175                    if (
176                        typeof rawValue === 'string' &&
177                        rawValue.trim().toUpperCase() === 'SESSION'
178                    ) {
179                        settings[obj] = 'SESSION';
180                    } else {
181                        settings[obj] = parseInt(rawValue); // Overwrite settings
182                    }
183                } else {
184                    settings[obj] = cpnb_config[obj]; //Overwrite settings
185                }
186            }
187        }
188
189        // Create-Read Cookie Limit => cpnb_cookie_limit + Check if higher + counter warning seen
190        if (settings.w357_limit > 0) {
191            if (cpnb_readCookie('cpnb_cookie_limit') == null) {
192                // Create cookie limit
193                cpnb_createCookie(
194                    'cpnb_cookie_limit',
195                    1,
196                    settings.w357_expiration_cookies
197                );
198            } else {
199                // Counter +1 and Check if higher
200                if (settings.w357_blockCookies == 0) {
201                    var counterCookie =
202                        parseInt(cpnb_readCookie('cpnb_cookie_limit')) + 1;
203                    cpnb_createCookie(
204                        'cpnb_cookie_limit',
205                        counterCookie,
206                        settings.w357_expiration_cookies
207                    );
208                }
209            }
210        }
211
212        // Used in "if statement" for design perpuse (margin-top), so as not to hide text
213        var warning_div_position = [
214            'top-left',
215            'top-right',
216            'bottom-left',
217            'bottom-right',
218            'center',
219        ];
220
221        // Check if Iframe
222        function cpnb_checkDIfIframeDisplay() {
223            if (settings.w357_show_in_iframes == 0) {
224                if (self == top) {
225                    return true; // Not In frame
226                } else {
227                    return false; // In frame
228                }
229            } else {
230                return true;
231            }
232        }
233
234        // Check Always Display
235        // cpnb_createCookie("cpnb_cookie_alwaysDisplay", settings.w357_always_display, settings.w357_expiration_cookies);
236        function cpnb_checkAlwaysDisplay() {
237            if (settings.w357_always_display == 1) {
238                return true;
239            } else if (
240                settings.w357_always_display !== 1 &&
241                !cpnb_hasConsentCookie(settings.w357_cookie_name) &&
242                !cpnb_hasConsentCookie(settings.w357_cookie_name_declined) &&
243                !cpnb_hasConsentCookie(settings.w357_cookie_name_cancelled)
244            ) {
245                return true;
246            } else {
247                return false;
248            }
249        }
250
251        // Check Limit (cookie: cpnb_cookie_limit)
252        function cpnb_checkCookieLimitDisplay() {
253            if (settings.w357_always_display !== 1) {
254                if (settings.w357_limit > 0) {
255                    if (cpnb_readCookie('cpnb_cookie_limit') !== null) {
256                        var counterCookie = parseInt(
257                            cpnb_readCookie('cpnb_cookie_limit')
258                        );
259                        if (counterCookie > settings.w357_limit) {
260                            return false;
261                        } else {
262                            return true;
263                        }
264                    }
265                } else {
266                    return true;
267                }
268            } else {
269                return true;
270            }
271        }
272
273        window.cpnb_handleKeyboardActivate=function (event) {
274            var key = event.key || event.keyCode;
275            if (key === 'Enter' || key === ' ' || key === 13 || key === 32) {
276                event.preventDefault();
277                event.target.click();
278            }
279        }
280
281        // Max-height create
282        var windowHeight =
283            window.innerHeight ||
284            document.documentElement.clientHeight ||
285            document.body.clientHeight;
286        var maxHeight = windowHeight - 0.2 * windowHeight;
287        maxHeight = parseInt(maxHeight.toFixed(0));
288        var marginTopWindow = windowHeight * 0.06;
289        marginTopWindow = parseInt(marginTopWindow.toFixed(0));
290
291        // Check if => iFrame && Always Display (w357_always_display) && Limit (cpnb_cookie_limit)
292        if (
293            cpnb_checkDIfIframeDisplay() &&
294            cpnb_checkAlwaysDisplay() &&
295            cpnb_checkCookieLimitDisplay() &&
296            settings.w357_show_notification_bar == true
297        ) {
298            // Create js to show warning
299            var elem = document.createElement('div');
300
301            // MaxHeight for WarningBox
302            var maxHeightWarningBox =
303                window.innerHeight ||
304                document.documentElement.clientHeight ||
305                document.body.clientHeight;
306            maxHeightWarningBox -= 40;
307
308            var cnbwb = '';
309            cnbwb +=
310                ' <div id="cpnb" class="cpnb" data-cookie-name="' +
311                decodeURI(settings.w357_cookie_name) +
312                '">';
313            cnbwb +=
314                '	<div role="contentinfo" aria-label="Cookie consent notification" class="cpnb-warningBox-show-fade-in cpnb-outer cpnb-div-position-' +
315                settings.w357_position +
316                '" id="w357_cpnb_outer" style=" display: flex; justify-content: center; flex-direction: column; position: fixed; height: ' +
317                settings.w357_height +
318                '; background: ' +
319                settings.w357_backgroundColor +
320                '; color: ' +
321                settings.w357_fontColor +
322                '; font-size: ' +
323                settings.w357_fontSize +
324                ';">';
325
326            // Close X icon
327            let cpnb_close_icon_html = '';
328            if (
329                settings.w357_show_close_x_icon == 1 &&
330                settings.w357_position != 'top' &&
331                settings.w357_position != 'bottom'
332            ) {
333                var cookieNameFun = settings.w357_cookie_name;
334                var linkFun = settings.w357_current_url;
335                var expiration = settings.w357_expiration_cookieCancel;
336                cpnb_close_icon_html =
337                    '				<span id="cpnb-close-x-btn" onClick="cpnb_warning_cancel_button(\'' +
338                    cookieNameFun +
339                    "', '" +
340                    expiration +
341                    "', '" +
342                    linkFun +
343                    "', '" +
344                    settings.w357_overlay_state +
345                    '\')" class="cpnb-x-close-icon"></span>';
346            }
347
348            if (
349                (settings.w357_message !== null) &
350                (settings.w357_message !== '')
351            ) {
352                cnbwb +=
353                    '		<div class="cpnb-inner" style="max-height: ' +
354                    maxHeightWarningBox +
355                    'px;">' +
356                    cpnb_close_icon_html +
357                    '<div class="cpnb-message">' +
358                    decodeURI(settings.w357_message) +
359                    '</div>';
360            } else {
361                cnbwb +=
362                    '		<div class="cpnb-inner" style="max-height: ' +
363                    maxHeightWarningBox +
364                    'px;">' +
365                    cpnb_close_icon_html +
366                    '<div class="cpnb-message">We use cookies to improve your experience on our website. By browsing this website, you agree to our use of cookies.</div>';
367            }
368
369            if (warning_div_position.indexOf(settings.w357_position) >= 0) {
370                cnbwb += '			<div class="cpnb-buttons" style="margin-top:10px;">';
371            } else {
372                cnbwb += '			<div class="cpnb-buttons">';
373            }
374
375            // BEGIN: Buttons Sorting
376            var buttons_ordering_array = JSON.parse(
377                settings.w357_buttons_ordering
378            );
379            for (var i = 0; i < buttons_ordering_array.length; i++) {
380                var btn = buttons_ordering_array[i];
381                switch (btn) {
382                    case 'ok':
383                        // ACCEPT BUTTON
384                        if (settings.w357_display_ok_btn == 1) {
385                            var enableConfirFun =
386                                settings.w357_enableConfirmationAlertsForAcceptBtn;
387                            var msgFun = settings.w357_confirm_allow_msg;
388                            var cookieNameFun = settings.w357_cookie_name;
389                            var linkFun = settings.w357_current_url;
390                            var expiration =
391                                settings.w357_expiration_cookieAccept;
392                            cnbwb +=
393                                '				<span id="cpnb-accept-btn" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' +
394                                decodeURI(settings.w357_buttonText) +
395                                '" onClick="cpnb_warning_accept_button(\'' +
396                                settings.w357_joomla_caching +
397                                "', '" +
398                                decodeURI(enableConfirFun) +
399                                "', '" +
400                                decodeURI(msgFun) +
401                                "', '" +
402                                cookieNameFun +
403                                "', '" +
404                                linkFun +
405                                "', '" +
406                                expiration +
407                                "', '" +
408                                settings.w357_base_ajax_url +
409                                "', 'notification_bar', '" +
410                                settings.w357_reloadPageAfterAccept +
411                                "', '" +
412                                settings.w357_overlay_state +
413                                '\')" class="cpnb-button cpnb-button-ok ' +
414                                decodeURI(
415                                    settings.w357_accept_button_class_notification_bar
416                                ) +
417                                '">' +
418                                decodeURI(settings.w357_buttonText) +
419                                '</span>';
420                        }
421                        break;
422
423                    case 'decline':
424                        // DECLINE BUTTON
425                        if (settings.w357_display_decline_btn == 1) {
426                            var enableConfirFun =
427                                settings.w357_enableConfirmationAlertsForDeclineBtn;
428                            var msgFun = settings.w357_confirm_delete_msg;
429                            var cookieNameFun = settings.w357_cookie_name;
430                            var linkFun = settings.w357_current_url;
431                            var expiration =
432                                settings.w357_expiration_cookieDecline;
433                            cnbwb +=
434                                '				<span id="cpnb-decline-btn" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' +
435                                decodeURI(settings.w357_buttonDeclineText) +
436                                '" onClick="cpnb_warning_decline_button(\'' +
437                                settings.w357_joomla_caching +
438                                "', '" +
439                                decodeURI(enableConfirFun) +
440                                "', '" +
441                                decodeURI(msgFun) +
442                                "', '" +
443                                cookieNameFun +
444                                "', '" +
445                                linkFun +
446                                "', '" +
447                                expiration +
448                                '\')" class="cpnb-button cpnb-button-decline ' +
449                                decodeURI(
450                                    settings.w357_decline_button_class_notification_bar
451                                ) +
452                                '">' +
453                                decodeURI(settings.w357_buttonDeclineText) +
454                                '</span>';
455                        }
456                        break;
457
458                    case 'cancel':
459                        // CANCEL BUTTON
460                        if (settings.w357_display_cancel_btn == 1) {
461                            var cookieNameFun = settings.w357_cookie_name;
462                            var linkFun = settings.w357_current_url;
463                            var expiration =
464                                settings.w357_expiration_cookieCancel;
465                            cnbwb +=
466                                '				<span id="cpnb-cancel-btn" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' +
467                                decodeURI(settings.w357_buttonCancelText) +
468                                '" onClick="cpnb_warning_cancel_button(\'' +
469                                cookieNameFun +
470                                "', '" +
471                                expiration +
472                                "', '" +
473                                linkFun +
474                                "', '" +
475                                settings.w357_overlay_state +
476                                '\')" class="cpnb-button cpnb-button-cancel ' +
477                                decodeURI(
478                                    settings.w357_cancel_button_class_notification_bar
479                                ) +
480                                '">' +
481                                decodeURI(settings.w357_buttonCancelText) +
482                                '</span>';
483                        }
484                        break;
485
486                    case 'moreinfo':
487                        // MORE INFO BUTTON
488                        if (settings.w357_display_more_info_btn == 1) {
489                            if (
490                                settings.w357_more_info_btn_type == 'link' ||
491                                settings.w357_more_info_btn_type == 'menu_item'
492                            ) {
493                                if (settings.w357_link_target == '_self') {
494                                    cnbwb +=
495                                        '				<a id="cpnb-moreinfo-btn" href="' +
496                                        settings.w357_buttonMoreLink +
497                                        '" target="_self" class="cpnb-button cpnb-button-more-default ' +
498                                        decodeURI(
499                                            settings.w357_moreinfo_button_class_notification_bar
500                                        ) +
501                                        '">' +
502                                        decodeURI(
503                                            settings.w357_buttonMoreText
504                                        ) +
505                                        '</a>';
506                                } else if (
507                                    settings.w357_link_target == '_blank'
508                                ) {
509                                    cnbwb +=
510                                        '				<a id="cpnb-moreinfo-btn" href="' +
511                                        settings.w357_buttonMoreLink +
512                                        '" target="_blank" class="cpnb-button cpnb-button-more-default ' +
513                                        decodeURI(
514                                            settings.w357_moreinfo_button_class_notification_bar
515                                        ) +
516                                        '">' +
517                                        decodeURI(
518                                            settings.w357_buttonMoreText
519                                        ) +
520                                        '</a>';
521                                } else if (
522                                    settings.w357_link_target == 'popup'
523                                ) {
524                                    cnbwb +=
525                                        '				<span id="cpnb-moreinfo-btn" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' +
526                                        decodeURI(
527                                            settings.w357_buttonMoreText
528                                        ) +
529                                        '" onClick="w357_openPopUpWindowMoreInfo(\'' +
530                                        settings.w357_buttonMoreLink +
531                                        "','titlos', '" +
532                                        settings.w357_popup_height +
533                                        "', '" +
534                                        settings.w357_popup_width +
535                                        '\')" class="cpnb-button cpnb-button-more-default ' +
536                                        decodeURI(
537                                            settings.w357_moreinfo_button_class_notification_bar
538                                        ) +
539                                        '">' +
540                                        decodeURI(
541                                            settings.w357_buttonMoreText
542                                        ) +
543                                        '</span>';
544                                }
545                            } else if (
546                                settings.w357_more_info_btn_type ==
547                                'custom_text'
548                            ) {
549                                cnbwb +=
550                                    '				<span id="cpnb-moreinfo-btn" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' +
551                                    decodeURI(settings.w357_buttonMoreText) +
552                                    '" onClick="cpnb_openModalMoreInfo()" class="cpnb-button cpnb-button-more-default ' +
553                                    decodeURI(
554                                        settings.w357_moreinfo_button_class_notification_bar
555                                    ) +
556                                    '" id="cpnb_button_more_modal">' +
557                                    decodeURI(settings.w357_buttonMoreText) +
558                                    '</span>';
559                            }
560                        }
561
562                        break;
563
564                    case 'settings':
565                        // SETTINGS BUTTON
566                        if (settings.w357_display_settings_btn == 1) {
567                            cnbwb +=
568                                '				<span id="cpnb-settings-btn" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' +
569                                decodeURI(settings.w357_buttonSettingsText) +
570                                '" onClick="cpnb_m_openModal()" class="cpnb-button cpnb-button-settings ' +
571                                decodeURI(
572                                    settings.w357_settings_button_class_notification_bar
573                                ) +
574                                '">' +
575                                decodeURI(settings.w357_buttonSettingsText) +
576                                '</span>';
577                        }
578
579                        break;
580
581                    default:
582                        // nothing to display
583                        break;
584                }
585            }
586            // END: Buttons Sorting
587
588            cnbwb += '				<div class="cpnb-clear-both"></div>';
589            cnbwb += '			</div>';
590            cnbwb += '		</div>';
591            cnbwb += '	</div>';
592            cnbwb += '</div>';
593
594            // Check if background overlay is enabled
595            if (settings.w357_overlay_state == 1) {
596                cnbwb +=
597                    '<div id="cpnb_warningBoxBgOverlay" style="background-color:' +
598                    settings.w357_overlay_color +
599                    ';">';
600            }
601
602            elem.innerHTML = cnbwb;
603            document.body.insertBefore(elem, document.body.firstChild);
604
605            //Center WarningBox Style
606            if (settings.w357_position == 'center') {
607                var windowWidth =
608                    window.innerWidth ||
609                    document.documentElement.clientWidth ||
610                    document.body.clientWidth;
611                var warningBoxHeight =
612                    document.getElementById('w357_cpnb_outer').clientHeight;
613                var pus = document.createElement('style');
614                pus.type = 'text/css';
615                pus.innerHTML =
616                    '.cpnb-div-position-center {top:0; left:0; margin-top: ' +
617                    (windowHeight - warningBoxHeight) / 2 +
618                    'px; margin-left: ' +
619                    (windowWidth - 500) / 2 +
620                    'px} ';
621                document.getElementsByTagName('head')[0].appendChild(pus);
622            }
623
624            // Auto-accept after scrolling
625            if (settings.w357_autoAcceptAfterScrolling) {
626                var scroll_counter = 0;
627                window.addEventListener('scroll', function () {
628                    if (scroll_counter == 0) {
629                        // if counter is 1, it will not execute
630                        if (
631                            window.pageYOffset >
632                            settings.w357_numOfScrolledPixelsBeforeAutoAccept
633                        ) {
634                            var enableConfirFun =
635                                settings.w357_enableConfirmationAlertsForAcceptBtn;
636                            var msgFun = settings.w357_confirm_allow_msg;
637                            var cookieNameFun = settings.w357_cookie_name;
638                            var linkFun = settings.w357_current_url;
639                            var expiration =
640                                settings.w357_expiration_cookieAccept;
641
642                            cpnb_warning_accept_button(
643                                settings.w357_joomla_caching,
644                                decodeURI(enableConfirFun),
645                                decodeURI(msgFun),
646                                cookieNameFun,
647                                linkFun,
648                                expiration,
649                                settings.w357_base_ajax_url,
650                                'notification_bar',
651                                settings.w357_reloadPageAfterAccept,
652                                settings.w357_overlay_state
653                            );
654
655                            scroll_counter++; // increment the counter by 1, new value = 1
656                        }
657                    }
658                });
659            }
660
661            // Timeout Duration function, Hide warning box box-shadow => w357_duration
662            function cpnb_hideInfoBox(ms, gapMs) {
663                setTimeout(function () {
664                    var e = document.getElementById('w357_cpnb_outer');
665                    if (e) {
666                        e.classList.remove('cpnb-warningBox-show-fade-in');
667                        e.classList.add('cpnb-warningBox-show-fade-out');
668                    }
669
670                    if (settings.w357_overlay_state == 1) {
671                        var overlay = document.getElementById(
672                            'cpnb_warningBoxBgOverlay'
673                        );
674                        if (overlay) {
675                            overlay.classList.add(
676                                'cpnb-warningBox-show-fade-out'
677                            );
678                        }
679                    }
680                }, ms);
681                // Hide warning
682                setTimeout(function () {
683                    var bar = document.getElementById('w357_cpnb_outer');
684                    if (bar) {
685                        bar.style.display = 'none';
686                    }
687                    if (settings.w357_overlay_state == 1) {
688                        var overlay = document.getElementById(
689                            'cpnb_warningBoxBgOverlay'
690                        );
691                        if (overlay) {
692                            overlay.style.display = 'none';
693                        }
694                    }
695                }, ms + gapMs);
696            }
697
698            // Hide the notification bar after X seconds
699            if (settings.w357_hide_after_time != 'display_always') {
700                cpnb_hideInfoBox(
701                    settings.w357_duration * 1000,
702                    settings.w357_animate_duration
703                );
704            }
705
706            // Create style WarningBox duration open & close
707            var stDur = settings.w357_animate_duration / 1000;
708
709            // If border on warning box, problem with animation height.
710            var offsetHeightBorderx1 = ['top', 'bottom'];
711            if (offsetHeightBorderx1.indexOf(settings.w357_position) >= 0) {
712                var subOffsetHeight = settings.w357_borderWidth;
713            } else {
714                var subOffsetHeight = settings.w357_borderWidth * 2;
715            }
716
717            var offsetHeight =
718                document.getElementById('w357_cpnb_outer').offsetHeight -
719                subOffsetHeight;
720            var w357_cpnb_outer_height =
721                document.getElementById('w357_cpnb_outer').offsetHeight;
722
723            var pus = document.createElement('style');
724            pus.type = 'text/css';
725            pus.innerHTML =
726                '.cpnb-warningBox-show-fade-in {overflow:hidden; animation-name: slidein; animation-duration: ' +
727                stDur +
728                's;} ';
729            pus.innerHTML +=
730                '.cpnb-warningBox-show-fade-out { opacity:0; overflow:hidden; padding:0; animation-name: slideout; animation-duration: ' +
731                stDur +
732                's;} ';
733            pus.innerHTML +=
734                '@keyframes slidein { from { height:0px; opacity:0; } to { height:' +
735                offsetHeight +
736                'px; opacity:1;} }';
737            pus.innerHTML +=
738                '@keyframes slideout { from {  opacity:1; } to { opacity:0; } }';
739            document.getElementsByTagName('head')[0].appendChild(pus);
740
741            // Create Modal
742            if (settings.w357_more_info_btn_type == 'custom_text') {
743                // Create style with modal duration open & close
744                var stDur = settings.w357_animate_duration / 5000;
745                var pus = document.createElement('style');
746                pus.type = 'text/css';
747                pus.innerHTML =
748                    '.cpnb-modal-show-fade-in { visibility: visible; opacity: 1; -webkit-transition: opacity ' +
749                    stDur +
750                    's, visibility ' +
751                    stDur +
752                    's; transition: opacity ' +
753                    stDur +
754                    's, visibility ' +
755                    stDur +
756                    's; } ';
757                pus.innerHTML +=
758                    '.cpnb-modal-show-fade-out { visibility: hidden; opacity: 0; -webkit-transition: opacity ' +
759                    stDur +
760                    's, visibility ' +
761                    stDur +
762                    's; transition: opacity ' +
763                    stDur +
764                    's, visibility ' +
765                    stDur +
766                    's; } ';
767                document.getElementsByTagName('head')[0].appendChild(pus);
768
769                var elem = document.createElement('div');
770                var cnbwb =
771                    '<div id="cpnb_modal_wrap" class="cpnb-modal-wrap cpnb-modal-show-fade-out">';
772                cnbwb +=
773                    '		<div class="cpnb-modal-outer cpnb-modal-bg cpnb-close" id="cpnb_outter-moreinfo" style="top: 0px; left: 0px; align-items: flex-start;">';
774                cnbwb +=
775                    '				<div class="cpnb-modal-inner cpnb-modal--medium" id="cpnb_inner-moreinfo" style="z-index: 100000000; max-height:' +
776                    maxHeight +
777                    'px; margin-top:' +
778                    marginTopWindow +
779                    'px;">';
780                cnbwb +=
781                    '';
782                cnbwb +=
783                    '						<div class="cpnb-modal-inner-text">' +
784                    settings.w357_customText +
785                    '</div>';
786                cnbwb +=
787                    '						<span role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="Close" onClick="cpnb_closeModalMoreInfo()" id="cpnb-modal-close-moreinfo" class="cpnb-modal-close cpnb-close cpnb-close-icon-x"></span>';
788                cnbwb +=
789                    '						<div id="close_cpnb_modal_footer" class="cpnb-modal-footer">';
790                cnbwb +=
791                    '								<div id="close_cpnb_modal_actions" class="cpnb-modal-actions">';
792
793                // BEGIN: Buttons Sorting
794                var buttons_ordering_array = JSON.parse(
795                    settings.w357_buttons_ordering
796                );
797                for (var i = 0; i < buttons_ordering_array.length; i++) {
798                    var btn = buttons_ordering_array[i];
799                    switch (btn) {
800                        case 'ok':
801                            // ACCEPT BUTTON
802                            if (settings.w357_display_ok_btn == 1) {
803                                var msgFun = settings.w357_confirm_allow_msg;
804                                var expiration =
805                                    settings.w357_expiration_cookieAccept;
806                                var linkFun = settings.w357_current_url;
807                                cnbwb +=
808                                    '				<span id="cpnb-accept-btn-m-info" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' +
809                                    decodeURI(settings.w357_buttonText) +
810                                    '" onClick="cpnb_warning_accept_button(\'' +
811                                    settings.w357_joomla_caching +
812                                    "', '" +
813                                    decodeURI(enableConfirFun) +
814                                    "', '" +
815                                    decodeURI(msgFun) +
816                                    "', '" +
817                                    cookieNameFun +
818                                    "', '" +
819                                    linkFun +
820                                    "', '" +
821                                    expiration +
822                                    "', '" +
823                                    settings.w357_base_ajax_url +
824                                    "', 'modal', '" +
825                                    settings.w357_reloadPageAfterAccept +
826                                    "', '" +
827                                    settings.w357_overlay_state +
828                                    '\')" class="cpnb-button cpnb-button-ok ' +
829                                    decodeURI(
830                                        settings.w357_accept_button_class_notification_bar
831                                    ) +
832                                    '">' +
833                                    decodeURI(settings.w357_buttonText) +
834                                    '</span>';
835                            }
836                            break;
837
838                        case 'decline':
839                            // DECLINE BUTTON
840                            if (settings.w357_display_decline_btn == 1) {
841                                var msgFun = settings.w357_confirm_delete_msg;
842                                var expiration =
843                                    settings.w357_expiration_cookieDecline;
844                                var linkFun = settings.w357_current_url;
845                                cnbwb +=
846                                    '				<span id="cpnb-decline-btn-m-info" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' +
847                                    decodeURI(settings.w357_buttonDeclineText) +
848                                    '" onClick="cpnb_warning_decline_button(\'' +
849                                    settings.w357_joomla_caching +
850                                    "', '" +
851                                    decodeURI(enableConfirFun) +
852                                    "', '" +
853                                    decodeURI(msgFun) +
854                                    "', '" +
855                                    cookieNameFun +
856                                    "', '" +
857                                    linkFun +
858                                    "', '" +
859                                    expiration +
860                                    "', true)\" class=\"cpnb-button cpnb-button-decline " +
861                                    decodeURI(
862                                        settings.w357_decline_button_class_notification_bar
863                                    ) +
864                                    '">' +
865                                    decodeURI(settings.w357_buttonDeclineText) +
866                                    '</span>';
867                            }
868                            break;
869
870                        case 'cancel':
871                            // CANCEL BUTTON
872                            if (settings.w357_display_cancel_btn == 1) {
873                                var expiration =
874                                    settings.w357_expiration_cookieCancel;
875                                var linkFun = settings.w357_current_url;
876                                cnbwb +=
877                                    '				<span id="cpnb-cancel-btn-m-info" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' +
878                                    decodeURI(settings.w357_buttonCancelText) +
879                                    '" onClick="cpnb_warning_cancel_button(\'' +
880                                    cookieNameFun +
881                                    "', '" +
882                                    expiration +
883                                    "', '" +
884                                    linkFun +
885                                    "', '" +
886                                    settings.w357_overlay_state +
887                                    "', true)\" class=\"cpnb-button cpnb-button-cancel " +
888                                    decodeURI(
889                                        settings.w357_cancel_button_class_notification_bar
890                                    ) +
891                                    '">' +
892                                    decodeURI(settings.w357_buttonCancelText) +
893                                    '</span>';
894                            }
895                            break;
896
897                        case 'settings':
898                            // SETTINGS BUTTON
899                            if (settings.w357_display_settings_btn == 1) {
900                                cnbwb +=
901                                    '				<span id="cpnb-settings-btn-m-info" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' +
902                                    decodeURI(
903                                        settings.w357_buttonSettingsText
904                                    ) +
905                                    '" onClick="cpnb_m_openModal(); cpnb_closeModalMoreInfo();" class="cpnb-button cpnb-button-settings ' +
906                                    decodeURI(
907                                        settings.w357_settings_button_class_notification_bar
908                                    ) +
909                                    '">' +
910                                    decodeURI(
911                                        settings.w357_buttonSettingsText
912                                    ) +
913                                    '</span>';
914                            }
915
916                            break;
917
918                        default:
919                            // nothing to display
920                            break;
921                    }
922                }
923                // END: Buttons Sorting
924
925                cnbwb += '								</div>';
926                cnbwb += '						</div>';
927                cnbwb += '				</div>';
928                cnbwb +=
929                    '				<div class="cpnb-modal-show-fade-out" id="modal_close_bg" role="button" tabindex="0" aria-label="Close modal" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" onClick="cpnb_closeModalMoreInfo()" style=" z-index: 99999999; top:0; left:0; position:fixed; width:100%; height:100%;"></div>';
930                cnbwb += '		</div>';
931                cnbwb += '</div>';
932                elem.innerHTML = cnbwb;
933                document.body.insertBefore(elem, document.body.firstChild);
934            }
935        } // END: Check if => iFrame && Always Display (w357_always_display) && Limit (cpnb_cookie_limit)
936
937        // Do not cover the body of the page.
938        if (settings.w357_body_cover === 0) {
939            if (w357_cpnb_outer_height != null && w357_cpnb_outer_height > 0) {
940                if (settings.w357_position == 'top') {
941                    document.getElementsByTagName('body')[0].style.paddingTop =
942                        w357_cpnb_outer_height + 'px';
943                } else {
944                    document.getElementsByTagName(
945                        'body'
946                    )[0].style.paddingBottom = w357_cpnb_outer_height + 'px';
947                }
948            }
949        }
950
951        ////***************** START MANAGER *****************///
951/
952        // Get data from server, check for each if empty or null then use default settings
953        // EXAMPLE: PHP ECHO SCRIPT -> var newSettings = { .. }
954
955        //Overide ModalManager settings
956        var varsToBeParsedInt = [
957            'w357_m_modalState',
958            'w357_m_floatButtonState',
959        ];
960        //var cpnb_manager = [];
961        for (var obj in cpnb_manager) {
962            if ((cpnb_manager[obj] !== null) & (cpnb_manager[obj] !== '')) {
963                if (varsToBeParsedInt.indexOf(obj) >= 0) {
964                    modalManager[obj] = parseInt(cpnb_manager[obj]); // Overwrite settings
965                } else {
966                    modalManager[obj] = cpnb_manager[obj]; //Overwrite settings
967                }
968            }
969        }
970
971        modalManagerSettings = modalManager;
972
973        //Get array with information about cookies categories (Read Cookie)
974        var settingsPayload = cpnb_getConsentCookiePayload(
975            'cpnb_cookiesSettings'
976        );
977        if (settingsPayload && settingsPayload.v) {
978            categoriesSettingsCookie = settingsPayload.v;
979        } else {
980            categoriesSettingsCookie = {};
981            //categoriesSettingsCookie = {"required-cookies":1,"analytical-cookies":0,"social-media-cookies":0,"targeted-advertising-cookies":0};
982        }
983
984        //cpnb_createCookie("cpnb_cookiesSettings", JSON.stringify(categoriesSettingsCookie), settings.w357_expiration_cookies);
985        afterCategoriesSettingsCookie = categoriesSettingsCookie;
986        afterExpirationCookies = settings.w357_expiration_cookieSettings;
987        cpnb_syncConsentCookieExpiration(
988            settings.w357_cookie_name,
989            settings.w357_expiration_cookieAccept
990        );
991        cpnb_syncConsentCookieExpiration(
992            settings.w357_cookie_name_declined,
993            settings.w357_expiration_cookieDecline
994        );
995        cpnb_syncConsentCookieExpiration(
996            settings.w357_cookie_name_cancelled,
997            settings.w357_expiration_cookieCancel
998        );
999        cpnb_syncConsentCookieExpiration(
1000            'cpnb_cookiesSettings',
1001            settings.w357_expiration_cookieSettings
1002        );
1003        cpnb_syncConsentCookieExpiration(
1004            'cpnb_cookiesSettingsTemp',
1005            settings.w357_expiration_cookieSettings
1006        );
1007
1008        // Sync any blocked scripts that should run before/after consent on page load (init)
1009        cpnb_handleBlockCookieScripts();
1010
1011        // After the first post-accept reload, poll until document.cookie stops changing
1012        // (meaning GA4/GTM scripts have finished writing their cookies), then reload so
1013        // the {cookiesinfo} shortcode table includes _ga_XXXX and similar async cookies.
1014        try {
1015            if (localStorage.getItem('cpnb_shortcode_cookie_reload') === '1' && settings.w357_shortcode_is_enabled_on_this_page == 1) {
1016                localStorage.removeItem('cpnb_shortcode_cookie_reload');
1017                var _cpnbPollStart = Date.now();
1018                var _cpnbPollBaseline = document.cookie;
1019                var _cpnbPollSnapshot = _cpnbPollBaseline;
1020                var _cpnbPollTimer = setInterval(function () {
1021                    var _cpnbNow = Date.now();
1022                    var _cpnbCurrent = document.cookie;
1023                    var _cpnbStable = (_cpnbCurrent === _cpnbPollSnapshot && (_cpnbNow - _cpnbPollStart) >= 1000);
1024                    var _cpnbTimeout = (_cpnbNow - _cpnbPollStart) >= 8000;
1025                    if (_cpnbStable || _cpnbTimeout) {
1026                        clearInterval(_cpnbPollTimer);
1027                        // Only re-fetch the table if GA4/GTM wrote new cookies since the page loaded.
1028                        // If nothing changed, the DOMContentLoaded fetch already showed the correct state.
1029                        if (_cpnbCurrent !== _cpnbPollBaseline) {
1030                            var _cpnbCitEl = document.getElementById('cpnb-cit-container');
1031                            if (_cpnbCitEl && _cpnbCitEl.getAttribute('data-cpnb-table-ajax')) {
1032                                cpnb_fetchCookiesInfoTable();
1033                            } else {
1034                                window.location.reload();
1035                            }
1036                        }
1037                    }
1038                    _cpnbPollSnapshot = _cpnbCurrent;
1039                }, 1500);
1040            }
1041        } catch (e) {
1042        }
1043
1044        //Check if ModalManager is enabled
1045        if (
1046            cpnb_checkDIfIframeDisplay() &&
1047            settings.w357_blockCookies == 1 &&
1048            modalManager.w357_m_modalState == 1
1049        ) {
1050            //Pass Modal LOCKED-CHECKBOX Confirmation Alert
1051            m_modalManager_confirmationText =
1052                modalManager.w357_m_confirmationAlertRequiredCookies;
1053
1054            //Create Left Menu Item Selected Class
1055            var pus = document.createElement('style');
1056            pus.type = 'text/css';
1057            pus.innerHTML =
1058                '.cpnb-manager-modal-left-item-selected, .cpnb-manager-modal-left-item-unSelected:hover, .cpnb-manager-modal-left-item-unSelected:focus {background: ' +
1059                modalManager.w357_m_modal_menuItemSelectedBgColor +
1060                ';} ';
1061            document.getElementsByTagName('head')[0].appendChild(pus);
1062
1063            var HTMLleftMenu = '';
1064            var HTMLinformationBoxes = '';
1065            var categoriesCounter = 0; //Pick first category and first box with information to show.
1066
1067            // Open-Close Left Menu Button
1068            HTMLinformationBoxes +=
1069                '<div class="cpnb-left-menu-toggle" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" onClick="cpnb_toggle_responsive_menu(this)">';
1070            HTMLinformationBoxes +=
1071                '<div class="cpnb-toggle-menu-container cpnb-left-menu-toggle-button">';
1072            HTMLinformationBoxes += '<div class="cpnb-toggle-menu-bar1"></div>';
1073            HTMLinformationBoxes += '<div class="cpnb-toggle-menu-bar2"></div>';
1074            HTMLinformationBoxes += '<div class="cpnb-toggle-menu-bar3"></div>';
1075            HTMLinformationBoxes += '</div>';
1076            HTMLinformationBoxes += '</div>';
1077
1078            // Modal Manager HEADER
1079            HTMLinformationBoxes +=
1080                '<div class="h2 cpnb-m-header">' +
1081                modalManager.w357_m_modalHeadingText +
1082                '</div>';
1083
1084            for (var categoryID in cpnb_cookiesCategories) {
1085                if (
1086                    cpnb_cookiesCategories[categoryID].cookie_category_status ==
1087                    1
1088                ) {
1089                    var innerCookieCategory =
1090                        cpnb_cookiesCategories[categoryID].cookie_category_id;
1091
1092                    categoriesCounter++;
1093
1094                    // Check if First Category
1095                    if (categoriesCounter == 1) {
1096                        // Create menu item
1097                        HTMLleftMenu +=
1098                            '<div role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' +
1099                            cpnb_cookiesCategories[categoryID]
1100                                .cookie_category_name +
1101                            '" onClick="cpnb_m_changeModalCategory(\'' +
1102                            categoryID +
1103                            '\')" id="mlm_menu_category_id_' +
1104                            categoryID +
1105                            '" class="cpnb-manager-modal-left-item-selected cpnb-manager-modal-left-item modal-left-menu-item-id-' +
1106                            categoryID +
1107                            '">' +
1108                            cpnb_cookiesCategories[categoryID]
1109                                .cookie_category_name +
1110                            '</div>';
1111                        //Create new information box (right)
1112                        HTMLinformationBoxes +=
1113                            '<div id="mmr_box_category_id_' +
1114                            categoryID +
1115                            '" class="cpnb-manager-modal-right-selected cpnb-manager-modal-right cpnb-manager-modal-right-scrollbar">';
1116                    } else {
1117                        // Create menu item
1118                        HTMLleftMenu +=
1119                            '<div role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' +
1120                            cpnb_cookiesCategories[categoryID]
1121                                .cookie_category_name +
1122                            '" onClick="cpnb_m_changeModalCategory(\'' +
1123                            categoryID +
1124                            '\')" id="mlm_menu_category_id_' +
1125                            categoryID +
1126                            '" class="cpnb-manager-modal-left-item-unSelected cpnb-manager-modal-left-item modal-left-menu-item-id-' +
1127                            categoryID +
1128                            '">' +
1129                            cpnb_cookiesCategories[categoryID]
1130                                .cookie_category_name +
1131                            '</div>';
1132                        // Create new information box (right)
1133                        HTMLinformationBoxes +=
1134                            '<div id="mmr_box_category_id_' +
1135                            categoryID +
1136                            '" class="cpnb-manager-modal-right-unSelected cpnb-manager-modal-right cpnb-manager-modal-right-scrollbar">';
1137                    }
1138
1139                    HTMLinformationBoxes +=
1140                        '<p><strong id="cpnb_category_heading_' +
1141                        categoryID +
1142                        '" class="cpnb-cookies-category-heading-responsive">' +
1143                        cpnb_cookiesCategories[categoryID]
1144                            .cookie_category_name +
1145                        '</strong></p>';
1146                    HTMLinformationBoxes +=
1147                        cpnb_cookiesCategories[categoryID]
1148                            .cookie_category_description;
1149                    HTMLinformationBoxes +=
1150                        '<div class="cpnb-category-group" role="group" aria-labelledby="cpnb_category_heading_' +
1151                        categoryID +
1152                        '">';
1153
1154                    //Initialize vars for saveCategoryState
1155                    var init_genericExp = settings.w357_expiration_cookies;
1156                    var init_baseUrl = settings.w357_current_url;
1157                    var init_cookieName = settings.w357_cookie_name;
1158                    var init_acceptExp = settings.w357_expiration_cookieAccept;
1159                    var init_declineExp =
1160                        settings.w357_expiration_cookieDecline;
1161
1162                    //(ENABLE-DISABLE BUTTON) - Check if cookie for category state exists. If exists check what state has been saved.
1163                    if (categoriesSettingsCookie[innerCookieCategory] == null) {
1164                        if (
1165                            cpnb_cookiesCategories[categoryID]
1166                                .cookie_category_checked_by_default == 1
1167                        ) {
1168                            HTMLinformationBoxes +=
1169                                '<div class="modalCheckBox"><input data-cpnb-save="1" data-cpnb-category-id="' +
1170                                categoryID +
1171                                '" data-cpnb-exp="' +
1172                                init_genericExp +
1173                                '" data-cpnb-base-url="' +
1174                                init_baseUrl +
1175                                '" data-cpnb-cookie-name="' +
1176                                init_cookieName +
1177                                '" data-cpnb-accept-exp="' +
1178                                init_acceptExp +
1179                                '" data-cpnb-decline-exp="' +
1180                                init_declineExp +
1181                                '" class="cpnb-checkbox" type="checkbox" value="1" id="modalCheckBox_id_' +
1182                                categoryID +
1183                                '" name="modalCheckBox_id_' +
1184                                categoryID +
1185                                '" checked/><label for="modalCheckBox_id_' +
1186                                categoryID +
1187                                '">' +
1188                                modalManager.w357_m_checkboxText +
1189                                '</label></div>';
1190                            categoriesSettingsCookie[innerCookieCategory] = 1;
1191                        } else if (
1192                            cpnb_cookiesCategories[categoryID]
1193                                .cookie_category_checked_by_default == 2
1194                        ) {
1195                            //DISABLED CHECKBOX - cpnb_m_lockedCheckbox
1196                            HTMLinformationBoxes +=
1197                                '<div class="modalCheckBox"><input data-cpnb-locked="1" data-cpnb-category-id="' +
1198                                categoryID +
1199                                '" data-cpnb-exp="' +
1200                                settings.w357_expiration_cookies +
1201                                '" data-cpnb-confirmation="' +
1202                                settings.w357_enableConfirmationAlerts +
1203                                '" class="cpnb-checkbox" type="checkbox" value="1" id="modalCheckBox_id_' +
1204                                categoryID +
1205                                '" name="modalCheckBox_id_' +
1206                                categoryID +
1207                                '" checked/><label for="modalCheckBox_id_' +
1208                                categoryID +
1209                                '">' +
1210                                modalManager.w357_m_checkboxText +
1211                                '</label></div>';
1212                            categoriesSettingsCookie[innerCookieCategory] = 1;
1213                        } else {
1214                            HTMLinformationBoxes +=
1215                                '<div class="modalCheckBox"><input data-cpnb-save="1" data-cpnb-category-id="' +
1216                                categoryID +
1217                                '" data-cpnb-exp="' +
1218                                init_genericExp +
1219                                '" data-cpnb-base-url="' +
1220                                init_baseUrl +
1221                                '" data-cpnb-cookie-name="' +
1222                                init_cookieName +
1223                                '" data-cpnb-accept-exp="' +
1224                                init_acceptExp +
1225                                '" data-cpnb-decline-exp="' +
1226                                init_declineExp +
1227                                '" class="cpnb-checkbox" type="checkbox" value="1" id="modalCheckBox_id_' +
1228                                categoryID +
1229                                '" name="modalCheckBox_id_' +
1230                                categoryID +
1231                                '" /><label for="modalCheckBox_id_' +
1232                                categoryID +
1233                                '">' +
1234                                modalManager.w357_m_checkboxText +
1235                                '</label></div>';
1236                            categoriesSettingsCookie[innerCookieCategory] = 0;
1237                        }
1238                    } else {
1239                        //Check if LOCKED
1240                        if (
1241                            cpnb_cookiesCategories[categoryID]
1242                                .cookie_category_checked_by_default != 2
1243                        ) {
1244                            if (
1245                                categoriesSettingsCookie[
1246                                '' + innerCookieCategory + ''
1247                                    ] == 1
1248                            ) {
1249                                HTMLinformationBoxes +=
1250                                    '<div class="modalCheckBox"><input class="cpnb-checkbox" data-cpnb-save="1" data-cpnb-category-id="' +
1251                                    categoryID +
1252                                    '" data-cpnb-exp="' +
1253                                    init_genericExp +
1254                                    '" data-cpnb-base-url="' +
1255                                    init_baseUrl +
1256                                    '" data-cpnb-cookie-name="' +
1257                                    init_cookieName +
1258                                    '" data-cpnb-accept-exp="' +
1259                                    init_acceptExp +
1260                                    '" data-cpnb-decline-exp="' +
1261                                    init_declineExp +
1262                                    '" type="checkbox" value="1" id="modalCheckBox_id_' +
1263                                    categoryID +
1264                                    '" name="modalCheckBox_id_' +
1265                                    categoryID +
1266                                    '" checked/><label for="modalCheckBox_id_' +
1267                                    categoryID +
1268                                    '">' +
1269                                    modalManager.w357_m_checkboxText +
1270                                    '</label></div>';
1271                                categoriesSettingsCookie[
1272                                    innerCookieCategory
1273                                    ] = 1;
1274                            } else {
1275                                HTMLinformationBoxes +=
1276                                    '<div class="modalCheckBox"><input data-cpnb-save="1" data-cpnb-category-id="' +
1277                                    categoryID +
1278                                    '" data-cpnb-exp="' +
1279                                    init_genericExp +
1280                                    '" data-cpnb-base-url="' +
1281                                    init_baseUrl +
1282                                    '" data-cpnb-cookie-name="' +
1283                                    init_cookieName +
1284                                    '" data-cpnb-accept-exp="' +
1285                                    init_acceptExp +
1286                                    '" data-cpnb-decline-exp="' +
1287                                    init_declineExp +
1288                                    '" class="cpnb-checkbox" type="checkbox" value="1" id="modalCheckBox_id_' +
1289                                    categoryID +
1290                                    '" name="modalCheckBox_id_' +
1291                                    categoryID +
1292                                    '" /><label for="modalCheckBox_id_' +
1293                                    categoryID +
1294                                    '">' +
1295                                    modalManager.w357_m_checkboxText +
1296                                    '</label></div>';
1297                                categoriesSettingsCookie[
1298                                    innerCookieCategory
1299                                    ] = 0;
1300                            }
1301                        } else {
1302                            //DISABLED CHECKBOX - cpnb_m_lockedCheckbox
1303                            HTMLinformationBoxes +=
1304                                '<div class="modalCheckBox"><input data-cpnb-locked="1" data-cpnb-category-id="' +
1305                                categoryID +
1306                                '" data-cpnb-exp="' +
1307                                settings.w357_expiration_cookies +
1308                                '" data-cpnb-confirmation="' +
1309                                settings.w357_enableConfirmationAlerts +
1310                                '" class="cpnb-checkbox" type="checkbox" value="1" id="modalCheckBox_id_' +
1311                                categoryID +
1312                                '" name="modalCheckBox_id_' +
1313                                categoryID +
1314                                '" checked/><label for="modalCheckBox_id_' +
1315                                categoryID +
1316                                '">' +
1317                                modalManager.w357_m_checkboxText +
1318                                ' ' +
1319                                modalManager.w357_m_lockedText +
1320                                '</label></div>';
1321                            categoriesSettingsCookie[innerCookieCategory] = 1;
1322                        }
1323                    }
1324
1325                    HTMLinformationBoxes += '</div>';
1326                    HTMLinformationBoxes +=
1327                        '<div style="display:block; width:100%; height:30px;"></div>';
1328                    HTMLinformationBoxes += '</div>';
1329
1330                    //Create IO ARRAY with IDs
1331                    categoriesSettingsCookieInner[innerCookieCategory] =
1332                        categoryID;
1333                    categoriesSettingsCookieOuter[categoryID] =
1334                        innerCookieCategory;
1335                }
1336            }
1337
1338            HTMLinformationBoxes += '<div class="cpnb-m-bottom-buttons">';
1339            var enableConfirFun =
1340                settings.w357_enableConfirmationAlertsForAcceptBtn;
1341            var cookieNameFun = settings.w357_cookie_name;
1342            var msgFun = settings.w357_confirm_allow_msg;
1343            var expiration = settings.w357_expiration_cookieAccept;
1344            var linkFun = settings.w357_current_url;
1345            var encodedAcceptMsg = encodeURIComponent(decodeURI(msgFun));
1346            var encodedAcceptCookieName = encodeURIComponent(cookieNameFun);
1347            var encodedAcceptLink = encodeURIComponent(linkFun);
1348            var encodedAcceptBaseAjaxUrl = encodeURIComponent(
1349                settings.w357_base_ajax_url
1350            );
1351            HTMLinformationBoxes +=
1352                '<button id="cpnb-accept-btn-m" class="cpnb-button cpnb-m-enableAllButton ' +
1353                decodeURI(
1354                    settings.w357_accept_button_class_notification_bar_modal_window
1355                ) +
1356                '" type="button" data-cpnb-action="accept" data-cpnb-joomla-caching="' +
1357                settings.w357_joomla_caching +
1358                '" data-cpnb-enable-confirmation="' +
1359                decodeURI(enableConfirFun) +
1360                '" data-cpnb-message="' +
1361                encodedAcceptMsg +
1362                '" data-cpnb-cookie-name="' +
1363                encodedAcceptCookieName +
1364                '" data-cpnb-link="' +
1365                encodedAcceptLink +
1366                '" data-cpnb-expiration="' +
1367                expiration +
1368                '" data-cpnb-base-ajax-url="' +
1369                encodedAcceptBaseAjaxUrl +
1370                '" data-cpnb-context="modal" data-cpnb-reload="' +
1371                settings.w357_reloadPageAfterAccept +
1372                '" data-cpnb-overlay="' +
1373                settings.w357_overlay_state +
1374                '">' +
1375                modalManager.w357_m_EnableAllButtonText +
1376                '</button>';
1377
1378            var enableConfirFun =
1379                settings.w357_enableConfirmationAlertsForDeclineBtn;
1380            var msgFun = settings.w357_confirm_delete_msg;
1381            var expiration = settings.w357_expiration_cookieDecline;
1382            var linkFun = settings.w357_current_url;
1383            var encodedDeclineMsg = encodeURIComponent(decodeURI(msgFun));
1384            var encodedDeclineCookieName = encodeURIComponent(cookieNameFun);
1385            var encodedDeclineLink = encodeURIComponent(linkFun);
1386            HTMLinformationBoxes +=
1387                '<button id="cpnb-decline-btn-m" class="cpnb-button cpnb-m-DeclineAllButton ' +
1388                decodeURI(
1389                    settings.w357_decline_button_class_notification_bar_modal_window
1390                ) +
1391                '" type="button" data-cpnb-action="decline" data-cpnb-joomla-caching="' +
1392                settings.w357_joomla_caching +
1393                '" data-cpnb-enable-confirmation="' +
1394                decodeURI(enableConfirFun) +
1395                '" data-cpnb-message="' +
1396                encodedDeclineMsg +
1397                '" data-cpnb-cookie-name="' +
1398                encodedDeclineCookieName +
1399                '" data-cpnb-link="' +
1400                encodedDeclineLink +
1401                '" data-cpnb-expiration="' +
1402                expiration +
1403                '" data-cpnb-is-modal="true">' +
1404                modalManager.w357_m_DeclineAllButtonText +
1405                '</button>';
1406            var linkFun = settings.w357_current_url;
1407            var init_genericExp = settings.w357_expiration_cookies;
1408            var init_baseUrl = settings.w357_current_url;
1409            var init_cookieName = settings.w357_cookie_name;
1410            var init_acceptExp = settings.w357_expiration_cookieAccept;
1411            var init_declineExp = settings.w357_expiration_cookieDecline;
1412            var encodedSaveLink = encodeURIComponent(linkFun);
1413            var encodedSaveBaseUrl = encodeURIComponent(init_baseUrl);
1414            var encodedSaveCookieName = encodeURIComponent(init_cookieName);
1415            HTMLinformationBoxes +=
1416                '<button type="button" id="cpnb-save-btn-m" class="cpnb-button cpnb-m-SaveChangesButton ' +
1417                decodeURI(
1418                    settings.w357_save_button_class_notification_bar_modal_window
1419                ) +
1420                '" data-cpnb-action="save-settings" data-cpnb-link="' +
1421                encodedSaveLink +
1422                '" data-cpnb-expiration="' +
1423                init_genericExp +
1424                '" data-cpnb-base-url="' +
1425                encodedSaveBaseUrl +
1426                '" data-cpnb-cookie-name="' +
1427                encodedSaveCookieName +
1428                '" data-cpnb-accept-expiration="' +
1429                init_acceptExp +
1430                '" data-cpnb-decline-expiration="' +
1431                init_declineExp +
1432                '" data-cpnb-joomla-caching="' +
1433                settings.w357_joomla_caching +
1434                '">' +
1435                modalManager.w357_m_SaveChangesButtonText +
1436                '</button>';
1437            HTMLinformationBoxes += '</div>';
1438
1439            afterCategoriesSettingsCookie = categoriesSettingsCookie;
1440            afterExpirationCookies = settings.w357_expiration_cookies;
1441
1442            var cnbwb =
1443                '<div id="cpnb_manager_wrap" class="cpnb-modal-wrap cpnb-modal-show-fade-out">';
1444            cnbwb +=
1445                '		<div class="cpnb-modal-outer cpnb-modal-bg cpnb-close" id="cpnb_outter" style="top: 0px; left: 0px; align-items: flex-start;">';
1446            cnbwb +=
1447                '				<div class="cpnb-modal-inner cpnb-modal--medium" id="cpnb_inner" style="z-index: 100000000; height:' +
1448                maxHeight +
1449                'px; margin-top:' +
1450                marginTopWindow +
1451                'px; overflow:hidden;">';
1452            if (modalManager.w357_m_FloatButtonIconType == 'fontawesome_icon') {
1453                cnbwb +=
1454                    '						<span role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="Close" onClick="cpnb_m_closeModal()" id="cpnb-modal-close" class="cpnb-modal-close-fontawesome"><i class="fa fas fa-times"></i></span>';
1455            } else {
1456                cnbwb +=
1457                    '						<span role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="Close" onClick="cpnb_m_closeModal()" id="cpnb-modal-close" class="cpnb-modal-close cpnb-close cpnb-close-icon-x"></span>';
1458            }
1459            cnbwb +=
1460                '						<section class="cpnb-m-content" aria-label="' +
1461                modalManager.w357_m_modalHeadingText +
1462                '">';
1463            cnbwb +=
1464                '						<div id="cpnb_manager_modal_left" class="cpnb-manager-modal-left">';
1465            cnbwb += HTMLleftMenu;
1466            cnbwb += '						</div>';
1467
1468            cnbwb += HTMLinformationBoxes;
1469
1470            cnbwb += '						</section>';
1471            cnbwb += '				</div>';
1472            cnbwb +=
1473                '				<div class="cpnb-modal-show-fade-out" id="cpnb_manager_wrap_close_bg" aria-label="Close modal" style=" z-index: 99999999; top:0; left:0; position:fixed; width:100%; height:100%;"></div>';
1474            cnbwb += '		</div>';
1475            cnbwb += '</div>';
1476            var elem = document.createElement('div');
1477            elem.innerHTML = cnbwb;
1478            var bar = document.getElementById('w357_cpnb_outer');
1479            if (bar && bar.parentNode) {
1480                bar.parentNode.insertBefore(elem, bar.nextSibling);
1481            } else {
1482                document.body.insertBefore(elem, document.body.firstChild);
1483            }
1484
1485            var closeModalOverlay = document.getElementById(
1486                'cpnb_manager_wrap_close_bg'
1487            );
1488            if (closeModalOverlay) {
1489                closeModalOverlay.addEventListener(
1490                    'click',
1491                    cpnb_m_closeModal,
1492                    false
1493                );
1494            }
1495
1496            var closeModalOuter = document.getElementById('cpnb_outter');
1497            if (closeModalOuter) {
1498                closeModalOuter.addEventListener(
1499                    'click',
1500                    function (event) {
1501                        if (event.target === closeModalOuter) {
1502                            cpnb_m_closeModal();
1503                        }
1504                    },
1505                    false
1506                );
1507            }
1508
1509            // Check if floatButton is enabled
1510            if (
1511                modalManager.w357_m_floatButtonState == 1 &&
1512                (cpnb_hasConsentCookie(settings.w357_cookie_name_cancelled) ||
1513                    cpnb_hasConsentCookie(settings.w357_cookie_name_declined) ||
1514                    cpnb_hasConsentCookie(settings.w357_cookie_name))
1515            ) {
1516                //Floating Button
1517                var tooltipPosition =
1518                    modalManager.w357_m_floatButtonPosition === 'bottom_right'
1519                        ? 'left'
1520                        : 'right';
1521                var floatingButton =
1522                    '<div role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' +
1523                    modalManager.w357_m_floatButtonText +
1524                    '" onClick="cpnb_m_openModal()" class="cpnb-m-cookies-floatButton cpnb-m-cookies-floatButtonPosition_' +
1525                    modalManager.w357_m_floatButtonPosition +
1526                    '">';
1527                floatingButton +=
1528                    '<div class="cpnb-m-cookies-floatButton-icon" data-balloon="' +
1529                    modalManager.w357_m_floatButtonText +
1530                    '" data-balloon-pos="' +
1531                    tooltipPosition +
1532                    '">';
1533
1534                if (
1535                    modalManager.w357_m_FloatButtonIconType ==
1536                    'fontawesome_icon'
1537                ) {
1538                    floatingButton +=
1539                        '<i class="cpnb-m-cookies-floatButton-icon-fontawesome-icon ' +
1540                        modalManager.w357_m_FloatButtonIconFontAwesomeName +
1541                        ' ' +
1542                        modalManager.w357_m_FloatButtonIconFontAwesomeSize +
1543                        '" style="color: ' +
1544                        modalManager.w357_m_FloatButtonIconFontAwesomeColor +
1545                        ';"></i>';
1546                } else if (
1547                    modalManager.w357_m_FloatButtonIconType == 'uikit_icon'
1548                ) {
1549                    floatingButton +=
1550                        '<span class="cpnb-m-cookies-floatButton-icon-uikit-icon" uk-icon="icon:' +
1551                        modalManager.w357_m_FloatButtonIconUikitName +
1552                        '; ratio: ' +
1553                        modalManager.w357_m_FloatButtonIconUikitSize +
1554                        '" style="color: ' +
1555                        modalManager.w357_m_FloatButtonIconUikitColor +
1556                        ';"></span>';
1557                } else {
1558                    floatingButton +=
1559                        '<img alt="Cookies manager" class="cpnb-m-cookies-floatButton-icon-img" src="' +
1560                        modalManager.w357_m_floatButtonIconSrc +
1561                        '"/>';
1562                }
1563
1564                floatingButton += '</div>';
1565                floatingButton += '</div>';
1566                var elem = document.createElement('div');
1567                elem.innerHTML = floatingButton;
1568                document.body.insertBefore(elem, document.body.firstChild);
1569            }
1570
1571            var click_to_open_modal = null;
1572            var el_w357_m_HashLink = document.getElementById(
1573                modalManager.w357_m_HashLink
1574            );
1575            if (el_w357_m_HashLink) {
1576                click_to_open_modal = el_w357_m_HashLink.addEventListener(
1577                    'click',
1578                    cpnb_m_openModal,
1579                    false
1580                );
1581            }
1582
1583            var classTriggerName = modalManager.w357_m_HashLink;
1584            var classTriggers = [];
1585            if (classTriggerName) {
1586                classTriggers = document.getElementsByClassName(
1587                    classTriggerName
1588                );
1589            }
1590            var hashTriggers = [];
1591            if (classTriggerName) {
1592                hashTriggers = Array.prototype.slice.call(
1593                    document.querySelectorAll(
1594                        'a[href$="#' + classTriggerName + '"]'
1595                    )
1596                );
1597            }
1598            var menuItemTriggers = Array.prototype.slice.call(
1599                document.querySelectorAll(
1600                    'a[href*="view=cpnbcookiemanager"]'
1601                )
1602            );
1603            if (menuItemTriggers.length) {
1604                menuItemTriggers.forEach(function (menuEl) {
1605                    if (menuEl && menuEl.classList) {
1606                        menuEl.classList.add('cpnb-modal-trigger');
1607                    }
1608                });
1609            }
1610            var modalTriggers = Array.prototype.slice.call(
1611                document.getElementsByClassName('cpnb-modal-trigger')
1612            );
1613            var combinedTriggers = modalTriggers;
1614            if (classTriggers.length) {
1615                combinedTriggers = combinedTriggers.concat(
1616                    Array.prototype.slice.call(classTriggers)
1617                );
1618            }
1619            if (hashTriggers.length) {
1620                combinedTriggers = combinedTriggers.concat(hashTriggers);
1621            }
1622            if (combinedTriggers.length) {
1623                combinedTriggers.forEach(function (triggerEl) {
1624                    triggerEl.addEventListener(
1625                        'click',
1626                        function (event) {
1627                            if (event && event.preventDefault) {
1628                                event.preventDefault();
1629                            }
1630                            click_to_open_modal = true;
1631                            cpnb_m_openModal();
1632                        },
1633                        false
1634                    );
1635                });
1636            }
1637            document.addEventListener(
1638                'click',
1639                function (event) {
1640                    var target = event.target;
1641                    while (target && target !== document) {
1642                        if (
1643                            target.classList &&
1644                            target.classList.contains('cpnb-modal-trigger')
1645                        ) {
1646                            if (event && event.preventDefault) {
1647                                event.preventDefault();
1648                            }
1649                            click_to_open_modal = true;
1650                            cpnb_m_openModal();
1651                            break;
1652                        }
1653                        target = target.parentNode;
1654                    }
1655                },
1656                false
1657            );
1658
1659            // Check Hash Link to open modal
1660            if (
1661                window.location.hash == '#' + modalManager.w357_m_HashLink ||
1662                click_to_open_modal
1663            ) {
1664                var e = document.getElementById('cpnb_manager_wrap');
1665                if (e) {
1666                    e.classList.remove('cpnb-modal-show-fade-out');
1667                    e.classList.add('cpnb-modal-show-fade-in');
1668                }
1669
1670                var ec = document.getElementById('cpnb_manager_wrap_close_bg');
1671                if (ec) {
1672                    ec.classList.remove('cpnb-modal-show-fade-out');
1673                    ec.classList.add('cpnb-modal-show-fade-in');
1674                }
1675            }
1676        } //End - Check if ModalManager is enabled
1677
1678        cpnb_bindKeyboardAccessibility();
1679
1680        ////***************** END MANAGER *****************////
1681    },
1682    false
1683); // END: WINDOW.ONLOAD
1684
1685/////******* START MANAGER *******/////
1686
1687//DISABLED CHECKBOX - cpnb_m_lockedCheckbox
1688function cpnb_m_lockedCheckbox(id, exp, confirmationAlert) {
1689    document.getElementById('modalCheckBox_id_' + id).checked = true;
1690    alert(m_modalManager_confirmationText);
1691    return;
1692}
1693
1694function cpnb_handleLockedCheckboxChange(event) {
1695    var target = event.target;
1696    if (
1697        !target ||
1698        !target.matches ||
1699        !target.matches('input.cpnb-checkbox[data-cpnb-locked="1"]')
1700    ) {
1701        return;
1702    }
1703
1704    cpnb_m_lockedCheckbox(
1705        target.getAttribute('data-cpnb-category-id'),
1706        target.getAttribute('data-cpnb-exp'),
1707        target.getAttribute('data-cpnb-confirmation')
1708    );
1709}
1710
1711function cpnb_handleCategoryCheckboxChange(event) {
1712    var target = event.target;
1713    if (
1714        !target ||
1715        !target.matches ||
1716        !target.matches('input.cpnb-checkbox[data-cpnb-save="1"]')
1717    ) {
1718        return;
1719    }
1720
1721    cpnb_m_saveCategoryCookiesState(
1722        target.getAttribute('data-cpnb-category-id'),
1723        target.getAttribute('data-cpnb-exp'),
1724        target.getAttribute('data-cpnb-base-url'),
1725        target.getAttribute('data-cpnb-cookie-name'),
1726        target.getAttribute('data-cpnb-accept-exp'),
1727        target.getAttribute('data-cpnb-decline-exp')
1728    );
1729}
1730
1731// Save Settings Button
1732function cpnb_warning_save_settings_button(
1733    link,
1734    exp,
1735    baseUrl,
1736    acceptCookieName,
1737    acceptCookieExpiration,
1738    declineCookieExpiration,
1739    w357_joomla_caching
1740) {
1741    var closeModalIfOpen = function () {
1742        if (document.getElementById('cpnb_manager_wrap')) {
1743            cpnb_m_closeModal();
1744        }
1745    };
1746    var closeBarIfOpen = function () {
1747        cpnb_closeNotificationBar();
1748    };
1749
1750    cpnb_setConsentCookie(
1751        'cpnb_cookiesSettings',
1752        afterCategoriesSettingsCookie,
1753        afterExpirationCookies
1754    );
1755    // Use the temp settings until the "cpnb_warning_save_settings_button" function is called
1756    if (cpnb_getConsentCookiePayload('cpnb_cookiesSettingsTemp') == null) {
1757        cpnb_setConsentCookie(
1758            'cpnb_cookiesSettingsTemp',
1759            cpnb_getConsentCookieValue('cpnb_cookiesSettings'),
1760            exp
1761        );
1762    }
1763
1764    cpnb_setConsentCookie(
1765        'cpnb_cookiesSettings',
1766        cpnb_getConsentCookieValue('cpnb_cookiesSettingsTemp'),
1767        exp
1768    );
1769
1770    // save settings
1771    cpnb_handleBlockCookieScripts();
1772
1773    var savedCookieSettings = cpnb_getConsentCookieValue(
1774        'cpnb_cookiesSettingsTemp'
1775    );
1776    if (savedCookieSettings) {
1777        afterCategoriesSettingsCookie = savedCookieSettings || {};
1778    } else {
1779        afterCategoriesSettingsCookie = {};
1780    }
1781    afterExpirationCookies = exp;
1782    var funCookieSettings = cpnb_getConsentCookieValue(
1783        'cpnb_cookiesSettings'
1784    );
1785
1786    //CHECK+CHANGE CookieName & cpnb_cookieDeclined = 1
1787    var countAllCategoriesCookies = 0;
1788    var countDisabledCategoriesCookies = 0;
1789    var countLockedCategoriesCookies = 0;
1790    for (var item in funCookieSettings) {
1791        countAllCategoriesCookies++;
1792
1793        if (cpnb_cookiesCategories[categoriesSettingsCookieInner[item]]) {
1794            if (
1795                cpnb_cookiesCategories[categoriesSettingsCookieInner[item]]
1796                    .cookie_category_checked_by_default == 2
1797            ) {
1798                countLockedCategoriesCookies++;
1799            }
1800
1801            if (funCookieSettings[item] == 0) {
1802                countDisabledCategoriesCookies++;
1803            }
1804        }
1805    }
1806
1807    //If remaining cookies are all disabled, delete cookieName and create cookieDeclined=1
1808    if (
1809        countAllCategoriesCookies - countLockedCategoriesCookies ==
1810        countDisabledCategoriesCookies
1811    ) {
1812        if (!cpnb_hasConsentCookie(cpnb_getDeclinedCookieName())) {
1813            cpnb_setConsentCookie(
1814                cpnb_getDeclinedCookieName(),
1815                '1',
1816                declineCookieExpiration
1817            );
1818            cpnb_eraseCookie(acceptCookieName);
1819            cpnb_eraseCookie(cpnb_getCancelledCookieName());
1820            cpnb_eraseCookie('cpnb_cookiesSettingsTemp');
1821
1822            var postData = {
1823                cpnb_method: 'cpnbCookiesDeclined',
1824                dt: w357_joomla_caching > 0 ? new Date().getTime() : undefined,
1825            };
1826            sendPostRequest(baseUrl, postData);
1827            closeModalIfOpen();
1828            cpnb_m_ensureFloatButton();
1829            closeBarIfOpen();
1830            return;
1831        }
1832    } else {
1833        if (!cpnb_hasConsentCookie(acceptCookieName)) {
1834            cpnb_setConsentCookie(
1835                acceptCookieName,
1836                '1',
1837                acceptCookieExpiration
1838            );
1839            cpnb_eraseCookie(cpnb_getDeclinedCookieName());
1840            cpnb_eraseCookie(cpnb_getCancelledCookieName());
1841            cpnb_eraseCookie('cpnb_cookiesSettingsTemp');
1842            var postData = {
1843                cpnb_method: 'cpnbCookiesAccepted',
1844                dt: w357_joomla_caching > 0 ? new Date().getTime() : undefined,
1845            };
1846            sendPostRequest(baseUrl, postData);
1847            closeModalIfOpen();
1848            cpnb_m_ensureFloatButton();
1849            closeBarIfOpen();
1850            return;
1851        }
1852    }
1853
1854    var postData = {
1855        cpnb_method: 'cpnbCookiesManagerSaveSettings',
1856        dt: w357_joomla_caching > 0 ? new Date().getTime() : undefined,
1857    };
1858
1859    sendPostRequest(link, postData);
1860    closeModalIfOpen();
1861    cpnb_m_ensureFloatButton();
1862    closeBarIfOpen();
1863}
1864
1865function cpnb_m_saveCategoryCookiesState(
1866    id,
1867    exp,
1868    baseUrl,
1869    acceptCookieName,
1870    acceptCookieExpiration,
1871    declineCookieExpiration
1872) {
1873    if (cpnb_cookiesCategories[id].cookie_category_checked_by_default != 2) {
1874        // Use the temp settings until the "cpnb_warning_save_settings_button" function is called
1875        if (cpnb_getConsentCookiePayload('cpnb_cookiesSettingsTemp') == null) {
1876            cpnb_setConsentCookie(
1877                'cpnb_cookiesSettingsTemp',
1878                afterCategoriesSettingsCookie || {},
1879                exp
1880            );
1881        }
1882        var tempCookie = cpnb_getConsentCookieValue('cpnb_cookiesSettingsTemp');
1883        var funCookieSettings = tempCookie || {};
1884
1885        if (
1886            document.getElementById('modalCheckBox_id_' + id).checked === true
1887        ) {
1888            funCookieSettings[categoriesSettingsCookieOuter[id]] = 1;
1889        } else {
1890            funCookieSettings[categoriesSettingsCookieOuter[id]] = 0;
1891        }
1892
1893        afterCategoriesSettingsCookie = funCookieSettings;
1894
1895        document.getElementById('cpnb-save-btn-m').style.background =
1896            modalManagerSettings.w357_m_saveChangesButtonColorAfterChange;
1897
1898        cpnb_setConsentCookie(
1899            'cpnb_cookiesSettingsTemp',
1900            funCookieSettings,
1901            exp
1902        );
1903    }
1904}
1905
1906function cpnb_m_changeModalCategory(id) {
1907    //CHANGE LEFT MENU ITEM
1908    var x = document.getElementsByClassName(
1909        'cpnb-manager-modal-left-item-selected'
1910    );
1911    x[0].classList.add('cpnb-manager-modal-left-item-unSelected');
1912    x[0].classList.remove('cpnb-manager-modal-left-item-selected');
1913    var x = document.getElementById('mlm_menu_category_id_' + id);
1914    x.classList.remove('cpnb-manager-modal-left-item-unSelected');
1915    x.classList.add('cpnb-manager-modal-left-item-selected');
1916    //CHANGE RIGHT INFORMATION BOX
1917    var x = document.getElementsByClassName(
1918        'cpnb-manager-modal-right-selected'
1919    );
1920    x[0].classList.add('cpnb-manager-modal-right-unSelected');
1921    x[0].classList.remove('cpnb-manager-modal-right-selected');
1922    var x = document.getElementById('mmr_box_category_id_' + id);
1923    x.classList.remove('cpnb-manager-modal-right-unSelected');
1924    x.classList.add('cpnb-manager-modal-right-selected');
1925
1926    //Responsive Hide SelectCategoryMenu on ChangeCategory
1927    cpnb_toggle_responsive_menu_hide_menu();
1928}
1929
1930function cpnb_m_openModal() {
1931    var e = document.getElementById('cpnb_manager_wrap');
1932    if (e) {
1933        e.classList.remove('cpnb-modal-show-fade-out');
1934        e.classList.add('cpnb-modal-show-fade-in');
1935    }
1936
1937    var ec = document.getElementById('cpnb_manager_wrap_close_bg');
1938    if (ec) {
1939        ec.classList.remove('cpnb-modal-show-fade-out');
1940        ec.classList.add('cpnb-modal-show-fade-in');
1941    }
1942}
1943
1944function cpnb_m_ensureFloatButton() {
1945    var cfg = typeof cpnb_config !== 'undefined' ? cpnb_config : settings;
1946    if (
1947        !modalManagerSettings ||
1948        modalManagerSettings.w357_m_floatButtonState != 1 ||
1949        modalManagerSettings.w357_m_modalState != 1 ||
1950        cfg.w357_blockCookies != 1 ||
1951        (typeof cpnb_checkDIfIframeDisplay === 'function' &&
1952            !cpnb_checkDIfIframeDisplay())
1953    ) {
1954        return;
1955    }
1956    if (document.querySelector('.cpnb-m-cookies-floatButton')) {
1957        return;
1958    }
1959
1960    if (
1961        !cpnb_hasConsentCookie(cfg.w357_cookie_name_cancelled) &&
1962        !cpnb_hasConsentCookie(cfg.w357_cookie_name_declined) &&
1963        !cpnb_hasConsentCookie(cfg.w357_cookie_name)
1964    ) {
1965        return;
1966    }
1967
1968    var tooltipPosition =
1969        modalManagerSettings.w357_m_floatButtonPosition === 'bottom_right'
1970            ? 'left'
1971            : 'right';
1972    var floatingButton =
1973        '<div role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' +
1974        modalManagerSettings.w357_m_floatButtonText +
1975        '" onClick="cpnb_m_openModal()" class="cpnb-m-cookies-floatButton cpnb-m-cookies-floatButtonPosition_' +
1976        modalManagerSettings.w357_m_floatButtonPosition +
1977        '">';
1978    floatingButton +=
1979        '<div class="cpnb-m-cookies-floatButton-icon" data-balloon="' +
1980        modalManagerSettings.w357_m_floatButtonText +
1981        '" data-balloon-pos="' +
1982        tooltipPosition +
1983        '">';
1984
1985    if (modalManagerSettings.w357_m_FloatButtonIconType == 'fontawesome_icon') {
1986        floatingButton +=
1987            '<i class="cpnb-m-cookies-floatButton-icon-fontawesome-icon ' +
1988            modalManagerSettings.w357_m_FloatButtonIconFontAwesomeName +
1989            ' ' +
1990            modalManagerSettings.w357_m_FloatButtonIconFontAwesomeSize +
1991            '" style="color: ' +
1992            modalManagerSettings.w357_m_FloatButtonIconFontAwesomeColor +
1993            ';"></i>';
1994    } else if (
1995        modalManagerSettings.w357_m_FloatButtonIconType == 'uikit_icon'
1996    ) {
1997        floatingButton +=
1998            '<span class="cpnb-m-cookies-floatButton-icon-uikit-icon" uk-icon="icon:' +
1999            modalManagerSettings.w357_m_FloatButtonIconUikitName +
2000            '; ratio: ' +
2001            modalManagerSettings.w357_m_FloatButtonIconUikitSize +
2002            '" style="color: ' +
2003            modalManagerSettings.w357_m_FloatButtonIconUikitColor +
2004            ';"></span>';
2005    } else {
2006        floatingButton +=
2007            '<img alt="Cookies manager" class="cpnb-m-cookies-floatButton-icon-img" src="' +
2008            modalManagerSettings.w357_m_floatButtonIconSrc +
2009            '"/>';
2010    }
2011
2012    floatingButton += '</div>';
2013    floatingButton += '</div>';
2014
2015    var elem = document.createElement('div');
2016    elem.innerHTML = floatingButton;
2017    document.body.insertBefore(elem, document.body.firstChild);
2018}
2019
2020function cpnb_m_closeModal() {
2021    var e = document.getElementById('cpnb_manager_wrap');
2022    if (e) {
2023        e.classList.remove('cpnb-modal-show-fade-in');
2024        e.classList.add('cpnb-modal-show-fade-out');
2025    }
2026
2027    var ec = document.getElementById('cpnb_manager_wrap_close_bg');
2028    if (ec) {
2029        ec.classList.remove('cpnb-modal-show-fade-in');
2030        ec.classList.add('cpnb-modal-show-fade-out');
2031    }
2032}
2033
2034// Enable Enter/Space activation for focusable non-button controls (e.g. modal tabs).
2035function cpnb_bindKeyboardAccessibility() {
2036    if (window.cpnb_keyboard_bound) {
2037        return;
2038    }
2039    window.cpnb_keyboard_bound = true;
2040    document.addEventListener('keydown', function (event) {
2041        var key = event.key || event.keyCode;
2042        var isEnter = key === 'Enter' || key === 13;
2043        var isSpace = key === ' ' || key === 'Spacebar' || key === 32;
2044        if (!isEnter && !isSpace) {
2045            return;
2046        }
2047        var target = event.target;
2048        if (!target || !target.getAttribute) {
2049            return;
2050        }
2051        if (target.getAttribute('role') === 'button' || target.tagName === 'BUTTON') {
2052            event.preventDefault();
2053            target.click();
2054        }
2055    });
2056}
2057
2058function cpnb_closeNotificationBar() {
2059    var bar = document.getElementById('w357_cpnb_outer');
2060    if (bar) {
2061        bar.classList.add('cpnb-warningBox-show-fade-out');
2062        setTimeout(function () {
2063            if (bar.parentNode) {
2064                bar.parentNode.removeChild(bar);
2065            }
2066        }, 500);
2067    }
2068    var overlay = document.getElementById('cpnb_warningBoxBgOverlay');
2069    if (overlay) {
2070        overlay.style.display = 'none';
2071    }
2072}
2073/////******* END MANAGER *******/////
2074
2075// OK - Accept Button
2076function acceptFunction(
2077    w357_joomla_caching,
2078    confirmationAlert,
2079    confirmMsg,
2080    AcceptCookieName,
2081    link,
2082    expiration,
2083    base_url,
2084    type,
2085    reloadPageAfterAccept,
2086    overlayState
2087) {
2088    cpnb_setConsentCookie(
2089        'cpnb_cookiesSettings',
2090        afterCategoriesSettingsCookie,
2091        afterExpirationCookies
2092    );
2093    cpnb_setConsentCookie(AcceptCookieName, '1', expiration);
2094    cpnb_eraseCookie(cpnb_getCancelledCookieName());
2095    cpnb_eraseCookie(cpnb_getDeclinedCookieName());
2096    cpnb_eraseCookie('cpnb_cookiesSettingsTemp');
2097
2098    var shouldReload = reloadPageAfterAccept == 1;
2099    if (!shouldReload) {
2100        // Render any scripts that should run after consent is given (accept)
2101        cpnb_handleBlockCookieScripts();
2102    }
2103
2104    // Modal Manager
2105    var funCookieSettings = cpnb_getConsentCookieValue('cpnb_cookiesSettings');
2106    for (var item in funCookieSettings) {
2107        funCookieSettings[item] = 1;
2108    }
2109    cpnb_setConsentCookie(
2110        'cpnb_cookiesSettings',
2111        funCookieSettings,
2112        afterExpirationCookies
2113    );
2114
2115    var postData = {
2116        cpnb_method: 'cpnbCookiesAccepted',
2117        dt: w357_joomla_caching > 0 ? new Date().getTime() : undefined,
2118    };
2119
2120    if (type == 'notification_bar') {
2121        // hide notification bar
2122        if (shouldReload) {
2123            sendPostRequest(link, postData);
2124            cpnb_handleBlockCookieScripts();
2125            try {
2126                if (cpnb_config.w357_shortcode_is_enabled_on_this_page == 1) {
2127                    localStorage.setItem('cpnb_shortcode_cookie_reload', '1');
2128                }
2129            } catch (e) {}
2130            setTimeout(function () {
2131                window.location.reload();
2132            }, 1500);
2133            return;
2134        } else {
2135            // Store decision to DB
2136            var xmlhttp = new XMLHttpRequest();
2137            xmlhttp.onreadystatechange = function () {
2138                if (xmlhttp.readyState == XMLHttpRequest.DONE) {
2139                    // XMLHttpRequest.DONE == 4
2140                    if (xmlhttp.status == 200) {
2141                        // all done
2142                    } else if (xmlhttp.status == 400) {
2143                        // There was an error 400
2144                    } else {
2145                        // something else other than 200 was returned
2146                    }
2147                }
2148            };
2149            var url =
2150                base_url +
2151                'index.php?option=com_ajax&plugin=cookiespolicynotificationbar&format=raw&method=cpnbCookiesAccepted';
2152            xmlhttp.open('POST', url, true);
2153            xmlhttp.setRequestHeader(
2154                'Content-Type',
2155                'application/x-www-form-urlencoded'
2156            );
2157            xmlhttp.send(postData);
2158
2159            // hide the notification bar
2160            document
2161                .getElementById('w357_cpnb_outer')
2162                .classList.add('cpnb-warningBox-show-fade-out');
2163            if (overlayState == 1) {
2164                document.getElementById(
2165                    'cpnb_warningBoxBgOverlay'
2166                ).style.display = 'none';
2167            }
2168        }
2169    } // shortcode_table or modal
2170    else {
2171        if (shouldReload) {
2172            sendPostRequest(link, postData);
2173            cpnb_handleBlockCookieScripts();
2174            try {
2175                if (cpnb_config.w357_shortcode_is_enabled_on_this_page == 1) {
2176                    localStorage.setItem('cpnb_shortcode_cookie_reload', '1');
2177                }
2178            } catch (e) {}
2179            setTimeout(function () {
2180                window.location.reload();
2181            }, 1500);
2182            return;
2183        } else {
2184            sendPostRequest(link, postData);
2185            cpnb_fetchCookiesInfoTable();
2186            return;
2187        }
2188    }
2189}
2190
2191function checkCookieCategoriesAfterAccept(expiration) {
2192    // after accept check all checkboxes asynchronously.
2193    cpnb_checkboxes = document.getElementsByClassName('cpnb-checkbox');
2194    for (var i = 0, n = cpnb_checkboxes.length; i < n; i++) {
2195        cpnb_checkboxes[i].checked = true;
2196    }
2197
2198    for (var categoryID in cpnb_cookiesCategories) {
2199        if (cpnb_cookiesCategories[categoryID].cookie_category_status == 1) {
2200            var innerCookieCategory =
2201                cpnb_cookiesCategories[categoryID].cookie_category_id;
2202            categoriesSettingsCookie[innerCookieCategory] = 1;
2203        }
2204    }
2205
2206    // Get the total of enabled categories and if is more than one then create the cpnb_cookiesSettings cookie, or if is only the required-cookies category do not create the cpnb_cookiesSettings cookie to pass the Cookiebot validation service
2207    var categoriesSettingsCookie_arr_values = Object.keys(
2208        categoriesSettingsCookie
2209    ).map(function (itm) {
2210        return categoriesSettingsCookie[itm];
2211    }); // IE compatibility
2212
2213    var categoriesSettingsCookie_count_of_enabled =
2214        categoriesSettingsCookie_arr_values.reduce(function (a, b) {
2215            return a + b;
2216        }, 0);
2217
2218    if (categoriesSettingsCookie_count_of_enabled > 1) {
2219        cpnb_setConsentCookie(
2220            'cpnb_cookiesSettings',
2221            categoriesSettingsCookie,
2222            expiration
2223        );
2224    }
2225
2226    afterCategoriesSettingsCookie = categoriesSettingsCookie;
2227    afterExpirationCookies = expiration;
2228}
2229
2230function checkCookieCategoriesAfterDecline(expiration) {
2231    // after decline uncheck all checkboxes and keep the locked ones checked
2232    var cpnb_checkboxes = document.getElementsByClassName('cpnb-checkbox');
2233    for (var i = 0, n = cpnb_checkboxes.length; i < n; i++) {
2234        cpnb_checkboxes[i].checked = false;
2235    }
2236
2237    for (var categoryID in cpnb_cookiesCategories) {
2238        if (cpnb_cookiesCategories[categoryID].cookie_category_status == 1) {
2239            var innerCookieCategory =
2240                cpnb_cookiesCategories[categoryID].cookie_category_id;
2241            if (
2242                cpnb_cookiesCategories[categoryID]
2243                    .cookie_category_checked_by_default == 2
2244            ) {
2245                categoriesSettingsCookie[innerCookieCategory] = 1;
2246                var lockedCheckbox = document.getElementById(
2247                    'modalCheckBox_id_' + categoryID
2248                );
2249                if (lockedCheckbox) {
2250                    lockedCheckbox.checked = true;
2251                }
2252            } else {
2253                categoriesSettingsCookie[innerCookieCategory] = 0;
2254            }
2255        }
2256    }
2257
2258    cpnb_setConsentCookie(
2259        'cpnb_cookiesSettings',
2260        categoriesSettingsCookie,
2261        expiration
2262    );
2263
2264    afterCategoriesSettingsCookie = categoriesSettingsCookie;
2265    afterExpirationCookies = expiration;
2266}
2267
2268function cpnb_warning_accept_button(
2269    w357_joomla_caching,
2270    confirmationAlert,
2271    confirmMsg,
2272    AcceptCookieName,
2273    link,
2274    expiration,
2275    base_url,
2276    type,
2277    reloadPageAfterAccept,
2278    overlayState
2279) {
2280    if (confirmationAlert != 1 || confirm(confirmMsg)) {
2281        checkCookieCategoriesAfterAccept(expiration);
2282        acceptFunction(
2283            w357_joomla_caching,
2284            confirmationAlert,
2285            confirmMsg,
2286            AcceptCookieName,
2287            link,
2288            expiration,
2289            base_url,
2290            type,
2291            reloadPageAfterAccept,
2292            overlayState
2293        );
2294    }
2295    if (type == 'modal') {
2296        cpnb_m_closeModal();
2297        cpnb_closeModalMoreInfo();
2298    }
2299    cpnb_m_ensureFloatButton();
2300    cpnb_closeNotificationBar();
2301}
2302
2303// Decline Button
2304function cpnb_warning_decline_button(
2305    w357_joomla_caching,
2306    confirmationAlert,
2307    confirmMsg,
2308    cookieName,
2309    link,
2310    expiration,
2311    isModalWindow = false
2312) {
2313    var postData = {
2314        cpnb_method: 'cpnbCookiesDeclined',
2315        cpnb_btn_area: isModalWindow ? 'cookiesManager' : 'notificationBar',
2316        dt: w357_joomla_caching > 0 ? new Date().getTime() : undefined,
2317    };
2318
2319    var declineAction = function () {
2320        checkCookieCategoriesAfterDecline(expiration);
2321        cpnb_setConsentCookie(
2322            cpnb_getDeclinedCookieName(),
2323            '1',
2324            expiration
2325        );
2326        cpnb_eraseCookie(cookieName);
2327        cpnb_eraseCookie(cpnb_getCancelledCookieName());
2328        cpnb_eraseCookie('cpnb_cookiesSettingsTemp');
2329
2330        // Modal Manager
2331        var funCookieSettings = cpnb_getConsentCookieValue(
2332            'cpnb_cookiesSettings'
2333        );
2334        for (var item in funCookieSettings) {
2335            var catId = categoriesSettingsCookieInner[item];
2336            var isLocked =
2337                catId &&
2338                cpnb_cookiesCategories[catId] &&
2339                cpnb_cookiesCategories[catId]
2340                    .cookie_category_checked_by_default == 2;
2341            funCookieSettings[item] = isLocked ? 1 : 0;
2342        }
2343        cpnb_setConsentCookie(
2344            'cpnb_cookiesSettings',
2345            funCookieSettings,
2346            expiration
2347        );
2348
2349        // decline
2350        cpnb_handleBlockCookieScripts();
2351        sendPostRequest(link, postData);
2352    };
2353
2354    if (confirmationAlert == 1) {
2355        if (confirm(confirmMsg)) {
2356            declineAction();
2357        }
2358    } else {
2359        declineAction();
2360    }
2361    if (isModalWindow) {
2362        cpnb_m_closeModal();
2363        cpnb_closeModalMoreInfo();
2364    }
2365    cpnb_m_ensureFloatButton();
2366    cpnb_closeNotificationBar();
2367}
2368
2369// Delete Button
2370function cpnb_warning_delete_button(
2371    w357_joomla_caching,
2372    confirmationAlert,
2373    confirmMsg,
2374    cookieName,
2375    link
2376) {
2377    var postData = {
2378        cpnb_method: 'cpnbCookiesDeleted',
2379        dt: w357_joomla_caching > 0 ? new Date().getTime() : undefined,
2380    };
2381
2382    if (confirmationAlert == 1) {
2383        if (confirm(confirmMsg)) {
2384            cpnb_eraseCookie('cpnb_cookiesSettings');
2385            cpnb_eraseCookie(cpnb_getDeclinedCookieName());
2386            cpnb_eraseCookie(cookieName);
2387            cpnb_eraseCookie(cpnb_getCancelledCookieName());
2388            sendPostRequest(link, postData);
2389            return;
2390        }
2391    } else {
2392        cpnb_eraseCookie('cpnb_cookiesSettings');
2393        cpnb_eraseCookie(cpnb_getDeclinedCookieName());
2394        cpnb_eraseCookie(cookieName);
2395        cpnb_eraseCookie(cpnb_getCancelledCookieName());
2396        sendPostRequest(link, postData);
2397        return;
2398    }
2399}
2400
2401// Cancel Button
2402function cpnb_warning_cancel_button(
2403    cookieName,
2404    expiration,
2405    link,
2406    overlayState,
2407    isModalWindow = false
2408) {
2409    cpnb_setConsentCookie(cpnb_getCancelledCookieName(), '1', expiration);
2410    cpnb_eraseCookie(cookieName);
2411    cpnb_eraseCookie(cpnb_getDeclinedCookieName());
2412
2413    // hide the notification bar
2414    var bar = document.getElementById('w357_cpnb_outer');
2415    if (bar) {
2416        bar.classList.add('cpnb-warningBox-show-fade-out');
2417    }
2418    if (overlayState == 1) {
2419        var overlay = document.getElementById('cpnb_warningBoxBgOverlay');
2420        if (overlay) {
2421            overlay.style.display = 'none';
2422        }
2423    }
2424
2425    setTimeout(function () {
2426        var bar = document.getElementById('w357_cpnb_outer');
2427        if (bar) {
2428            bar.remove();
2429        }
2430    }, 500);
2431
2432    cpnb_closeModalMoreInfo();
2433}
2434
2435// Open POP UP
2436function w357_openPopUpWindowMoreInfo(url, title, w, h) {
2437    wLeft = window.screenLeft ? window.screenLeft : window.screenX;
2438    wTop = window.screenTop ? window.screenTop : window.screenY;
2439
2440    var left = wLeft + window.innerWidth / 2 - w / 2;
2441    var top = wTop + window.innerHeight / 2 - h / 2;
2442    window.open(
2443        url,
2444        title,
2445        'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' +
2446        w +
2447        ', height=' +
2448        h +
2449        ', top=' +
2450        top +
2451        ', left=' +
2452        left
2453    );
2454}
2455
2456function cpnb_openModalMoreInfo() {
2457    var e = document.getElementById('cpnb_modal_wrap');
2458    if (e) {
2459        e.classList.remove('cpnb-modal-show-fade-out');
2460        e.classList.add('cpnb-modal-show-fade-in');
2461    }
2462
2463    var ec = document.getElementById('modal_close_bg');
2464    if (ec) {
2465        ec.classList.remove('cpnb-modal-show-fade-out');
2466        ec.classList.add('cpnb-modal-show-fade-in');
2467    }
2468}
2469
2470function cpnb_closeModalMoreInfo() {
2471    var e = document.getElementById('cpnb_modal_wrap');
2472    if (e) {
2473        e.classList.remove('cpnb-modal-show-fade-in');
2474        e.classList.add('cpnb-modal-show-fade-out');
2475    }
2476
2477    var ec = document.getElementById('modal_close_bg');
2478    if (ec) {
2479        ec.classList.remove('cpnb-modal-show-fade-in');
2480        ec.classList.add('cpnb-modal-show-fade-out');
2481    }
2482}
2483
2484function cpnb_createCookie(name, value, days) {
2485    var expires;
2486    var expValue = days;
2487    if (typeof expValue === 'string') {
2488        expValue = expValue.trim();
2489    }
2490    if (
2491        expValue &&
2492        String(expValue).toUpperCase() !== 'SESSION' &&
2493        !isNaN(expValue)
2494    ) {
2495        var date = new Date();
2496        date.setTime(date.getTime() + expValue * 24 * 60 * 60 * 1000);
2497        expires = ';SameSite=Lax; expires=' + date.toGMTString();
2498    } else {
2499        expires = '';
2500    }
2501    // Get cookie domain from config (for sharing cookies across subdomains)
2502    var domainStr = '';
2503    if (typeof cpnb_config !== 'undefined' && cpnb_config.w357_co
2503okie_domain) {
2504        domainStr = '; domain=' + cpnb_config.w357_cookie_domain;
2505    }
2506    document.cookie =
2507        encodeURIComponent(name) +
2508        '=' +
2509        encodeURIComponent(value) +
2510        expires +
2511        '; path=/' +
2512        domainStr;
2513}
2514
2515function cpnb_buildConsentPayload(value, exp) {
2516    return JSON.stringify({ v: value, exp: exp });
2517}
2518
2519function cpnb_setConsentCookie(name, value, exp) {
2520    cpnb_createCookie(name, cpnb_buildConsentPayload(value, exp), exp);
2521}
2522
2523function cpnb_getDeclinedCookieName() {
2524    if (
2525        typeof cpnb_config !== 'undefined' &&
2526        cpnb_config.w357_cookie_name_declined
2527    ) {
2528        return cpnb_config.w357_cookie_name_declined;
2529    }
2530    return 'cpnbCookiesDeclined';
2531}
2532
2533function cpnb_getCancelledCookieName() {
2534    if (
2535        typeof cpnb_config !== 'undefined' &&
2536        cpnb_config.w357_cookie_name_cancelled
2537    ) {
2538        return cpnb_config.w357_cookie_name_cancelled;
2539    }
2540    return 'cpnbCookiesCancelled';
2541}
2542
2543function cpnb_getConsentCookiePayload(name) {
2544    var raw = cpnb_readCookie(name);
2545    if (!raw) {
2546        return null;
2547    }
2548    try {
2549        var payload = JSON.parse(raw);
2550        if (!payload || typeof payload !== 'object') {
2551            return null;
2552        }
2553        return payload;
2554    } catch (error) {
2555        return null;
2556    }
2557}
2558
2559function cpnb_getConsentCookieValue(name) {
2560    var payload = cpnb_getConsentCookiePayload(name);
2561    return payload ? payload.v : null;
2562}
2563
2564function cpnb_hasConsentCookie(name) {
2565    return cpnb_getConsentCookiePayload(name) !== null;
2566}
2567
2568function cpnb_syncConsentCookieExpiration(name, exp) {
2569    var payload = cpnb_getConsentCookiePayload(name);
2570    if (!payload) {
2571        return;
2572    }
2573    var current = String(payload.exp).toUpperCase();
2574    var expected = String(exp).toUpperCase();
2575    if (current !== expected) {
2576        cpnb_setConsentCookie(name, payload.v, exp);
2577    }
2578}
2579
2580function cpnb_readCookie(name) {
2581    var nameEQ = encodeURIComponent(name) + '=';
2582    var ca = document.cookie.split(';');
2583    for (var i = 0; i < ca.length; i++) {
2584        var c = ca[i];
2585        while (c.charAt(0) === ' ') c = c.substring(1, c.length);
2586        if (c.indexOf(nameEQ) === 0)
2587            return decodeURIComponent(c.substring(nameEQ.length, c.length));
2588    }
2589    return null;
2590}
2591
2592function cpnb_eraseCookie(name) {
2593    cpnb_createCookie(name, '', -1);
2594}
2595
2596function cpnb_decodeBlockCookiePayload(encodedPayload) {
2597    if (!encodedPayload) {
2598        return '';
2599    }
2600
2601    try {
2602        return atob(encodedPayload);
2603    } catch (error) {
2604        console.error('CPNB: Failed to decode blocked script payload', error);
2605        return '';
2606    }
2607}
2608
2609function cpnb_getDataAttribute(element, attributeName) {
2610    if (!element) {
2611        return '';
2612    }
2613    var value = element.getAttribute(attributeName);
2614    return value === null ? '' : value;
2615}
2616
2617function cpnb_decodeDataAttribute(value) {
2618    if (!value) {
2619        return '';
2620    }
2621    try {
2622        return decodeURIComponent(value);
2623    } catch (error) {
2624        return value;
2625    }
2626}
2627
2628function cpnb_handleActionButtonClick(event) {
2629    var target = event.target;
2630    if (!target || !target.closest) {
2631        return;
2632    }
2633    var actionButton = target.closest('[data-cpnb-action]');
2634    if (!actionButton) {
2635        return;
2636    }
2637
2638    var action = cpnb_getDataAttribute(actionButton, 'data-cpnb-action');
2639    if (!action) {
2640        return;
2641    }
2642
2643    switch (action) {
2644        case 'accept':
2645            cpnb_warning_accept_button(
2646                cpnb_getDataAttribute(
2647                    actionButton,
2648                    'data-cpnb-joomla-caching'
2649                ),
2650                cpnb_getDataAttribute(
2651                    actionButton,
2652                    'data-cpnb-enable-confirmation'
2653                ),
2654                cpnb_decodeDataAttribute(
2655                    cpnb_getDataAttribute(actionButton, 'data-cpnb-message')
2656                ),
2657                cpnb_decodeDataAttribute(
2658                    cpnb_getDataAttribute(
2659                        actionButton,
2660                        'data-cpnb-cookie-name'
2661                    )
2662                ),
2663                cpnb_decodeDataAttribute(
2664                    cpnb_getDataAttribute(actionButton, 'data-cpnb-link')
2665                ),
2666                cpnb_getDataAttribute(
2667                    actionButton,
2668                    'data-cpnb-expiration'
2669                ),
2670                cpnb_decodeDataAttribute(
2671                    cpnb_getDataAttribute(
2672                        actionButton,
2673                        'data-cpnb-base-ajax-url'
2674                    )
2675                ),
2676                cpnb_getDataAttribute(actionButton, 'data-cpnb-context'),
2677                cpnb_getDataAttribute(actionButton, 'data-cpnb-reload'),
2678                cpnb_getDataAttribute(actionButton, 'data-cpnb-overlay')
2679            );
2680            break;
2681        case 'decline':
2682            cpnb_warning_decline_button(
2683                cpnb_getDataAttribute(
2684                    actionButton,
2685                    'data-cpnb-joomla-caching'
2686                ),
2687                cpnb_getDataAttribute(
2688                    actionButton,
2689                    'data-cpnb-enable-confirmation'
2690                ),
2691                cpnb_decodeDataAttribute(
2692                    cpnb_getDataAttribute(actionButton, 'data-cpnb-message')
2693                ),
2694                cpnb_decodeDataAttribute(
2695                    cpnb_getDataAttribute(
2696                        actionButton,
2697                        'data-cpnb-cookie-name'
2698                    )
2699                ),
2700                cpnb_decodeDataAttribute(
2701                    cpnb_getDataAttribute(actionButton, 'data-cpnb-link')
2702                ),
2703                cpnb_getDataAttribute(
2704                    actionButton,
2705                    'data-cpnb-expiration'
2706                ),
2707                cpnb_getDataAttribute(actionButton, 'data-cpnb-is-modal')
2708            );
2709            break;
2710        case 'save-settings':
2711            event.preventDefault();
2712            cpnb_warning_save_settings_button(
2713                cpnb_decodeDataAttribute(
2714                    cpnb_getDataAttribute(actionButton, 'data-cpnb-link')
2715                ),
2716                cpnb_getDataAttribute(
2717                    actionButton,
2718                    'data-cpnb-expiration'
2719                ),
2720                cpnb_decodeDataAttribute(
2721                    cpnb_getDataAttribute(actionButton, 'data-cpnb-base-url')
2722                ),
2723                cpnb_decodeDataAttribute(
2724                    cpnb_getDataAttribute(
2725                        actionButton,
2726                        'data-cpnb-cookie-name'
2727                    )
2728                ),
2729                cpnb_getDataAttribute(
2730                    actionButton,
2731                    'data-cpnb-accept-expiration'
2732                ),
2733                cpnb_getDataAttribute(
2734                    actionButton,
2735                    'data-cpnb-decline-expiration'
2736                ),
2737                cpnb_getDataAttribute(
2738                    actionButton,
2739                    'data-cpnb-joomla-caching'
2740                )
2741            );
2742            break;
2743        case 'delete':
2744            cpnb_warning_delete_button(
2745                cpnb_getDataAttribute(
2746                    actionButton,
2747                    'data-cpnb-joomla-caching'
2748                ),
2749                cpnb_getDataAttribute(
2750                    actionButton,
2751                    'data-cpnb-enable-confirmation'
2752                ),
2753                cpnb_decodeDataAttribute(
2754                    cpnb_getDataAttribute(actionButton, 'data-cpnb-message')
2755                ),
2756                cpnb_decodeDataAttribute(
2757                    cpnb_getDataAttribute(
2758                        actionButton,
2759                        'data-cpnb-cookie-name'
2760                    )
2761                ),
2762                cpnb_decodeDataAttribute(
2763                    cpnb_getDataAttribute(actionButton, 'data-cpnb-link')
2764                )
2765            );
2766            if (cpnb_getDataAttribute(actionButton, 'data-cpnb-reload') == 1) {
2767                setTimeout(function () {
2768                    window.location.reload();
2769                }, 1500);
2770            }
2771            break;
2772        default:
2773            break;
2774    }
2775}
2776
2777function cpnb_isBlockCookieCategoryEnabled(categoryId, loadState) {
2778    if (!categoryId) {
2779        return true;
2780    }
2781
2782    // Find category config by key or by inner category_id
2783    var categoryConfig = null;
2784    if (typeof cpnb_cookiesCategories !== 'undefined') {
2785        if (cpnb_cookiesCategories[categoryId]) {
2786            categoryConfig = cpnb_cookiesCategories[categoryId];
2787        } else {
2788            for (var key in cpnb_cookiesCategories) {
2789                if (
2790                    cpnb_cookiesCategories[key].cookie_category_id ===
2791                    categoryId
2792                ) {
2793                    categoryConfig = cpnb_cookiesCategories[key];
2794                    break;
2795                }
2796            }
2797        }
2798    }
2799
2800    var declinedCookieName =
2801        typeof cpnb_config !== 'undefined' &&
2802        cpnb_config.w357_cookie_name_declined
2803            ? cpnb_config.w357_cookie_name_declined
2804            : 'cpnbCookiesDeclined';
2805    var decisionMade =
2806        cpnb_hasConsentCookie(
2807            typeof cpnb_config !== 'undefined'
2808                ? cpnb_config.w357_cookie_name
2809                : 'cookiesDirective'
2810        ) || cpnb_hasConsentCookie(declinedCookieName);
2811
2812    var cookieSettingsRaw =
2813        cpnb_renderSettingsOverride ||
2814        cpnb_getConsentCookieValue('cpnb_cookiesSettingsTemp') ||
2815        cpnb_getConsentCookieValue('cpnb_cookiesSettings');
2816
2817    // No decision stored yet: fall back to default config per loadState
2818    if (!decisionMade || !cookieSettingsRaw) {
2819        if (!categoryConfig) {
2820            return loadState === 'before' ? true : false;
2821        }
2822
2823        if (loadState === 'before') {
2824            return categoryConfig.cookie_category_checked_by_default == 0;
2825        }
2826
2827        if (loadState === 'after') {
2828            return categoryConfig.cookie_category_checked_by_default > 0;
2829        }
2830
2831        return loadState === 'before' ? true : false;
2832    }
2833
2834    try {
2835        var parsedSettings = cookieSettingsRaw;
2836        if (Object.prototype.hasOwnProperty.call(parsedSettings, categoryId)) {
2837            if (loadState === 'before') {
2838                return parsedSettings[categoryId] === 0;
2839            }
2840            if (loadState === 'after') {
2841                return parsedSettings[categoryId] === 1;
2842            }
2843            if (loadState === 'decline') {
2844                return parsedSettings[categoryId] === 0;
2845            }
2846            return parsedSettings[categoryId] === 1;
2847        }
2848        // If the specific categoryId is not in settings, fall back to defaults
2849        if (categoryConfig) {
2850            if (loadState === 'before') {
2851                return categoryConfig.cookie_category_checked_by_default == 0;
2852            }
2853            if (loadState === 'after') {
2854                return categoryConfig.cookie_category_checked_by_default > 0;
2855            }
2856        }
2857    } catch (error) {
2858        console.error('CPNB: Failed to parse cpnb_cookiesSettings', error);
2859    }
2860
2861    return loadState === 'before' ? false : true;
2862}
2863
2864function cpnb_renderBlockCookieScripts(loadState) {
2865    // Retrieve cookie settings and check if a decision was made
2866    var settingsObj = cpnb_getConsentCookieValue('cpnb_cookiesSettings');
2867
2868    for (var catId in cpnb_cookiesCategories) {
2869        var category = cpnb_cookiesCategories[catId];
2870
2871        // Skip if the category is disabled
2872        if (category.cookie_category_status != 1) continue;
2873
2874        var categoryId = category.cookie_category_id;
2875        var checkedByDefault = category.cookie_category_checked_by_default;
2876
2877        var shouldRender = false;
2878
2879        if (!settingsObj) {
2880            // Logic for when no decision has been made yet
2881            if (loadState === 'before') {
2882                // "Load Before Consent" only for "No (allow change by User)" (0)
2883                shouldRender = checkedByDefault == 0;
2884            } else if (loadState === 'after') {
2885                // "Load After Consent" for "Yes (allow change)" (1) and "Yes (locked)" (2)
2886                shouldRender = checkedByDefault == 1 || checkedByDefault == 2;
2887            }
2888        } else {
2889            // Logic for after a decision (Accept/Decline) has been made
2890            var isAccepted =
2891                (settingsObj && settingsObj[categoryId] == 1) ||
2892                checkedByDefault == 2;
2893
2894            if (loadState === 'after') {
2895                // "Load After Consent" if the category is accepted or locked
2896                shouldRender = isAccepted;
2897            } else if (loadState === 'decline') {
2898                // "Load After Decline" if the category is declined and not locked
2899                shouldRender = !isAccepted && checkedByDefault != 2;
2900            }
2901        }
2902
2903        // Select all script placeholders for the current state and category
2904        var placeholders = document.querySelectorAll(
2905            '[data-cpnb-js][data-cpnb-load="' +
2906            loadState +
2907            '"][data-cpnb-category="' +
2908            categoryId +
2909            '"]'
2910        );
2911
2912        for (var i = 0; i < placeholders.length; i++) {
2913            var placeholder = placeholders[i];
2914            var isScriptPlaceholder =
2915                placeholder.tagName &&
2916                placeholder.tagName.toLowerCase() === 'script';
2917
2918            if (isScriptPlaceholder) {
2919                // Remove previously injected nodes for this placeholder
2920                if (placeholder._cpnbInjectedNodes) {
2921                    for (
2922                        var r = 0;
2923                        r < placeholder._cpnbInjectedNodes.length;
2924                        r++
2925                    ) {
2926                        var oldNode = placeholder._cpnbInjectedNodes[r];
2927                        if (oldNode && oldNode.parentNode) {
2928                            oldNode.parentNode.removeChild(oldNode);
2929                        }
2930                    }
2931                }
2932                placeholder._cpnbInjectedNodes = [];
2933            } else {
2934                placeholder.innerHTML = '';
2935            }
2936
2937            if (!shouldRender) continue;
2938
2939            var decoded = cpnb_decodeBlockCookiePayload(
2940                placeholder.getAttribute('data-cpnb-js')
2941            );
2942
2943            if (!decoded) continue;
2944
2945            // Inject the scripts into the placeholder
2946            var template = document.createElement('template');
2947            template.innerHTML = decoded;
2948            var fragment = document.createDocumentFragment();
2949            var nodes = template.content.childNodes;
2950
2951            for (var n = 0; n < nodes.length; n++) {
2952                var node = nodes[n];
2953                if (
2954                    node.nodeName &&
2955                    node.nodeName.toLowerCase() === 'script'
2956                ) {
2957                    var script = document.createElement('script');
2958                    if (node.attributes) {
2959                        for (var a = 0; a < node.attributes.length; a++) {
2960                            script.setAttribute(
2961                                node.attributes[a].name,
2962                                node.attributes[a].value
2963                            );
2964                        }
2965                    }
2966                    script.text = node.text || node.textContent || '';
2967                    fragment.appendChild(script);
2968                } else {
2969                    fragment.appendChild(node.cloneNode(true));
2970                }
2971            }
2972
2973            if (isScriptPlaceholder) {
2974                var parent = placeholder.parentNode;
2975                if (!parent) continue;
2976
2977                var injectedNodes = [];
2978                var childNodes = fragment.childNodes;
2979                for (var c = 0; c < childNodes.length; c++) {
2980                    injectedNodes.push(childNodes[c]);
2981                }
2982
2983                parent.insertBefore(fragment, placeholder.nextSibling);
2984                placeholder._cpnbInjectedNodes = injectedNodes;
2985            } else {
2986                placeholder.appendChild(fragment);
2987            }
2988        }
2989    }
2990}
2991
2992function cpnb_handleBlockCookieScripts() {
2993    // Check if a decision has already been made (cookies accepted or declined)
2994    var decisionMade = cpnb_hasConsentCookie('cpnb_cookiesSettings');
2995
2996    if (!decisionMade) {
2997        // Initial run where no decision has been made yet
2998        cpnb_renderBlockCookieScripts('before');
2999        cpnb_renderBlockCookieScripts('after');
3000    } else {
3001        // After a decision (Accept/Decline) or on subsequent page loads
3002        cpnb_renderBlockCookieScripts('after');
3003        cpnb_renderBlockCookieScripts('decline');
3004    }
3005}
3006
3007// Responsive left menu
3008function cpnb_toggle_responsive_menu(x) {
3009    x.classList.toggle('cpnb-toggle-menu-change');
3010
3011    if (
3012        document.getElementsByClassName('cpnb-manager-modal-left')[0].style
3013            .display == 'block'
3014    ) {
3015        document.getElementsByClassName(
3016            'cpnb-manager-modal-left'
3017        )[0].style.display = 'none';
3018    } else {
3019        document.getElementsByClassName(
3020            'cpnb-manager-modal-left'
3021        )[0].style.display = 'block';
3022    }
3023}
3024
3025function cpnb_toggle_responsive_menu_hide_menu() {
3026    if (window.innerWidth < 601) {
3027        document.getElementsByClassName(
3028            'cpnb-manager-modal-left'
3029        )[0].style.display = 'none';
3030    }
3031}
3032
3033function cpnb_fetchCookiesInfoTable() {
3034    var container = document.getElementById('cpnb-cit-container');
3035    if (!container || !container.getAttribute('data-cpnb-table-ajax')) {
3036        return;
3037    }
3038
3039    container.innerHTML = '<div class="cpnb-cit-spinner"></div>';
3040
3041    var baseUrl =
3042        typeof cpnb_config !== 'undefined' && cpnb_config.w357_base_ajax_url
3043            ? cpnb_config.w357_base_ajax_url
3044            : '';
3045
3046    var url =
3047        baseUrl +
3048        'index.php?option=com_ajax&plugin=cookiespolicynotificationbar&format=raw&method=getCookiesInfoTable&_=' +
3049        Date.now();
3050
3051    fetch(url)
3052        .then(function (response) {
3053            if (!response.ok) {
3054                throw new Error('CPNB: getCookiesInfoTable responded with ' + response.status);
3055            }
3056            return response.text();
3057        })
3058        .then(function (html) {
3059            container.innerHTML = html;
3060        })
3061        .catch(function (err) {
3062            console.error(err);
3063        });
3064}
3065
3066/**
3067 * TRIGGER EVENTS
3068 */
3069document.addEventListener('click', cpnb_handleActionButtonClick, false);
3070document.addEventListener('change', cpnb_handleLockedCheckboxChange, false);
3071document.addEventListener('change', cpnb_handleCategoryCheckboxChange, false);
3072document.addEventListener('DOMContentLoaded', cpnb_fetchCookiesInfoTable, false);
3073document.addEventListener('click', function (event) {
3074    var reloadBtn = event.target.closest('#cpnb-reload-btn-cit');
3075    if (!reloadBtn) {
3076        return;
3077    }
3078    event.preventDefault();
3079    cpnb_fetchCookiesInfoTable();
3080}, false);
3081
3082function sendPostRequest(url, params) {
3083    // Params should be an object containing key-value pairs
3084    let formData = new URLSearchParams(params).toString();
3085
3086    fetch(url, {
3087        method: 'POST',
3088        headers: {
3089            'Content-Type': 'application/x-www-form-urlencoded',
3090        },
3091        body: formData, // Sending the URL-encoded string
3092    })
3093        .then((response) => {
3094            if (!response.ok) {
3095                throw new Error('Network response was not ok');
3096            }
3097            // Reload the page after successful POST
3098            //window.location.reload();
3099        })
3100        .catch((error) => {
3101            console.error('Failed to send POST request:', error);
3102        });
3103}

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.