(function() {
'use strict';
// Prevent multiple initializations
if (window.adManagerInitialized) {
return;
}
window.adManagerInitialized = true;
class AdManager {
constructor() {
this.config = {
prebidTimeout: 1500,
cpmMarginPercent: parseInt(window.cpmMarginPercent) || 0,
showLogs: window.cis_show_logs || false
};
this.pixel = {
adsAmountValue: 0,
lastSentValue: 0,
eventFired: 0,
smallEventFired: 0,
smallEvents: [1, 2, 2.5, 3, 4, 5, 6, 7, 7.5, 8, 9]
};
this.doneAuctionsWins = window.doneAuctionsWins || [];
this.isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
this.isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
// Initialize immediately
this.init().catch(error => {
this.log('AdManager initialization error:', error);
});
}
async init() {
try {
this.setupPreconnections();
this.setupAnalytics();
await this.waitForDocumentReady();
await this.loadScripts();
this.setupEventListeners();
this.setupFacebookPixel();
this.log('AdManager initialized successfully');
} catch (error) {
this.log('Error during initialization:', error);
}
}
setupPreconnections() {
const preconnectUrls = [
'https://fonts.gstatic.com',
'https://adservice.google.com',
'https://tpc.googlesyndication.com',
'https://securepubads.g.doubleclick.net',
'https://pagead2.googlesyndication.com',
'https://pubads.g.doubleclick.net',
'https://www.google-analytics.com',
'https://www.googletagservices.com',
'https://c.amazon-adsystem.com',
'https://aax.amazon-adsystem.com',
'https://connect.facebook.net'
];
preconnectUrls.forEach(url => {
try {
const link = document.createElement('link');
link.rel = 'preconnect';
link.href = url;
document.head.appendChild(link);
} catch (error) {
this.log('Error adding preconnect for', url, error);
}
});
}
setupAnalytics() {
try {
window.assertiveQueue = window.assertiveQueue || [];
window.assertiveQueue.push(() => {
if (window.assertive && window.assertive.analytics && window.assertive.analytics.custom) {
window.assertive.analytics.custom.custom_6 = "AY_wrapper";
window.assertive.analytics.custom.custom_4 = 'Layout_' + (window.ads_layout || 'unknown');
}
});
} catch (error) {
this.log('Error setting up analytics:', error);
}
}
async waitForDocumentReady() {
return new Promise((resolve) => {
if (document.readyState === "interactive" || document.readyState === "complete") {
resolve();
return;
}
const checkInterval = setInterval(() => {
if (document.readyState === "interactive" || document.readyState === "complete") {
clearInterval(checkInterval);
resolve();
}
}, 20);
});
}
loadAdWrapperScript() {
try {
const script = document.createElement("script");
script.src = "https://jk3yfTwHczNirJfKt.ay.delivery/manager/jk3yfTwHczNirJfKt";
script.referrerPolicy = "no-referrer-when-downgrade";
document.head.appendChild(script);
} catch (error) {
this.log('Error loading ad wrapper script:', error);
}
}
async loadScripts() {
try {
// Load ad wrapper
this.loadAdWrapperScript();
// Load Facebook pixel noscript
this.setupFacebookNoscript();
// Load P1 script
await this.loadP1Script();
// Set prebid timeout
window.PREBID_TIMEOUT = this.config.prebidTimeout;
} catch (error) {
this.log('Error loading scripts:', error);
}
}
setupFacebookNoscript() {
try {
const noscript = document.createElement("noscript");
const img = document.createElement("img");
img.height = "1";
img.width = "1";
img.style.display = "none";
img.src = "https://www.facebook.com/tr?id=1581007252192655&ev=PageView&noscript=1";
noscript.appendChild(img);
document.head.appendChild(noscript);
} catch (error) {
this.log('Error setting up Facebook noscript:', error);
}
}
async loadP1Script() {
return new Promise((resolve) => {
try {
const script = document.createElement("script");
script.id = "script_p1";
script.src = "https://cdn.historycollection.com/wp-content/uploads/2024/03/p1.js";
script.onload = () => resolve();
script.onerror = () => resolve(); // Continue even if script fails
document.head.appendChild(script);
// Fallback timeout
setTimeout(resolve, 5000);
} catch (error) {
this.log('Error loading P1 script:', error);
resolve();
}
});
}
setupFacebookPixel() {
try {
// Initialize pixel globals
window.pixel_ads_amount_value = this.pixel.adsAmountValue;
window.pixel_last_sent_value = this.pixel.lastSentValue;
window.pixel_event_fired = this.pixel.eventFired;
window.pixel_small_event_fired = this.pixel.smallEventFired;
window.pixel_small_events = this.pixel.smallEvents;
} catch (error) {
this.log('Error setting up Facebook pixel:', error);
}
}
setupEventListeners() {
try {
// Revenue tracking
window.addEventListener("assertive_predictedRevenue", (event) => {
this.handlePredictedRevenue(event);
}, false);
// Impression logging
window.addEventListener("assertive_logImpression", (event) => {
this.handleLogImpression(event);
});
} catch (error) {
this.log('Error setting up event listeners:', error);
}
}
handlePredictedRevenue(event) {
try {
const data = event.data;
if (!data || !data.predictedRevenueCPM) {
return;
}
let winnerCPM = data.predictedRevenueCPM.impression;
if (winnerCPM === 0) return;
this.log("assertive_predictedRevenue", window.assertive && window.assertive.analytics && window.assertive.analytics.custom ? window.assertive.analytics.custom.custom_6 : 'unknown', winnerCPM);
// Update aggregated value and send pixel events
this.sendPurchaseAggregatedValue(winnerCPM);
// Apply margin if configured
if (this.config.cpmMarginPercent > 0) {
winnerCPM = winnerCPM - (winnerCPM * this.config.cpmMarginPercent) / 100;
}
if (winnerCPM < 0) return;
// Prepare Facebook pixel data
const fbPixelData = {
value: winnerCPM,
currency: "USD",
content_ids: window.location.href.split("/")[3] || '',
content_type: "Product",
bidder: "Google",
adUnit: data.meta ? data.meta.slotId : '',
};
// Determine winner and platform
const winnerInfo = this.determineWinner(data);
// Report to external systems
this.reportWin({
biddingPlatformId: winnerInfo.biddingPlatformId,
partnerAuctionId: data.meta ? data.meta.auctionId : '',
bidderCode: winnerInfo.winner,
prebidAuctionId: data.meta ? data.meta.auctionId : '',
cpm: winnerCPM,
currency: "USD",
originalCpm: winnerCPM,
originalCurrency: "USD",
status: "rendered",
placementId: data.meta ? data.meta.slotId : '',
});
// Send Facebook pixel event
if (typeof fbq !== "undefined") {
fbq("track", "Purchase", fbPixelData);
}
// Update analytics
this.updateAnalytics();
} catch (error) {
this.log('Error handling predicted revenue:', error);
}
}
determineWinner(data) {
let biddingPlatformId = 3; // Default to Google
let winner = "Google";
try {
if (data.meta && data.meta.dfpResponseInformation) {
const advertiserId = data.meta.dfpResponseInformation.advertiserId;
if (advertiserId === 4566943199) {
biddingPlatformId = 1; // Prebid
winner = data.meta.highestBid ? data.meta.highestBid.bidderCode : winner;
} else if (advertiserId === 4726541655) {
biddingPlatformId = 2; // Amazon
winner = "amazon";
}
}
} catch (error) {
this.log('Error determining winner:', error);
}
return { winner: winner, biddingPlatformId: biddingPlatformId };
}
sendPurchaseAggregatedValue(winnerCPM) {
try {
this.pixel.adsAmountValue += winnerCPM;
window.pixel_ads_amount_value = this.pixel.adsAmountValue;
if (typeof fbq === "undefined") return;
// Process small events
this.processSmallEvents();
// Process $10 increments
this.processIncrementalEvents();
// Process milestone events
this.processMilestoneEvents();
} catch (error) {
this.log('Error sending purchase aggregated value:', error);
}
}
processSmallEvents() {
try {
this.pixel.smallEvents.forEach((threshold, index) => {
if (this.pixel.smallEventFired <= index && this.pixel.adsAmountValue > threshold) {
this.pixel.smallEventFired++;
window.pixel_small_event_fired = this.pixel.smallEventFired;
const eventName = (threshold / 10) + "R" + (window.site_prefix || '');
this.sendCustomEvent(eventName, {
currency: "USD",
value: threshold,
});
}
});
} catch (error) {
this.log('Error processing small events:', error);
}
}
processIncrementalEvents() {
try {
while (
this.pixel.adsAmountValue > 10 &&
this.pixel.adsAmountValue < 310 &&
this.pixel.adsAmountValue > this.pixel.lastSentValue + 10
) {
this.pixel.lastSentValue += 10;
window.pixel_last_sent_value = this.pixel.lastSentValue;
const eventName = (this.pixel.lastSentValue / 10) + "R" + (window.site_prefix || '');
this.sendCustomEvent(eventName, {
currency: "USD",
value: this.pixel.lastSentValue,
});
}
} catch (error) {
this.log('Error processing incremental events:', error);
}
}
processMilestoneEvents() {
try {
const milestones = [
{ threshold: 30, event: "HC_30" },
{ threshold: 50, event: "HC_50" },
{ threshold: 80, event: "HC_80" },
{ threshold: 100, event: "HC_100" }
];
milestones.forEach((milestone, index) => {
if (this.pixel.adsAmountValue > milestone.threshold && this.pixel.eventFired === index) {
this.pixel.eventFired++;
window.pixel_event_fired = this.pixel.eventFired;
this.sendCustomEvent(milestone.event, {
currency: "USD",
value: this.pixel.adsAmountValue,
});
}
});
} catch (error) {
this.log('Error processing milestone events:', error);
}
}
sendCustomEvent(eventName, data) {
try {
if (typeof fbq !== "undefined") {
fbq("trackCustom", eventName, data);
}
if (typeof cis_send_custom_event !== "undefined") {
cis_send_custom_event(eventName, data);
}
} catch (error) {
this.log('Error sending custom event:', error);
}
}
handleLogImpression(event) {
try {
const payload = event.data ? event.data.payload : null;
if (!payload) return;
const mediaType = (payload.highestBid && payload.highestBid.mediaType) || "banner";
if (payload.unfilled || payload.sourceInternal !== "gpt") {
return;
}
// Apply iOS bias for banner ads
if (mediaType === "banner" && this.isIOS) {
payload.revenueBias = 0.975;
}
} catch (error) {
this.log('Error handling log impression:', error);
}
}
reportWin(winData) {
try {
// Report to IntentIQ (if not Chrome)
if (!this.isChrome && typeof intentIq_612283370 !== "undefined" && intentIq_612283370.reportExternalWin) {
intentIq_612283370.reportExternalWin(winData);
}
} catch (error) {
this.log('Error reporting win:', error);
}
}
updateAnalytics() {
try {
if (typeof intentIq_612283370 !== "undefined" && intentIq_612283370.intentIqConfig) {
const testGroup = intentIq_612283370.intentIqConfig.abTesting ? intentIq_612283370.intentIqConfig.abTesting.currentTestGroup : null;
if (window.assertive && window.assertive.analytics && window.assertive.analytics.custom) {
window.assertive.analytics.custom.custom_8 = testGroup === "A" ? "IIQ_Enabled" : "IIQ_Disabled";
}
if (testGroup === "A") {
window.iiqCallbackMethod_init = true;
}
}
} catch (error) {
this.log('Error updating analytics:', error);
}
}
log() {
if (this.config.showLogs && typeof console !== 'undefined' && console.log) {
try {
console.log.apply(console, arguments);
} catch (e) {
// Silent fail if console is not available
}
}
}
}
// Initialize the ad manager
try {
window.adManager = new AdManager();
} catch (error) {
if (typeof console !== 'undefined' && console.error) {
console.error('Failed to initialize AdManager:', error);
}
}
// Add Impact site verification meta tag
try {
const metaTag = document.createElement('meta');
metaTag.name = 'impact-site-verification';
metaTag.content = 'bd46cba2-8f9e-4fd2-97e3-030369b052ff';
document.head.appendChild(metaTag);
} catch (error) {
if (typeof console !== 'undefined' && console.error) {
console.error('Failed to add meta tag:', error);
}
}
})();
40 Violent Realities in the Making of the British Empire
Larry Holzwarth - March 25, 2019
At its height, the British Empire encompassed nearly a quarter of the land mass of the globe, and held sway over almost a quarter of the world’s population. It was the largest empire in history. Its economic might made Great Britain the world’s economic powerhouse, but it had rivals in Asia, Africa, North America, and the Indian subcontinent. It was through the might of the empire that Great Britain survived the World Wars of the first half of the twentieth century… but at a cost. Which made the empire no longer sustainable, and by the end of that century, Great Britain’s influence as a global superpower was gone. Here are 40 historical facts about the empire that it once was and the influence on global affairs it once presented.
1. It was born through privateering and piracy against Spain.
The British sea raiders such as Sir Francis Drake captured ships of the Dutch and Spanish returning from the Indies and the New World. Wikimedia
The British Empire was born before the United Kingdom of England and Scotland was formed – with the raiding of Spanish treasure ships from the New World, and the attacks on slave ships off the coast of Africa. Spain was the world’s dominant power, with both Portugal and Spain establishing colonies and trading stations in the Americas and along the African coasts. Throughout the 16th century English ships raided Spanish possessions, often in acts which were clearly piracy, though thinly veiled as privateering. They were protected by letters of marque from the English throne. Late in the sixteenth century, the English established their first colony in the New World, Roanoke, but it did not survive.