PageSourceSearch

https://www.nbcconnecticut.com/wp-content/plugins/ad-layers-nbc/js/ad-layers-dfp.js?ver=0.0.10

js nbcconnecticut.com collected 2026-09-24 08:27:56 UTC 3,852 bytes, 133 lines download raw bytes

1/*
2The AdLayersDFPAPI class implements functionality specific to DFP For the AdLayersAPI.
3*/
4AdLayersDFPAPI = function() {}
5
6// Refreshes a specific ad unit
7AdLayersDFPAPI.prototype.refresh = function( ad_unit ) {
8	if ( 'undefined' !== typeof dfpAdUnits[ ad_unit ] ) {
9		googletag.pubads().refresh( [ dfpAdUnits[ ad_unit ] ] );
10	}
11}
12
13// Refreshes all ad units
14AdLayersDFPAPI.prototype.refreshAll = function(type) {
15	if (dfpAdUnits && Object.keys(dfpAdUnits).length) {
16		// DFP needs a numerical indexed array
17		var unitsToRefresh = new Array;
18		for ( var adUnit in dfpAdUnits ) {
19			unitsToRefresh.push( dfpAdUnits[ adUnit ] );
20		}
21		// Set targeting that indicates the type of refresh
22		if (type) {
23			googletag.pubads().setTargeting('refresh', type);
24		}
25		googletag.pubads().refresh( unitsToRefresh );
26	}
27}
28
29const magnitePrebid = function( slotName ) {
30	if ('undefined' === typeof pbjs) return;
31
32	pbjs.que.push(function() {
33		pbjs.rp.requestBids({
34			callback: () => {
35				if (pbjs.adserverRequestSent) return;
36				pbjs.adserverRequestSent = true;
37			},
38			gptSlotObjects: 'undefined' !== typeof slotName ? [ dfpAdUnits[ slotName ] ] : null,
39		})
40	})
41};
42
43AdLayersDFPAPI.prototype.buildAd = function( slotName, path, sizes, targets, sizeMapping ) {
44	if ('function' === typeof URLSearchParams) {
45		let params = new URLSearchParams( window.location ); // phpcs:ignore WordPressVIPMinimum.JS.Window.location
46		if (
47			'1' === params.get('disableHeader')
48			&& '1' === params.get('disableFooter')
49		) {
50			path = path.replace('_mobileweb', '_app');
51		}
52	}
53
54	return googletag.cmd.push( function() {
55		var key, value, divId;
56		divId = adLayersDFP.adUnitPrefix + slotName;
57		dfpAdUnits = dfpAdUnits || {};
58		dfpAdUnits[ slotName ] = googletag.defineSlot( path, sizes, divId );
59
60		if ( targets ) {
61			for ( key in targets ) {
62				value = targets[ key ];
63				dfpAdUnits[ slotName ].setTargeting( key, value );
64			}
65		}
66
67		if ( sizeMapping ) {
68			dfpAdUnits[ slotName ].defineSizeMapping( sizeMapping );
69		}
70
71		// Prevent CLS issues by not collapsing banner ads at top of page.
72		if ( - 1 !== slotName.indexOf('topbanner') ) {
73			dfpAdUnits[ slotName ].setCollapseEmptyDiv(false);
74		}
75
76		magnitePrebid( slotName );
77
78		dfpAdUnits[ slotName ].addService( googletag.pubads() );
79		googletag.display( divId );
80	} );
81};
82
83AdLayersDFPAPI.prototype.lazyLoadAd = function( args ) {
84	if ( ! args.slotName ) {
85		return;
86	}
87
88	if (document.getElementById('div-gpt-ad-' + args.slotName).style.visibility === 'hidden' && -1 === args.slotName.indexOf('topbanner') && 'LX' !== nbc.callLetters) {
89		return;
90	}
91
92	if ( args.format ) {
93		if ( ! ( dfpAdDetails && dfpAdDetails[ args.format ] ) ) {
94			return;
95		}
96		if ( ! args.path ) {
97			args.path = dfpAdDetails[ args.format ].path;
98		}
99		if ( ! args.sizes ) {
100			args.sizes = dfpAdDetails[ args.format ].sizes;
101		}
102		if ( ! args.targeting ) {
103			args.targeting = dfpAdDetails[ args.format ].targeting;
104		}
105		if ( ! args.sizeMapping ) {
106			if ( dfpBuiltMappings && dfpBuiltMappings[ args.format ] ) {
107				args.sizeMapping = dfpBuiltMappings[ args.format ];
108			} else {
109				args.sizeMapping = null;
110			}
111		}
112	}
113	return this.buildAd( args.slotName, args.path, args.sizes, args.targeting, args.sizeMapping );
114};
115
116document.addEventListener('DOMContentLoaded', function() {
117	if ( document.body.classList.contains('tve-landing-page') && ('production' === nbc.env || 'stage' === nbc.env) ) {
118		if (typeof adInstance === 'undefined') {
119			adInstance = new AdLayersAPI();
120		}
121		setInterval(function(){
122			magnitePrebid();
123			adInstance.refreshAll('time');
124		}, 120000);
125	}
126});
127
128window.addEventListener('focus', function() {
129	if ( 'undefined' !== typeof(adInstance) && ! document.body.classList.contains('tve-landing-page') && ('production' === nbc.env || 'stage' === nbc.env) ) {
130		magnitePrebid();
131		adInstance.refreshAll('focus');
132	}
133});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.