-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdfp.min.js
1 lines (1 loc) · 1.2 KB
/
dfp.min.js
1
var DFP=DFP||{},DFP_TARGETS=DFP_TARGETS||{},googletag=googletag||{};googletag.cmd=[],DFP={tags:[],rendered_ads:[],getAd:function(a){var b,c,e,f=[];if(b=this.tags[a],b.hasAttribute("data-sizes")){e=b.getAttribute("data-sizes"),e=e.indexOf(",")>=0?e.split(","):[e];for(var g=0,h=e.length;h>g;g++)d=e[g].split("x"),f.push([parseInt(d[0]),parseInt(d[1])]);c=googletag.defineSlot(b.getAttribute("data-unit"),f,a).addService(googletag.pubads())}else c=googletag.defineOutOfPageSlot(b.getAttribute("data-unit"),a);for(var i in DFP_TARGETS)c.setTargeting(i,DFP_TARGETS[i]);t=JSON.parse(this.tags[a].getAttribute("data-targets"));for(var i in t)c.setTargeting(i,t[i]);this.rendered_ads[a]=c,googletag.pubads().enableSingleRequest(),googletag.enableServices(),googletag.display(a)},processAds:function(){for(var a=document.querySelectorAll("div.dfp"),b="",c=0,d=a.length;d>c;c++)this.tags[a[c].id]=a[c],b+='googletag.cmd.push(function(){DFP.getAd("'+a[c].id+'")});';document.write("<script>"+b+"</scr"+"ipt>")},init:function(){var a,b;this.processAds(),a=document.createElement("script"),a.async=!0,a.src="//www.googletagservices.com/tag/js/gpt.js",b=document.getElementsByTagName("script")[0],b.parentNode.insertBefore(a,b)}},DFP.init();