Skip to content

Commit 50850b0

Browse files
committed
Refactor js_code.phtml
1 parent 705f3a7 commit 50850b0

File tree

1 file changed

+17
-38
lines changed

1 file changed

+17
-38
lines changed

view/frontend/templates/js_code.phtml

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,23 @@ $script = '';
4343

4444
<?php if ($block->isProtectCustomerDataEnabled()) { ?>
4545
<?php
46-
$script .= "
47-
window.dataLayer = window.dataLayer || [];
48-
function gtag() { dataLayer.push(arguments); }
49-
";
50-
5146
if (!$block->isMfCookieConsentExtensionEnabled()) {
5247
$script .= "
48+
window.dataLayer = window.dataLayer || [];
49+
function gtag() { dataLayer.push(arguments); }
5350
gtag('consent', 'default', {
54-
'ad_user_data': 'denied',
55-
'ad_personalization': 'denied',
56-
'ad_storage': 'denied',
57-
'analytics_storage': 'denied',
58-
/* cookieyes.com start */
59-
60-
'functionality_storage': 'denied',
61-
'personalization_storage': 'denied',
62-
'security_storage': 'granted',
63-
/* cookieyes.com end */
64-
65-
'wait_for_update': 2000
51+
'ad_user_data': 'denied',
52+
'ad_personalization': 'denied',
53+
'ad_storage': 'denied',
54+
'analytics_storage': 'denied',
55+
/* cookieyes.com start */
56+
57+
'functionality_storage': 'denied',
58+
'personalization_storage': 'denied',
59+
'security_storage': 'granted',
60+
/* cookieyes.com end */
61+
62+
'wait_for_update': 2000
6663
});
6764
/* cookieyes.com start */
6865
gtag('set', 'ads_data_redaction', true);
@@ -82,30 +79,12 @@ $script = '';
8279
<?php if ($block->isCookieRestrictionModeEnabled()) { ?>
8380
<?php $script .= "
8481
(function () {
85-
function getCookieValue(cookieName) {
86-
let name = cookieName + '=';
87-
let cookieSplit = document.cookie.split(';');
88-
89-
for (let i = 0; i < cookieSplit.length; i++) {
90-
let a = cookieSplit[i];
91-
92-
while (a.charAt(0) === ' ') {
93-
a = a.substring(1);
94-
}
95-
96-
if (a.indexOf(name) === 0) {
97-
return a.substring(name.length, a.length);
98-
}
99-
}
100-
return '';
101-
};
10282
10383
function customerDataAllowed() {
104-
if (MagefanJs.getCookie('mf_cookie_consent') === '1') {
84+
if (MagefanJs.getCookie('mf_cookie_consent')) {
10585
return true;
106-
}
107-
108-
let cookie = getCookieValue(
86+
};
87+
let cookie = MagefanJs.getCookie(
10988
'{$escaper->escapeHtml(\Magento\Cookie\Helper\Cookie::IS_USER_ALLOWED_SAVE_COOKIE)}'
11089
);
11190
if (cookie) {

0 commit comments

Comments
 (0)