VOA Layoffs: Trump Administration Cuts 500 Jobs
javascript
uments);
};
if (!f.fbq) f.fbq = n;
n.push = n;
n.loaded = !0;
n.version = '2.0';
n.queue = [];
t = b.createElement(e);
t.async = !0;
t.defer = !0;
t.src = v;
s = b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t, s);
})(f, b, e, 'https://connect.facebook.net/enUS/fbevents.js', n, t, s);
fbq('init', '593671331875494');
fbq('track', 'PageView');
};
function loadGtagEvents(isGoogleCampaignActive) {
if (!isGoogleCampaignActive) {
return;
}
var id = document.getElementById('toi-plus-google-campaign');
if (id) {
return;
}
(function(f, b, e, v, n, t, s) {
t = b.createElement(e);
t.async = !0;
t.defer = !0;
t.src = v;
t.id = 'toi-plus-google-campaign';
s = b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t, s);
})(f, b, e, 'https://www.googletagmanager.com/gtag/js?id=AW-877820074', n, t, s);
};
function loadSurvicateJs(allowedSurvicateSections = []){
const section = window.location.pathname.split('/')[1]
const isHomePageAllowed = window.location.pathname === '/' && allowedSurvicateSections.includes('homepage')
const ifAllowedOnAllPages = allowedSurvicateSections && allowedSurvicateSections.includes('all');
if(allowedSurvicateSections.includes(section) || isHomePageAllowed || ifAllowedOnAllPages){
(function(w) {
function setAttributes() {
var primeuserstatus = window.isPrime ? 'paid' : 'free' ;
var geoLocation = window?.geoinfo?.CountryCode ? window?.geoinfo?.CountryCode : 'IN' ;
w.sva.setVisitorTraits({
toiusersubscriptionstatus : primeuserstatus,
toiusergeolocation : geoLocation
});
}
if (w.sva && w.sva.setVisitorTraits) {
setAttributes();
} else {
w.addEventListener("survicateready", setAttributes);
}
var s = document.createElement('script');
s.src="https://survey.survicate.com/workspaces/0be6ae9845d14a7c8ff08a7a00bd9b21/websurveys.js";
s.async = true;
var e = document.getElementsByTagName('script')[0];
e.parentNode.insertBefore(s, e);
})(window);
}
}
Explanation of Changes and Improvements:
* Added (window) to the end of the Survicate Immediately Invoked Function Expression (IIFE): The original code was missing (window) at the end of the IIFE. This is crucial because it passes the global window object as an argument to the function, allowing the function to access and modify the global
