console.log("=== OPTILOAD CONFIG: 20181120 ==="); console.log("=== PB/OPTILOAD 1.31.0/1.2.0 ==="); /* window.Adomik = window.Adomik || {}; Adomik.randomAdGroup = function () { var rand = Math.random(); switch (false) { case !(rand < 0.09): return "ad_ex" + (Math.floor(100 * rand)); case !(rand < 0.10): return "ad_bc"; default: return "ad_opt"; } }; */ var googletag = googletag || {}; googletag.cmd = googletag.cmd || []; googletag.cmd.push(function () { googletag.pubads().enableSingleRequest(); googletag.pubads().disableInitialLoad(); googletag.pubads().collapseEmptyDivs(true); googletag.enableServices(); }); var pbjs = pbjs || {}; pbjs.que = pbjs.que || []; var Optiload = {}; Optiload.adUnits = (function ($) { Optiload.isMobile = function () { return $(window).width() < 980; } var adUnits = []; adUnits[1] = { name: '/5966054/DimensioneB/DimensioneB_ATF', sizes: [[300, 250], [336,280],'fluid'], lazy: false, mappings:{ desktop: [[300, 250],[336,280],'fluid'], mobile: [[300,250],'fluid'] }, hb: { sizes: [[300, 250]], bids:[ { bidder:'adform', params:{ mid: '622689'} }, { bidder: 'appnexusAst', params: { placementId: '14416024'} }, { bidder: 'openx', params: { unit: '540469813', delDomain: 'evolution-d.openx.net'} }, { bidder: 'rubicon', params: { accountId: "17322", siteId:"227454", zoneId: "1120782", sizes: [15,16]} }, { bidder: 'smartadserver', params: {siteId: 273638, domain:'https://prg.smartadserver.com',pageId:1020029, formatId:58998} } ] }, hbmobile:{ sizes: [[300, 250]], bids:[ { bidder:'adform', params:{ mid: '622689'} }, { bidder: 'appnexusAst', params: { placementId: '14416024'} }, { bidder: 'openx', params: { unit: '540469813', delDomain: 'evolution-d.openx.net'} }, { bidder: 'rubicon', params: { accountId: "17322", siteId:"227456", zoneId: "1120794", sizes: [15]} }, { bidder: 'smartadserver', params: {siteId: 273638, domain:'https://prg.smartadserver.com',pageId:1020029, formatId:58999} } ] } }; adUnits[2] = { name: '/5966054/DimensioneB/DimensioneB_intext3', sizes: [[300, 250],[336,280],'fluid'], lazy: true, mappings:{ desktop: [[300,250],[336,280],'fluid'], mobile: [[300,250],'fluid'] }, hb: { sizes: [[300, 250],[336,280]], bids:[ { bidder:'adform', params:{ mid: '622690'} }, { bidder: 'appnexusAst', params: { placementId: '14416025'} }, { bidder: 'openx', params: { unit: '540469814', delDomain: 'evolution-d.openx.net'} }, { bidder: 'rubicon', params: { accountId: "17322", siteId:"227454", zoneId: "1120788", sizes: [15,16]} }, { bidder: 'smartadserver', params: {siteId: 273638, domain:'https://prg.smartadserver.com',pageId:1020029, formatId:58993} } ] }, hbmobile:{ sizes: [[300, 250]], bids:[ { bidder:'adform', params:{ mid: '622690'} }, { bidder: 'appnexusAst', params: { placementId: '14416025'} }, { bidder: 'openx', params: { unit: '540469814', delDomain: 'evolution-d.openx.net'} }, { bidder: 'rubicon', params: { accountId: "17322", siteId:"227456", zoneId: "1120796", sizes: [15]} }, { bidder: 'smartadserver', params: {siteId: 273638, domain:'https://prg.smartadserver.com',pageId:1020029, formatId:58994} } ] } }; adUnits[4] = { name: '/5966054/DimensioneB/DimensioneB_sidebarTop', sizes: [[300, 250],'fluid'], lazy: true, mappings:{ desktop: [[300,250],'fluid'], mobile: [[300,250],'fluid'] }, hb: { sizes: [[300, 250]], bids:[ { bidder:'adform', params:{ mid: '622691'} }, { bidder: 'appnexusAst', params: { placementId: '14416027'} }, { bidder: 'openx', params: { unit: '540469815', delDomain: 'evolution-d.openx.net'} }, { bidder: 'rubicon', params: { accountId: "17322", siteId:"227454", zoneId: "1120790", sizes: [15]} }, { bidder: 'smartadserver', params: {siteId: 273638, domain:'https://prg.smartadserver.com',pageId:1020029, formatId:58998} } ] }, hbmobile:{ sizes: [[300, 250]], bids:[ { bidder:'adform', params:{ mid: '622691'} }, { bidder: 'appnexusAst', params: { placementId: '14416027'} }, { bidder: 'openx', params: { unit: '540469815', delDomain: 'evolution-d.openx.net'} }, { bidder: 'rubicon', params: { accountId: "17322", siteId:"227456", zoneId: "1120798", sizes: [15]} }, { bidder: 'smartadserver', params: {siteId: 273638, domain:'https://prg.smartadserver.com',pageId:1020029, formatId:58999} } ] } }; return adUnits; }(jQuery)); (function ($, Optiload) { Optiload.bus = $({}); Optiload.sm = null; var cmp_loaded = false; var prebid_loaded = false; var optiload_loaded = false; include_js("https://assets.evolutionadv.it/confiant/confiant.js", function () {}); include_js("https://assets.evolutionadv.it/cmp/pubmatic/cmp.complete.bundle.js",function(){ cmp_loaded = true; startOptiload(); }); include_js("https://assets.evolutionadv.it/prebid/1.31.0/prebid.min.js", function () { pbjs.setConfig({ cache: { url: "https://prebid.adnxs.com/pbc/v1/cache" }, // "currency": { // "adServerCurrency": "JPY", /* Enables currency feature -- loads the rate file */ // "conversionRateFile": "url" // Allows the publisher to override the default rate file // }, "debug": false, // Previously `logging` endpoint: "https://prebid.adnxs.com/pbs/v1/auction", syncEndpoint: "https://prebid.adnxs.com/pbs/v1/cookie_sync", // "s2sConfig" : { // accountId : 'ae2fd2d6-deab-4262-bf76-bc7ef4ab7d87', //string:required: account ID obtained in step 1 // enabled : true, //boolean:required: enables s2s - default false // bidders : ['pubmatic','rubicon'], //array[string]:required: of bidder codes to enable S2S. // //Note these must have been including in the Prebid.js build from Step 2. // timeout : 600, //number:optional timeout in ms for bidders called via the S2S endpoint. // //default value is 1000 // //adapter : 'prebidServer', //string:optional: Adapter code for S2S code. Defaults to 'prebidServer' // cookieSet : true //boolean:optional: If 'false' (not recommended), opt out of link rewriting // //and cookie-setting that allow a persistent cookie for improved cookie // //match rates. // }, consentManagement: { cmpApi: 'iab', timeout: 60000, allowAuctionWithoutConsent: false }, "priceGranularity": "high", "enableSendAllBids": true, // Default will be `true` as of 1.0 "bidderSequence": "random", "bidderTimeout": 1200, // Default for all requests. "publisherDomain": "dimensioneb.it", // Used for SafeFrame creative. //By default, Prebid.js version 0.34.0+ turns off user syncing through iframes. //OpenX strongly recommends enabling user syncing through iframes. //This functionality improves DSP user match rates and increases the OpenX bid rate and bid price. // Be sure to call pbjs.setConfig() only once. "userSync": { iframeEnabled: true, enabledBidders: ['pubmatic','openx'], syncDelay: 6000 }, "cookieSyncDelay": 100 }); prebid_loaded = true; startOptiload(); }); include_js("https://assets.evolutionadv.it/optiload/1.2.0/optiload.min.js", function () { optiload_loaded = true; startOptiload(); }); function include_js(file, callback) { var js = null; var loaded = false; var head = document.getElementsByTagName('head')[0]; js = document.createElement('script'); js.setAttribute('type', 'text/javascript'); js.setAttribute('src', file); head.appendChild(js); js.onreadystatechange = function () { if (js.readyState == 'complete' && !loaded) { loaded = true; if (callback) { callback(); } } } js.onload = function () { if (!loaded) { loaded = true; if (callback) { callback(); } } } return false; } function startOptiload() { if (!cmp_loaded || !prebid_loaded || !optiload_loaded) { return; } Optiload.sm = new slotManager.SlotManager(Optiload.adUnits, { intervalInactivity: 50 }); $(function () { //Optiload.bus.trigger("optiload_ready"); //se le adUnit sono caricate da fuori commento questo metodo loadAdUnits(); //loadFloorad(6); //idFloorad //loadSpotx(); //loadSkin(7); // idSkin }); } function loadAdUnits() { insertBanner(); var slots = []; var divAdv = jQuery(".gptslot").filter(function () { return (jQuery(this).data('addesktop') == undefined && jQuery(this).data('admobile') == undefined) || jQuery(this).data('addesktop') == "1"; }); if (Optiload.isMobile()) { divAdv = jQuery(".gptslot").filter(function () { return (jQuery(this).data('addesktop') == undefined && jQuery(this).data('admobile') == undefined) || jQuery(this).data('admobile') == "1"; }); } //mod campagna febbraio 2018 var intextIdSlot = 2; $gptslots = jQuery(divAdv).filter(function () { return jQuery(this).data("adunitid") != intextIdSlot; }); $gptneltesto = jQuery(divAdv).filter(function () { return jQuery(this).data("adunitid") == intextIdSlot; }); /* jQuery.each($gptslots, function () { slots.push({slot:$(this),targeting:[ {key:"ad_group",value:Adomik.randomAdGroup()}, {key:"ad_h",value:(new Date).getUTCHours().toString()} ]}); }); */ Optiload.sm.addSlots($gptslots); var gptneltestocounter = 1; jQuery.each($gptneltesto, function () { slots.push({slot:$(this),targeting:[ //{key:"ad_group",value:Adomik.randomAdGroup()}, //{key:"ad_h",value:(new Date).getUTCHours().toString()}, { key: "gptneltesto", value: gptneltestocounter.toString() } ]}); gptneltestocounter++; }); Optiload.sm.addSlotsWithTargeting(slots); } function insertBanner() { var $texte = jQuery(".post_header.single").last(); if ($texte.length > 0) { var $p = $texte.find("p"); var limit = $texte.data("banner") || 100; var currentLimit = limit; var wordCount = 0; var count = Date.now() + 1; var $pAndImg = $texte.find("p, img"); for (var i = 0; i < $pAndImg.length; i++) { var $node =jQuery( $pAndImg[i]); if ($node.is("p")) { wordCount += $node.text().split(' ').length; if (wordCount > currentLimit) { var j = i + 1; var found = false; while (j < $pAndImg.length && !found) { if (jQuery($pAndImg[j]).is("p:not(.toc)") && jQuery($pAndImg[j]).text().trim().length > 0 ) { found = true; jQuery($pAndImg[j]).before( "
" ); } j++; } count++; wordCount = 0; } } } } } function loadSkin(idSkin) { $(document).ready(function () { var skin = null; $("body").append('
'); googletag.cmd.push(function () { skin = googletag.defineSlot(Optiload.adUnits[idSkin].name, Optiload.adUnits[idSkin].sizes, 'optiload-skin') //.setTargeting('ad_group', Adomik.randomAdGroup()) //.setTargeting('ad_h', (new Date).getUTCHours().toString()) .addService(googletag.pubads()); googletag.display('optiload-skin'); googletag.pubads().refresh([skin]); }); $("body").on("refreshskin", function () { googletag.cmd.push(function () { $("#GenecyDFPAdWallpaperCont").remove(); googletag.pubads().refresh([skin]); //console.log("skin refresh"); }); }); }); } function loadFloorad(idFloorad) { var css = "\ #floor-ad-wrapper {\ background: #fff!important;\ position: fixed;\ z-index: 99999;\ width: 100%;\ text-align: center;\ bottom: -294px;\ }\ .cont-floor {\ background: transparent;\ margin: 0 auto;\ position: relative;\ }\ #close {\ margin:0!important; font-size:13px!important;line-height:1.3;\ right: 0px;\ top: -22px;\ padding: 0.1rem 0.5rem;\ position: absolute;\ background: #ccc;\ cursor: pointer;\ z-index: 100000;\ color: #00aecd;\ font-weight: bold;\ }\ #close .close-btn{\ background:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAANCAYAAABy6+R8AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAPlJREFUeNp8UjESgjAQDBkfYGkZf0BjDZZ28gN4kU+AH0hnCdQ2/ABKS36gu8zGOZ3Rm9khye7eXS4kzsTudt/iUwIZwPUCDEDzOB2WqPPGcMZnAi46GmTkfhK/RmIMV6AFKptV1WuAmgJcm+iQFXocFO5HQMekObD3ykBjJfIJ1FrX3MtXSXf2unRvWiJZQjxpKGsy8T31NAVgjm2AbEQGJWtMl9QFHxem91q9U5zHVhVrAa/RkozGUhOsYqtKFpRsiNn5Dp37E+R1T7cxl+9kZJXZiIPeiVWO78cVmeqBKRr1C3HEqe7Nhx0/TMZcypip//lrgu4lwADSY2+nhzpILAAAAABJRU5ErkJggg==');\ background-size:cover;\ width:13px;\ height:13px;\ margin-top:2px;\ margin-right:2px;\ display:inline-block;\ }\ #floor-ad {\ z-index: 10000;\ }\ @media(max-width:767px) {\ #close {\ left: 0;\ }\ }", head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); style.type = 'text/css'; if (style.styleSheet) { style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); } head.appendChild(style); googletag.cmd.push(function () { googletag.pubads().addEventListener('slotRenderEnded', function (event) { if (event.slot.getSlotElementId() === "floor-ad" && !event.isEmpty) { console.info("[GPT] slotRenderEnded - " + 'floor-ad'); var adWidth = event.size[0]; var adHeight = event.size[1]; //se smart compra 1x1 non facciamo comparire nulla //if (adWidth === 1 || adHeight === 4) { if (adWidth === 1 && adHeight === 1) { return; } if(adHeight !== 4){ var iframe = $("#floor-ad-wrapper").find("iframe").first(); if (iframe.width() != adWidth || iframe.height() != adHeight) { console.log("Aggiustamento size floorad"); console.log("size gpt: " + adWidth + "X" + adHeight); console.log("size effettiva: " + iframe.width() + "X" + iframe.height()); adWidth = iframe.width(); adHeight = iframe.height(); } setTimeout(function () { $("#floor-ad-wrapper #close").show(); }, 500); setTimeout(function () { console.info("[GPT] triggered - " + 'floor-ad'); $("#floor-ad-wrapper").height(adHeight + 10); $("#floor-ad-wrapper>div").width(adWidth); $("#floor-ad-wrapper").animate({ bottom: 0 }); setTimeout(function () { console.info("[GPT] timeout triggered " + 'floor-ad'); $("#floor-ad-wrapper").animate({ bottom: -adHeight - 10 }, function () { $("#floor-ad-wrapper").remove(); }); }, 60000) }, 2000); } } }); }); function showFloorAd() { var floorad = "\
\
\

Chiudi

\
\
\
\
"; $floorad = $(floorad); $floorad.find("#close").on("click", function () { $floorad.remove(); }); $("body").append($floorad); Optiload.sm.createSlot(idFloorad, "floor-ad"); } function throttle(fn, wait) { var time = Date.now(); return function () { if ((time + wait - Date.now()) < 0) { fn(); time = Date.now(); } } } $(window).on("scroll", throttle(callback, 1000)); var triggered = false; function callback() { //console.log("callback"); if (!triggered && $(window).scrollTop() > 400) { triggered = true; showFloorAd(); } } } function loadSpotx() { include_js('//assets.evolutionadv.it/stickify-plugin.js?v=201802191336', function () { window["myAdDoneFunction"] = function (spotx_ad_found) { $("#container-spotx").slideUp(); }; var spotwidth = 400; var spotheight = 259; var s = ''; if (Optiload.isMobile()) { spotwidth = 320; spotheight = 208; s = ''; } var spotx = '
\
\
' + s + '
'; setTimeout(function () { var $texte = $(".texte").last(); if ($texte.length > 0) { var $p = $texte.find("p"); var $lastVisible = null; for (var i = 0; i < $p.length; i++) { if ($($p[i]).is(":in-viewport")) { $lastVisible = $($p[i]); } } if ($lastVisible) { $spotx = $(spotx); $lastVisible.after($spotx); console.log("SPOTX rendered"); $spotx.on("stuck", function () { if ($("#floor-ad-wrapper").length > 0) { $("#floor-ad-wrapper").remove(); } }); } setTimeout(function findVideo() { var $spotx = $("[data-spotx_content_container_generated=true]"); if ($spotx.length > 0 && $spotx.height() == spotheight) { $("#container-spotx").css("clear", "both"); $spotx.stickify({ wrapper: "#container-spotx" }); } else { setTimeout(findVideo, 1000); } }, 2000); } }, 7000); }); } }(jQuery, Optiload));