Skip to content

Commit

Permalink
Update cookie-consent.js
Browse files Browse the repository at this point in the history
Codacy comments
  • Loading branch information
m-lilja authored Dec 22, 2023
1 parent 2f1dbcb commit 48f11d4
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions assets/js/cookie-consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,31 @@ function activateClarity() {
})(window, document, "clarity", "script", "jd3awxna38");
}

function deleteCookie(name) {
if (getCookie(name)) {

Check notice on line 12 in assets/js/cookie-consent.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

assets/js/cookie-consent.js#L12

'getCookie' was used before it was defined.
document.cookie = name + "=;domain=.swedbankpay.com;path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT";
}
}

function inactivateClarityCookies() {
deleteCookie("_clck");
deleteCookie("_clsk");
}

function getCookie(name) {
if (document.cookie.split(';').some(c => c.trim().startsWith(name + '='))) {
return document.cookie.split(';').find(c => c.trim().startsWith(name + '='));
if (document.cookie.split(";").some((c) => c.trim().startsWith(name + "="))) {
return document.cookie.split(";").find((c) => c.trim().startsWith(name + "="));
}
else
else {
return false;
}

function deleteCookie(name) {
if (getCookie(name)) {
document.cookie = name + "=;domain=.swedbankpay.com;path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT";
}
}

window.addEventListener("OneTrustGroupsUpdated", event => {
if (event.detail.indexOf("C0002") !== -1)
window.addEventListener("OneTrustGroupsUpdated", (event) => {
if (event.detail.indexOf("C0002") !== -1) {
activateClarity();
else
}
else {
inactivateClarityCookies();
}
});

0 comments on commit 48f11d4

Please sign in to comment.