}否则{if(console.log && window.querystring.verbose ==='1')console.log(“尝试渲染弹出窗口:设备太窄(小于768px)”);} return true;}函数geturlquerystringvaluebyname(name){name = name.replace(/ [\ [] /,'\\ [')。替换(/ [\]] /,'\\]');var regex = new regexp('[\\?&]'+ name +'=([^&#] *)');var结果= regex.exec(location.search);返回结果=== null?'':解码组分(结果[1]。(/ \ + / g,''));};函数firloadload(Ismobile,AdloadDelay){if(console.log && window.querystring.verbose ==='1')console.log(“第一个加载:调用”);if(Ismobile){if(console.log && window.querystring.verbose ==='1')console.log(“init:这是一个移动设备”); // This may need a delay to keep Apple devices from doing a stupid.. // [!!!Spoiler Alert!!!] Yep, (fml) Browsers on Apple devices are just as dumb as IE and Edge are everywhere else. window.setTimeout(function () { document.getElementsByClassName("ad-mobile-dyn").forEach(function (e) { e.classList.remove("ad-unit-waiting"); }); moveAds(); }, (adLoadDelay * 2)); } else { if (console.log && window.queryString.verbose === '1') console.log("init: this is a desktop device"); $(window).on("focus", inFocus); adRender(); } return true; } function inFocus() { if (console.log && window.queryString.verbose === '1') console.log('In Focus: Got focus'); if (window.dfp === undefined || window.dfp.wff === undefined || window.dfp.wff.length === 0) return false; while (window.dfp.wff.length > 0) { var ad = window.dfp.wff.pop(); window.googletag.display(ad); /*if (window.ga) { ga('send', 'event', 'Viewability', 'Slot Requested', ad.getAdUnitPath(), 0, { 'nonInteraction': true }); }*/ } return true; } function adinit(retry) { if (retry === undefined || retry === null) retry = 0; if (retry > 9) { console.log("dfp retry exceeded..."); return false; } retry++; if (window.googletag.defineSlot === undefined) { console.log('Ads: Waiting for dfp [ ' + retry + ' ]...'); window.setTimeout(function () { return adinit(retry); }, 250); return false; } if (document.hasFocus() === false) { $j(window).one("focus", function () { adinit(); }); return false; }; window.Context = window.Context || {}; window.Context.dfp = window.Context.dfp | {}; window.ads = []; window.dfp = { stickyad: null, ads: [], wff: [] }; var testsections = ["/"]; var url = window.location.href.toLowerCase(); var referrer = document.referrer.toLowerCase(); window.isTestSection = false; testsections.forEach(function (value) { if (url.indexOf(value) > -1) { window.isTestSection = true; return true; } return false; }); if ($j.cookie('tt') !== undefined) { window.trafficmedium = $j.cookie('tt'); } else { var res = (url.indexOf("outbrain") > -1 || url.indexOf("gclid=") > -1 || url.indexOf("gbraid=") > -1 || url.indexOf("wbraid=") > -1 || url.indexOf("utm_medium=cpc") > -1 || referrer.indexOf("gclid=") > -1 || referrer.indexOf("outbrain") > -1 || referrer.indexOf("gbraid=") > -1 || referrer.indexOf("wbraid=") > -1 || referrer.indexOf("utm_medium=cpc") > -1) ? "Paid" : "Organic"; window.trafficmedium = res; $j.cookie('tt', res, { domain: '', path: '/' }); } if ($j.cookie('ts') !== undefined) { window.trafficsource = $j.cookie('ts'); } else if (window.trafficmedium === "Paid") { if (url.indexOf("gclid=") > -1 || referrer.indexOf("gclid=") > -1) { window.trafficsource = "google display"; } var utmsource = getUrlQueryStringValueByName("utm_source"); if (utmsource !== undefined && utmsource !== null && utmsource !== "") { window.trafficsource = utmsource.toLowerCase(); } } else { if (referrer.indexOf("google.com") > -1) { window.trafficsource = "google search"; } } if ($j.cookie('ts') === undefined && window.trafficsource !== undefined && window.trafficsource !== null) { $j.cookie('ts', window.trafficsource, { domain: '', path: '/' }); } window.Context.isMobile = (window.Context.isMobile || (typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf('IEMobile') !== -1) || (window.innerWidth < 768)); var isMobile = window.Context.isMobile; //mobile if (isMobile) { if ($j("#TopLeaderboard").length > 0) $j("#TopLeaderboard").remove(); if ($j("#BottomLeaderboard").length > 0) $j("#BottomLeaderboard").remove(); if (screen.width < 768) { if ($j("#modalHealio5Interstitial").length > 0) $j("#modalHealio5Interstitial").remove(); } if (!window.isTestSection) { if ($j("#MediumRectangle5").length > 0) $j("#MediumRectangle5").remove(); if ($j("#MediumRectangle6").length > 0) $j("#MediumRectangle6").remove(); if ($j("#MediumRectangle7").length > 0) $j("#MediumRectangle7").remove(); if ($j("#MediumRectangle8").length > 0) $j("#MediumRectangle8").remove(); if ($j("#MediumRectangle9").length > 0) $j("#MediumRectangle9").remove(); if ($j("#MediumRectangle10").length > 0) $j("#MediumRectangle10").remove(); } } //desktop else { var observer = new MutationObserver(function (mutations) { mutations.forEach(function (mutationRecord) { var ele = $j(mutationRecord.target); if ($j(ele).attr("style") === "display: none;" && $j(ele).is(":visible")) { $j(ele).attr("style", "display: none !important;"); } console.log('style changed!'); }); }); var target = document.getElementById('TopLeaderboard'); if (target !== undefined && target !== null) observer.observe(target, { attributes: true, attributeFilter: ['style'] }); } var adLoadDelay = 400; // time in ms to wait for an ad to render before refreshing the layout. var contentTypeTag = document.querySelector('meta[name="bi:content_type"], meta[name="page_type"]'); var contentSpecialtyTag = document.querySelector('meta[name="bi:primary_specialty"]'); var contentSubspecialtyTag = document.querySelector('meta[name="bi:primary_subspecialty"]'); var contentType = ((contentTypeTag !== undefined && contentTypeTag !== null) ? contentTypeTag.getAttribute("content") : '').replace(/[’']/g, ''); var contentSpecialty = ((contentSpecialtyTag !== undefined && contentSpecialtyTag !== null) ? contentSpecialtyTag.getAttribute("content") : '').replace(/[’']/g, ''); var contentSubspecialty = ((contentSubspecialtyTag !== undefined && contentSubspecialtyTag !== null) ? contentSubspecialtyTag.getAttribute("content") : '').replace(/[’']/g, ''); if ((contentType === "Author" || contentType === "Wyanoke Tag") && (contentSpecialty === "" || contentSpecialty === "Staff")) contentSpecialty = "Primary Care"; if (window.location.hostname.split('.')[0] !== 'www' || window.queryString.notarget !== undefined) googletag.pubads().setTargeting("usertype", "slack"); //negatively target against bad words var bodyText = $j('body').clone().find('script').remove().end().find('style').remove().end().text().trim(); var badWords = ['coronavirus', 'covid', 'covid19', 'covid 19']; var foundWords = []; badWords.forEach(function (value) { var regex = new RegExp(value, 'gi'); var res2 = bodyText.match(regex); if (res2 && res2.length > 0) foundWords.push(value); }); if (foundWords && foundWords.length > 0) { console.log('Found bad words: ' + foundWords.join()); googletag.pubads().setTargeting("keyword", foundWords.join()); } if (window.queryString.notarget === undefined || window.queryString.notarget === '') { var specfunc = function() { var specs = []; if (window.Visitor.usercontentspecialty) specs.push(window.Visitor.usercontentspecialty.replace(/[^a-zA-Z&\/\s]/g, '')); if (window.localStorage) { var specstorage = localStorage.getItem("contentspecialties"); specstorage = specstorage ? specstorage.split(',') : []; if (contentSpecialty && contentSpecialty !== '' && specstorage.indexOf(contentSpecialty) === -1) specstorage.splice(0,0,contentSpecialty.replace(/[^a-zA-Z&\/\s]/g, '')); if(specstorage.length > 3) specstorage.splice(2, 1); localStorage.setItem("contentspecialties", specstorage.toString()); specs = specs.concat(specstorage); } return specs.join(); }; var specstring = specfunc(); if(specstring) googletag.pubads().setTargeting("specialty", specstring); if (contentSpecialty !== '') { googletag.pubads().setTargeting("contentspecialty", contentSpecialty); } // use collection name instead of subspec when available if (("").length > 0) { googletag.pubads().setTargeting("collection", ""); } else { if (contentSubspecialty !== '') { googletag.pubads().setTargeting("contentsubspecialty", contentSubspecialty); } } googletag.pubads().setTargeting("traffictype", window.Visitor.type); if (contentType !== '') googletag.pubads().setTargeting("contenttype", contentType); if ("{B3F40BAF-3F00-4A49-A6F7-042269588356}" !== '') googletag.pubads().setTargeting("documentid", "{B3F40BAF-3F00-4A49-A6F7-042269588356}"); if (window.trafficmedium !== undefined) googletag.pubads().setTargeting("trafficmedium", window.trafficmedium); if (window.trafficsource !== undefined) googletag.pubads().setTargeting("trafficsource", decodeURI(window.trafficsource)); } window.viewedAds = []; googletag.pubads().addEventListener('impressionViewable', function (event) { var slotname = event.slot.getAdUnitPath(); setTimeout(function () { window.viewedAds.push(slotname.replace("/136749668/Healio5_", "")); }, 2000); //if (window.ga) // ga('send', 'event', 'Viewability', 'Viewed', slotname, 0, { // 'nonInteraction': true // }); var eventparams = { 'event_category':'Viewability', 'event_action': 'Viewed', 'event_label': slotname, 'non_interaction': true, 'value': 0 }; // see if gtag is available, if not give it a second and try once more. if (typeof (gtag) !== "undefined") { gtag('event', eventparams.event_action, eventparams); } else { window.setTimeout(function () { if (typeof (gtag) !== "undefined") gtag('event', eventparams.event_action, eventparams); }, 1000); } }); window.googletag.cmd.push(function () { window.googletag.pubads().collapseEmptyDivs(true); window.googletag.enableServices(); }); firstLoad(isMobile, adLoadDelay); tryRenderPopup(adLoadDelay); // Drew 2020-06-04: we used to only do this for mobile googletag.pubads().addEventListener('slotRenderEnded', function (event) { // Drew 2020-06-17: we have a different event handler specifically for the popup ad var slotElementId = event.slot.getSlotId().getDomId(); var slotElement = document.getElementById(slotElementId); /*if (window.ga) { var slotname = event.slot.getAdUnitPath(); ga('send', 'event', 'Viewability', 'Slot Loaded', slotname, 0, { 'nonInteraction': true }); }*/ if (slotElement.classList.contains('popup-ad')) return false; // ---- if (!event.isEmpty) { if (console.log && window.queryString.verbose === '1') console.log(event.slot.getSlotId() + ' Ad placed, checking for content.'); if ($("#" + event.slot.getSlotId().getDomId()).html().length > 0) { if (console.log && window.queryString.verbose === '1') console.log(event.slot.getSlotId() + ' We seem to have content.'); // once we have a rendered ad slot it's safe to remove all other stickiness document.getElementsByClassName("sticky-ad").forEach(function (e) { if (e.id !== slotElementId) e.classList.remove("sticky-ad"); }); if (isMobile) { $("#" + event.slot.getSlotId().getDomId()).parent().addClass("article-listing-card"); $(".card--layout").masonry('reloadItems').masonry('layout'); $("#" + event.slot.getSlotId().getDomId()).parent().css('opacity', '1'); } } else { if (console.log && window.queryString.verbose === '1') console.log(event.slot.getSlotId() + ' We do not seem to have content.'); if (console.log && window.queryString.verbose === '1') console.log(event.slot.getSlotId() + ' Ad empty, setting layout.'); $("#" + event.slot.getSlotId().getDomId()).closest('.card-placeholder, .ad-unit').remove(); } } else { if (console.log && window.queryString.verbose === '1') console.log(event.slot.getSlotId() + ' DFP error - Ad empty, setting layout.'); $("#" + event.slot.getSlotId().getDomId()).closest('.card-placeholder, .ad-unit').remove(); } return true; }); var lastDistanceFromTop = $(window).scrollTop(); var scrollTimeout; var throttle = 150; $(window).on('scroll', function () { if (!scrollTimeout) { scrollTimeout = setTimeout(function () { if (isMobile && window.isTestSection) { var distanceFromTop = $(window).scrollTop(); var offset = distanceFromTop - lastDistanceFromTop; //console.log("offset " + Math.round(offset)); lastDistanceFromTop = distanceFromTop; if (offset < 35 && offset > -35) // faster than x and we don't want to load the ads. lazyload(); } else { lazyload(); } scrollTimeout = null; }, throttle); } }); return true; } $j(document).ready(function() { if (window.location.pathname.toLowerCase().indexOf("/news/hematology-oncology") > -1 && document.querySelector('meta[name="bi:content_type"], meta[name="page_type"]').content === "Landing") { $j("body.news").addClass("hematology-oncology"); } if (window.Visitor === undefined && window.sessionStorage) window.Visitor = JSON.parse(sessionStorage.getItem("visitor", "")); if (window.Visitor !== undefined && window.Visitor !== "" && window.Visitor !== null && !window.Visitor.isbot && window.Visitor.type !== "DC") adinit(); else { window.addEventListener("globalsloaded", function () { //dont run if we're a bot if (window.Visitor !== undefined && window.Visitor !== "") { if (window.sessionStorage) sessionStorage.setItem("visitor", JSON.stringify(window.Visitor), "sessionStorage"); if (window.Visitor !== undefined && window.Visitor !== "" && window.Visitor !== null && !window.Visitor.isbot && window.Visitor.type !== "DC") adinit(); } }); } }); window.queryString = (window.queryString || {}); window.location.search.substring(1).split('&').forEach(function (param) { var kvp = param.split('='); if (kvp.length === 2 && kvp[0].length > 0 && kvp[1].length > 0 && !window.queryString.hasOwnProperty(kvp[0])) Object.defineProperty(window.queryString, kvp[0], { value: kvp[1] }); }); if (window.queryString.forcemobile === '1') window.orientation = window.orientation || {};