(function () { function addLabel(target, text) { const div = document.createElement('div'); div.id = target.id + '-label'; div.className = 'nif-ad-label'; div.style.font = '12px Arial, Calibri'; div.style.color = '#595959'; div.style.width = '100%'; div.style.textAlign = 'center'; div.style.margin = '5px 0'; div.innerHTML = text; target.prepend(div); } function nifGetAppropriateSizes(targetId) { const target = document.getElementById(targetId); // List of target IDs that should exclude the 980x600 size const excludeLargeAdTargets = ['nif-bunnbanner', 'nif-toppbanner']; // Add more IDs as needed const viewportWidth = target.parentElement.offsetWidth; let allSizes = [ [980, [[980, 300], [980, 600]]], [580, [[580, 400]]], [320, [[320, 250], [320, 400]]] ]; if (excludeLargeAdTargets.includes(targetId)) { allSizes = allSizes.filter(size => !(size[0] === 980 && size[1] === 600)); } return allSizes.find(size => size[0] <= viewportWidth)[1]; } function nifCreateAdRequest(adConfigs, adOptions) { const adUnits = []; for (const placement of adConfigs) { try { const target = document.getElementById(placement[0]); if (target) { adUnits.push({ targetId: placement[0] + '-child', auId: placement[1], dimensions: nifGetAppropriateSizes(placement[0]), onImpressionResponse: function (data) { // Check if an ad was actually delivered if (data.ads[0]) { if (adOptions && adOptions.adLabel) { addLabel(target, adOptions.adLabel); } } } }); target.style.width = "100%"; target.style.display = 'flex'; target.style.flexDirection = 'column'; target.style.justifyContent = 'center'; const div = document.createElement('div'); div.id = placement[0] + '-child'; div.style.display = "none"; target.appendChild(div); } } catch (e) { console.log("can't generate request for" + placement[0]); } } return adUnits } window.nifRequestAds = function (adConfigs, adOptions) { adn.calls.push(function () { const adUnits = nifCreateAdRequest(adConfigs, adOptions); adn.request({ network: '140f2f', adUnits: adUnits }); }); } var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://cdn.adnuntius.com/adn.js'; script.async = true; document.head.appendChild(script); })()