PageSourceSearch

https://wx.iwindsurf.com/App_Common/JS/ads.js

js iwindsurf.com collected 2026-10-01 11:48:47 UTC 3,162 bytes, 85 lines download raw bytes

1const iwBothPAs = ["Wind", "Kite"];
2const paMapping = { "Windsurf": "Wind", "Kite": "Kite", "Sail": "Sail", "Fish": "Fish", "KiteWindsurf": iwBothPAs[Math.floor(Math.random() * iwBothPAs.length)] };
3const dfpRandomPAs = ["Wind", "Kite", "Sail"];
4const adRefreshInterval = 10000;
5const ads = {};
6const dfpSlots = {}; // Used to lazy load dfp ads
7let paFound = false;
8let lastRefresh = new Date().getTime();
9let isDesktop = false;
10let hasTower = false;
11
12function registerAd(adContainerId) {
13    // The jweather global isn't loaded on every page that renders banner ad
14    // containers (e.g. the error/404 page), so bail rather than throwing a
15    // ReferenceError when there's nothing to configure ads with.
16    if (typeof jweather === 'undefined' || !jweather.Ads) return;
17
18    const dfpPA = jweather.Ads.gpt_primary_activity;
19    
20    const adContainer = document.querySelector(`#${adContainerId}`);
21    const adPosition = adContainer.dataset.adPosition;
22    const adSource = adContainer.dataset.adSource 
23        ? adContainer.dataset.adSource 
24        : adPosition === 'top-banner' 
25        ? 'gpt' 
26        : jweather.Ads.ad_source;
27    const adSourceSlotInfo = jweather.Ads.ad_slot_info[adSource];
28
29    const isGPTAd = adSource === 'gpt';
30    const isDesktop = window.innerWidth > 1440;
31    const isMedium = window.innerWidth > 839;
32    const shouldLazyLoad = adContainer.hasAttribute('data-lazy-load');
33
34    const deviceSize = isDesktop && isMedium ? 'desktop' : !isDesktop && isMedium ? 'medium' : 'mobile';
35    const adDimensions = adSourceSlotInfo[adPosition][deviceSize].dimensions;
36    const slotNamePrefix = adSourceSlotInfo[adPosition][deviceSize].namePrefix;
37    const slotName = isGPTAd ? `${slotNamePrefix}${dfpPA}` : `${slotNamePrefix}${adPosition}`;
38    const accountId = adSourceSlotInfo.accountId;
39    
40    window.googletag = window.googletag || { cmd: [] };
41
42    googletag.cmd.push(() => {
43        dfpSlots[adContainerId] = googletag.defineSlot(`/${accountId}/${slotName}`, adDimensions, adContainerId).addService(googletag.pubads());
44
45        googletag.setConfig({ disableInitialLoad: true });
46        googletag.enableServices();
47    });  
48    
49    if (!shouldLazyLoad) {
50        loadAd(adContainer);
51    }
52}
53
54function loadAd(container) {
55    const bannerId = container.id;
56
57    googletag.cmd.push(() => {
58        googletag.display(bannerId);
59        googletag.pubads().refresh([dfpSlots[bannerId]]);
60    });
61}
62
63function refreshDFP(interval) {
64    const slots = [...Object.values(dfpSlots), ...Object.values(ads)];
65    var currentTime = new Date().getTime();
66
67    if (lastRefresh != null && interval != null) {
68        if (currentTime - lastRefresh > interval) {
69            if (showAds == 'true') {
70                googletag.cmd.push(function () {
71                    googletag.pubads().refresh(slots);
72                });
73            }
74
75            lastRefresh = currentTime;
76
77            //_gaq.push(['_trackPageview']);
78        }
79    }
80}
81
82document.addEventListener('DOMContentLoaded', function () {
83    const bannerAds = document.querySelectorAll('[data-content="wa-banner-ad"]');
84    bannerAds.forEach(ad => registerAd(ad.id));
85});

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.