Skip to content

Commit

Permalink
TDW-2277 lint/duplicate code fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bosco-ensemble committed Apr 9, 2024
1 parent eb02e28 commit a57a677
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
9 changes: 4 additions & 5 deletions scripts/delayed.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,7 @@ export function initGigya() {
if (userButton) userButton.replaceWith(userButton.cloneNode(true));
const favoriteButtons = document.querySelectorAll('.leaderboard-favorite-button');
if (favoriteButtons) favoriteButtons.forEach((btn) => btn.replaceWith(btn.cloneNode(true)));
loadScript(
'https://cdns.gigya.com/JS/socialize.js?apikey=3__4H034SWkmoUfkZ_ikv8tqNIaTA0UIwoX5rsEk96Ebk5vkojWtKRZixx60tZZdob',
setupGigya,
loadScript('https://cdns.gigya.com/JS/socialize.js?apikey=3__4H034SWkmoUfkZ_ikv8tqNIaTA0UIwoX5rsEk96Ebk5vkojWtKRZixx60tZZdob', setupGigya,
);

Check failure on line 572 in scripts/delayed.js

View workflow job for this annotation

GitHub Actions / build

Unexpected newline before ')'
}

Expand Down Expand Up @@ -660,7 +658,8 @@ function getCookie(cookieName) {
return null;
}

async function OptanonWrapper() {
const OptanonWrapper = (async function() {

Check warning on line 661 in scripts/delayed.js

View workflow job for this annotation

GitHub Actions / build

Unexpected unnamed async function

Check failure on line 661 in scripts/delayed.js

View workflow job for this annotation

GitHub Actions / build

Missing space before function parentheses
console.log('test');

Check warning on line 662 in scripts/delayed.js

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
const geoInfo = window.Optanon.getGeolocationData();
Object.keys(geoInfo).forEach((key) => {
const cookieName = `PGAT_${key.charAt(0).toUpperCase() + key.slice(1)}`;
Expand All @@ -681,7 +680,7 @@ async function OptanonWrapper() {
}
}
sendAnalyticsPageEvent();
}
})

Check failure on line 683 in scripts/delayed.js

View workflow job for this annotation

GitHub Actions / build

Missing semicolon

export const loadAds = (function() {

Check warning on line 685 in scripts/delayed.js

View workflow job for this annotation

GitHub Actions / build

Unexpected unnamed function

Check failure on line 685 in scripts/delayed.js

View workflow job for this annotation

GitHub Actions / build

Missing space before function parentheses
const otId = placeholders.onetrustId;
Expand Down
17 changes: 1 addition & 16 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,6 @@ async function loadPage(doc) {
// eslint-disable-next-line no-use-before-define
await loadLazy(doc);
// eslint-disable-next-line no-use-before-define
loadAds();
// eslint-disable-next-line no-use-before-define
loadDelayed(doc);
}

Expand Down Expand Up @@ -1076,6 +1074,7 @@ async function loadLazy(doc) {
addFavIcon(`${window.hlx.codeBasePath}/styles/favicon.ico`);

doc.querySelectorAll('div:not([class]):not([id]):empty').forEach((empty) => empty.remove());
loadAds();
}

/**
Expand Down Expand Up @@ -1140,20 +1139,6 @@ function getPageNameAndSections() {
};
}

/* setup cookie preferences */
function getCookie(cookieName) {
const name = `${cookieName}=`;
const decodedCookie = decodeURIComponent(document.cookie);
const split = decodedCookie.split(';');
// eslint-disable-next-line no-plusplus
for (let i = 0; i < split.length; i++) {
let c = split[i];
while (c.charAt(0) === ' ') c = c.substring(1);
if (c.indexOf(name) === 0) return c.substring(name.length, c.length);
}
return null;
}

export async function sendAnalyticsPageEvent() {
window.dataLayer = window.dataLayer || [];
const dl = window.dataLayer;
Expand Down

0 comments on commit a57a677

Please sign in to comment.