PageSourceSearch

https://palafrugell.cat/plugins/system/cookiespolicynotificationba…cy-notification-bar.min.js?v=20260728173825

js palafrugell.cat collected 2026-10-02 11:34:59 UTC 133,596 bytes, 3,190 lines download raw bytes

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

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.