diff --git a/scripts/scripts.js b/scripts/scripts.js index 5bf99be3..0d2eda66 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -1158,6 +1158,20 @@ export async function sendAnalyticsPageEvent() { }); } +/* 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; +} + async function OptanonWrapper() { const geoInfo = window.Optanon.getGeolocationData(); Object.keys(geoInfo).forEach((key) => { @@ -1181,20 +1195,6 @@ async function OptanonWrapper() { await sendAnalyticsPageEvent(); } -/* 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; -} - async function loadAds(doc) { const placeholders = await fetchPlaceholders(); const isProd = window.location.hostname.endsWith(placeholders.hostname); @@ -1256,4 +1256,3 @@ try { }, }); } catch (e) { /* ignore */ } -