1 2 3var googletag = googletag || {}; googletag.cmd = googletag.cmd || []; 4(function() { var gads = document.createElement('script'); gads.async = true; gads.type = 'text/javascript'; var useSSL = 'https:' == document.location.protocol; gads.src = (useSSL ? 'https:' : 'http:') + '//www.googletagservices.com/tag/js/gpt.js'; var node = document.getElementsByTagName('script')[0]; node.parentNode.insertBefore(gads, node); })(); 5 6 7 8 9 10 11gpt_ad_slots = []; 12gpt_late_ad_slots = []; 13gptadpath = gpt_ad_settings.adpath; 14googletag.cmd.push(function() { 15 16 // Build 17 for( var id_key in gpt_ad_list ){ 18 19 if( gpt_ad_list[id_key].out ){ 20 if ( typeof( FM_Watcher ) === 'undefined' || ! FM_Watcher.isMobile() ) { 21 gpt_ad_slots[id_key] = googletag.defineOutOfPageSlot( gptadpath, id_key ).addService(googletag.companionAds()).addService(googletag.pubads()); 22 } 23 } else if( gpt_ad_list[id_key].strnativekey ) { 24 gpt_ad_slots[id_key] = googletag.defineSlot( gptadpath, gpt_ad_list[id_key].sizes, id_key ).addService(googletag.pubads()).setTargeting("POS", gpt_ad_list[id_key].POS ).setTargeting( "strnativekey", gpt_ad_list[id_key].strnativekey ); 25 } else { 26 gpt_ad_slots[id_key] = googletag.defineSlot( gptadpath, gpt_ad_list[id_key].sizes, id_key ).addService(googletag.pubads()).setTargeting("POS", gpt_ad_list[id_key].POS ); 27 } 28 if( gpt_ad_list[id_key].pos ) { 29 gpt_ad_slots[id_key].setTargeting("pos", gpt_ad_list[id_key].pos ); 30 } 31 if( gpt_ad_settings.sizemaps[id_key] ) { 32 var mapping = googletag.sizeMapping(); 33 for( var viewp in gpt_ad_settings.sizemaps[id_key] ){ 34 35 var viewp_xy = viewp.split('x'); 36 viewp_xy[0] = parseInt( viewp_xy[0] ); 37 viewp_xy[1] = parseInt( viewp_xy[1] ); 38 39 var ad_xy = gpt_ad_settings.sizemaps[id_key][viewp].split('x'); 40 ad_xy[0] = parseInt( ad_xy[0] ); 41 ad_xy[1] = parseInt( ad_xy[1] ); 42 43 mapping = mapping.addSize( viewp_xy, [ ad_xy ] ); 44 } 45 mapping = mapping.build(); 46 gpt_ad_slots[id_key].defineSizeMapping( mapping ); 47 } 48 49 } 50 51 // Target 52 if( gpt_ad_settings.targets ) { 53 54 // Add Age Gate param 55 const allCookies = document.cookie; 56 const hasOverNineteenCookie = allCookies.indexOf('over-nineteen=confirmed') >= 0; 57 58 if ( window.ageGateRequired && hasOverNineteenCookie ) { 59 gpt_ad_settings.targets.userOverNineteen = 'true'; 60 } 61 62 for( var t_key in gpt_ad_settings.targets ){ 63 googletag.pubads().setTargeting( t_key, gpt_ad_settings.targets[t_key] ); 64 } 65 } 66 googletag.pubads().setTargeting( 'url', document.location.href ); 67 googletag.pubads().setTargeting('permutive', encodeURIComponent(JSON.parse(localStorage._pdfps || '[]').slice(0,250).join(','))); 68 69 //Collect 70 var adslot_vals = []; 71 var i = 0; 72 for( var key in gpt_ad_slots ) { 73 adslot_vals[i] = gpt_ad_slots[key]; 74 i++; 75 } 76 77 //Hide content if native ad loads 78 googletag.pubads().addEventListener( 'slotOnload', function( event ) { 79 const divId = event.slot.getSlotElementId(); 80 const wrapperDiv = document.querySelector( '#native-wrapper-' + divId ); 81 82 if ( wrapperDiv ) { 83 wrapperDiv.querySelector( '.c-card__figure' ).style.display = 'none'; 84 wrapperDiv.querySelector( '.c-card__header' ).style.display = 'none'; 85 wrapperDiv.querySelector( '.c-card__ad' ).style.zIndex = '1'; 86 wrapperDiv.querySelector( '.c-card__ad' ).style.position = 'static'; 87 } 88 }); 89 90 //Settings 91 googletag.pubads().collapseEmptyDivs(); 92 googletag.companionAds().setRefreshUnfilledSlots(true); 93 94 // Batch SRA implemented 95 googletag.pubads().enableSingleRequest(); 96 97 googletag.enableServices(); 98 99 100}); 101 102(function($){ 103 function addEventListeners() { 104 threshold = $(window).innerHeight() * 0.5; 105 window.addEventListener( FM_Watcher.ON_SCROLL, handleScroll ); 106 isEventListening = true; 107 } 108 109 function removeEventListeners() { 110 window.removeEventListener( FM_Watcher.ON_SCROLL, handleScroll ); 111 isEventListening = false; 112 } 113 114 function handleScroll( evt ) { 115 var scrollTop = evt && evt.detail && evt.detail.scrollTop || $(window).scrollTop(); 116 var scrollBottom = evt && evt.detail && evt.detail.scrollBottom || ( scrollTop + $(window).innerHeight() ); 117 for ( var i = 0; i < dynamicAds.length; i++ ) { 118 var $target = dynamicAds[i].$target; 119 if ( !dynamicAds[i].initialized && $target.css('display') !== 'none' ) { 120 var adY = $target.offset().top; 121 if ( ( adY > scrollTop - threshold ) && ( adY + dynamicAds[i].height < scrollBottom + threshold ) ) { 122 dynamicAds[i].initialized = true; 123 124 displayAd( dynamicAds[i] ); 125 dynamicAds.splice( i, 1 ); 126 127 // No more dynamic ads to load, stop listening to scroll 128 if ( dynamicAds.length === 0 ) { 129 removeEventListeners(); 130 } 131 132 break; 133 } 134 } 135 } 136 } 137 138 function displayAd( setting ) { 139 googletag.cmd.push( function() { 140 var slot = googletag.defineSlot( gptadpath, setting.sizes, setting.id ) 141 .addService( googletag.pubads() ) 142 .setTargeting( 'pos', setting.pos ); 143 144 var mapping = false; 145 if ( typeof( setting.mapping ) !== 'undefined' ) { 146 mapping = googletag.sizeMapping(); 147 for ( var bp in setting.mapping ) { 148 mapping.addSize( [parseInt(bp), 0], setting.mapping[bp] ); 149 } 150 mapping = mapping.build(); 151 slot.defineSizeMapping( mapping ); 152 } 153 154 if ( typeof( apstag ) !== 'undefined' && typeof( apstag.fetchBids ) !== 'undefined' && typeof( FM_APS_Helper ) !== '' ) { 155 apstag.fetchBids({ 156 slots: [ 157 { 158 slotID: setting.id, 159 sizes: mapping ? FM_APS_Helper.parseSizeMappings( mapping ) : setting.sizes, 160 slotName: gptadpath + '/' + setting.id 161 } 162 ], 163 timeout: 700 164 }, function(bids){ 165 googletag.cmd.push(function(){ 166 apstag.setDisplayBids(); 167 googletag.pubads().refresh( [slot] ); 168 }); 169 }); 170 } else { 171 googletag.pubads().refresh( [slot] ); 172 } 173 } ); 174 } 175 176 var dynamicAds = []; 177 var isEventListening = false; 178 var fmAds = { 179 createDynamicAd: function( setting ) { 180 if ( typeof( FM_Watcher ) !== 'undefined' && setting.id && setting.sizes ) { 181 dynamicAds.push( setting ); 182 if ( !isEventListening ) { 183 addEventListeners(); 184 handleScroll(); 185 } 186 } 187 } 188 }; 189 190 window.FMAds = fmAds; 191})( jQuery ); 192; 193(function($) { 194 var elements = []; 195 var stickyElements = []; 196 var stickyStackHeight = 0; 197 var currentDirection = false; // 'true' for down, 'false' for up 198 var watchScroll = typeof( fm_watcher_setting ) !== 'undefined' && typeof( fm_watcher_setting.watch_scroll ) !== 'undefined' ? '1' === fm_watcher_setting.watch_scroll : false; 199 var currentScrollTop = 0; 200 var isEventWatching = false; 201 var isScrollTimeout = false; 202 var isMobile; 203 var isIOS; 204 var isAndroid; 205 var isSafari; 206 var animationTimeout; 207 208 var requestAnimationFrame = window.requestAnimationFrame || 209 window.mozRequestAnimationFrame || 210 window.webkitRequestAnimationFrame || 211 window.msRequestAnimationFrame; 212 213 var cancelAnimationFrame = window.cancelAnimationFrame || 214 window.mozCancelAnimationFrame; 215 216 var fmWatcher = { 217 ON_SCROLL: 'onWindowScroll', 218 ON_DIRECTION_CHANGE: 'onScrollDirectionChange', 219 ON_STICKY_STACK_CHANGE: 'onStickyStackChange', 220 ANIMATION_DURATION: 500, 221 isTimeout: function() { 222 return animationTimeout || isScrollTimeout; 223 }, 224 isIOS: function() { 225 if ( typeof(isIOS) === 'undefined' ) { 226 isIOS = window.navigator.platform && /iP(hone|od|ad)/i.test(window.navigator.platform); 227 } 228 return isIOS; 229 }, 230 isAndroid: function() { 231 if ( typeof(isAndroid) === 'undefined' ) { 232 isAndroid = window.navigator.userAgent && /android/i.test(window.navigator.userAgent); 233 } 234 return isAndroid; 235 }, 236 isMobile: function() { 237 if ( typeof(isMobile) === 'undefined' ) { 238 isMobile = fmWatcher.isAndroid() || fmWatcher.isIOS(); 239 } 240 return isMobile; 241 }, 242 isSafari: function() { 243 if ( typeof(isSafari) === 'undefined' ) { 244 isSafari = window.navigator.userAgent && !(/chrome/i.test(window.navigator.userAgent)) && /safari/i.test(window.navigator.userAgent); 245 } 246 return isSafari; 247 }, 248 hasWifi: function() { 249 return fmWatcher.isAndroid() && navigator.connection && navigator.connection.type === 'wifi'; 250 }, 251 fireWindowEvent: function( name, data ) { 252 fireEvent( name, data ); 253 }, 254 addStickyElement: function( $elem ) { 255 stickyStackHeight += $elem.height(); 256 stickyElements.push( $elem ); 257 fireEvent( fmWatcher.ON_STICKY_STACK_CHANGE, { 'height': stickyStackHeight } ); 258 }, 259 removeStickyElement: function( $elem ) { 260 for ( var i = 0; i < stickyElements.length; i++ ) { 261 var $current = stickyElements[i]; 262 if ( $current.attr('id') === $elem.attr('id') ) { 263 stickyElements.slice( i, 1 ); 264 stickyStackHeight -= $elem.height(); 265 fireEvent( fmWatcher.ON_STICKY_STACK_CHANGE, { 'height': stickyStackHeight } ); 266 break; 267 } 268 } 269 }, 270 getStickyStackHeight: function() { 271 return stickyStackHeight; 272 } 273 }; 274 275 function addEventListeners() { 276 if ( !isEventWatching && watchScroll ) { 277 if ( requestAnimationFrame ) { 278 window.addEventListener( 'scroll', handleAnimation ); 279 } else { 280 window.addEventListener( 'scroll', onScroll ); 281 } 282 isEventWatching = true; 283 } 284 } 285 286 function fireEvent( name, data ) { 287 var evt; 288 if ( typeof( CustomEvent ) === 'function' ) { 289 evt = new CustomEvent( name, { 290 detail: data 291 }); 292 } else { 293 evt = window.document.createEvent("Event"); 294 evt.initEvent( name, true, true ); 295 evt.detail = data; 296 } 297 298 window.dispatchEvent(evt); 299 } 300 301 function handleAnimation() { 302 var scrollTop = $(window).scrollTop(); 303 304 if ( animationTimeout ) { 305 cancelAnimationFrame( animationTimeout ); 306 } 307 308 if ( scrollTop !== currentScrollTop && scrollTop >= 0 ) { 309 animationTimeout = requestAnimationFrame( function() { 310 handleScroll( scrollTop ); 311 }); 312 } 313 } 314 315 function handleScroll( top ) { 316 var $window = $(window); 317 var scrollTop = top || $window.scrollTop(); 318 var direction = scrollTop > currentScrollTop; 319 var data = { 320 scrollTop: scrollTop, 321 scrollBottom: scrollTop + $window.innerHeight(), 322 scrollTopOld: currentScrollTop, 323 direction: direction, 324 directionOld: currentDirection 325 }; 326 327 fireEvent( fmWatcher.ON_SCROLL, data ); 328 329 if ( direction !== currentDirection ) { 330 fireEvent( fmWatcher.ON_DIRECTION_CHANGE, data ); 331 } 332 333 currentDirection = direction; 334 currentScrollTop = scrollTop; 335 } 336 337 function onScroll(event) { 338 if (isScrollTimeout) { 339 return; 340 } 341 342 isScrollTimeout = true; 343 handleScroll(); 344 345 // set new timeout to limit the number of excutions of _handleScroll 346 setTimeout(function() { 347 // reset timeout flag to false (no longer waiting) 348 isScrollTimeout = false; 349 }, 100); 350 } 351 352 addEventListeners(); 353 354 window.FM_Watcher = fmWatcher; 355 356})( jQuery ); 357;
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.