1"use strict";var apntag=window.apntag;class AdsController{config={debug:!1,tagWrapperClass:"js-ad-tag-wrapper",tagClass:"js-ad-tag",stack:{containerClass:"js-ad-stack",innerClass:"js-ad-stack-inner",itemClass:"js-ad-stack-item",templateClass:"js-ad-stack-template",invCodeBaseAttr:"data-ad-inv-code-base"},onHandleLonelyStackItems:(t,e)=>null,onXandrAdNotFound:(t,e)=>null,onXandrAdAvailable:(t,e)=>null,onXandrAdLoad:(t,e)=>null,onXandrAdShow:(t,e)=>null};tags=[];stacks=[];_$window=$([]);constructor(t,e=[]){this._$window=$(window),Object.assign(this.config,{...t,selectors:Object.assign(this.config.stack,t.stack??{})}),this.addTags(e)}addTags(t){t.forEach(t=>{this.addTag(t)})}addTag(t,e=!1){if(!e)try{t=this._validateInputTag(t)}catch(t){return console.error(t),null}if("stack"===t.type)t.items=[],t.$container=$("."+this.config.stack.containerClass+"["+this.config.stack.invCodeBaseAttr+'="'+t.invCodeBase+'"]'),t.$template=$(),t.$inner=$(),t._didInitContainer=!1;else t.type="default",t.targetId||(t.targetId=t.invCode),t.$target=$("#"+t.targetId),t.$wrapper=t.$target.closest("."+this.config.tagWrapperClass);return this.tags.push(t),t}init(){this.attachXandrEvents();const t=this.tags.filter(t=>"stack"===t.type);let e=!1;t.every(t=>!t.$container.length||!t.$container[0].offsetParent||(e=!0,!1)),this.config.debug&&console.log("=== INIT - waitForStacks",e,"==="),e?this._onLoad(()=>{t.forEach(t=>{this.handleStackContainer(t),this.handleLonelyStackItems(t)}),this.defineXandrTags(),this.loadXandrTags(),this.attachEvents()}):(t.forEach(t=>{this.handleLonelyStackItems(t)}),this.defineXandrTags(),this.loadXandrTags(),this.attachEvents())}attachXandrEvents(){apntag.anq.push(()=>{apntag.onEvent("adNoBid",t=>{const e=$("#"+t.targetId),a=e.closest("."+this.config.tagWrapperClass);this.config.debug&&console.log("_xandr_event_ adNoBid: ",e[0]),a.hide(),this.config.onXandrAdNotFound(this._findTagByTargetId(t.targetId),a)}),apntag.onEvent("adBadRequest",t=>{this.config.debug&&console.log("_xandr_event_ adBadRequest: ",t)}),apntag.onEvent("adAvailable",t=>{const e=$("#"+t.targetId);this.config.debug&&console.log("_xandr_event_ adAvailable: ",e[0]);const a=e.closest("."+this.config.tagWrapperClass);this.maybeShowTagOnAdAvailable(t.targetId),this.config.onXandrAdAvailable(this._findTagByTargetId(t.targetId),a)}),apntag.onEvent("adLoaded",t=>{const e=$("#"+t.targetId),a=e.closest("."+this.config.tagWrapperClass);this.config.debug&&console.log("_xandr_event_ adLoaded: ",e[0]);a.css("visibility","visible");this.config.onXandrAdLoad(this._findTagByTargetId(t.targetId),a)})})}defineXandrTags(t=[]){t.length||(t=this.tags);const e=[];t.forEach(t=>{if("stack"===t.type)t.items.forEach((a,s)=>{if(!a.defined&&a.$target[0].offsetParent){const a=t.tagIds[s],n={invCode:t.invCodeBase+"_"+(s+1),targetId:t.invCodeBase+"_"+(s+1)};"object"==typeof a?(n.tagId=a.tagId,n.sizes=a.sizes??t.sizes):(n.tagId=a,n.sizes=t.sizes),t.items[s].defined=!0,e.push(n)}});else!t.defined&&t.$target.length&&t.$target[0].offsetParent&&(t.defined=!0,e.push({invCode:t.invCode,targetId:t.targetId,tagId:t.tagId,sizes:t.sizes}))}),e.length&&apntag.anq.push(()=>{this.config.debug&&console.log("+++ defined",e.map(t=>t.targetId)),e.forEach(t=>{apntag.defineTag(t)})})}attachEvents(){this.showXandrTags(),this._$window.on("scroll",()=>{this.showXandrTags()}),this._$window.on("resize",this._debounce(()=>{this.handleTagsAfterResize()},500))}loadXandrTags(){const t=[];
1this.tags.forEach(e=>{if("stack"===e.type)e.items.forEach((a,s)=>{a.loaded||(t.push(e.invCodeBase+"_"+(s+1)),e.items[s].loaded=!0)});else e.$target.length&&e.$target[0].offsetParent&&(e.loaded||(t.push(e.targetId),e.loaded=!0))}),t.length&&apntag.anq.push(()=>{this.config.debug&&console.log("+++ loaded",t.map(t=>document.querySelector("#"+t))),t.forEach(t=>{}),apntag.loadTags(t)})}showXandrTags(t=null){const e=[];this.tags.forEach(t=>{if("stack"===t.type)t.items.forEach((a,s)=>{a.loaded&&!a.shown&&this._isInViewport(a.$target[0])&&(e.push(t.invCodeBase+"_"+(s+1)),t.items[s].shown=!0)});else t.$target.length&&t.$target[0].offsetParent&&t.loaded&&!t.shown&&this._isInViewport(t.$target[0])&&(e.push(t.targetId),t.shown=!0)}),e.length&&apntag.anq.push(()=>{this.config.debug&&console.log("+++ show",e.map(t=>document.querySelector("#"+t))),e.forEach(t=>{apntag.showTag(t),this.config.onXandrAdShow(this._findTagByTargetId(t),$("#"+t).closest("."+this.config.tagWrapperClass))})})}maybeShowTagOnAdAvailable(t){const e=this._findTagByTargetId(t);let a=null;if("stack"===e.type)e.items.forEach((s,n)=>{s.$target.attr("id")===t&&s.loaded&&!s.shown&&this._isInViewport(s.$target[0])&&(a=t,e.items[n].shown=!0)});else e.$target.attr("id")===t&&e.$target.length&&e.$target[0].offsetParent&&e.loaded&&!e.shown&&this._isInViewport(e.$target[0])&&(a=t,e.shown=!0);a&&apntag.anq.push(()=>{this.config.debug&&console.log("+++ show",[document.querySelector("#"+a)]),apntag.showTag(a),this.config.onXandrAdShow(this._findTagByTargetId(a),$("#"+a).closest("."+this.config.tagWrapperClass))})}handleTagsAfterResize(){this.config.debug&&console.log("=== handleTagsAfterResize ===");this.tags.filter(t=>"stack"===t.type).forEach(t=>{this.handleStackContainer(t),this.handleLonelyStackItems(t)}),this.defineXandrTags(),this.loadXandrTags(),this.showXandrTags()}handleStackContainer(t){if(t.$container.length&&t.$container[0].offsetParent){if(this.config.debug&&console.log("=== handleStackContainer",t.invCodeBase,!t._didInitContainer,"==="),!t._didInitContainer){t._didInitContainer=!0;const e=t.$container.find("."+this.config.stack.templateClass);if(!e.length)return void console.error("AdsController: No stack template found!",$stackContainer);if(!e.find("."+this.config.tagClass).length)return void console.error("AdsController: Stack template must contain a tag target!",e);t.$template=e,t.$inner=t.$container.find("."+this.config.stack.innerClass)}this._generateStackContainerItems(t)}}handleLonelyStackItems(t){this.config.debug&&console.log("--- handleLonelyStackItems: ",t.invCodeBase,"===");const e=$("."+this.config.tagClass+"["+this.config.stack.invCodeBaseAttr+'="'+t.invCodeBase+'"]:not([id])');e.each((e,a)=>{if(!a.offsetParent)return;const s=$(a);t.items.length<t.tagIds.length?(s.attr("id",t.invCodeBase+"_"+(t.items.length+1)),t.items.push({$target:s,$wrapper:s.closest("."+this.config.tagWrapperClass)}),this.config.debug&&console.log("+ handled lonely stack item",t.invCodeBase+"_",t.items.length)):(s.closest("."+this.config.tagWrapperClass).hide(),this.config.debug&&console.log("- handleLonelyStackItems: skipping - max items reached:",t.items.length,"for",t.invCodeBase))}),this.config.onHandleLonelyStackItems(t,e)}handleLateTags(){this.config.debug&&console.log("=== handleLateTags ===");this.tags.filter(t=>"stack"===t.type).forEach(t=>{this.handleLonelyStackItems(t)}),this.defineXandrTags(),this.loadXandrTags()}_onLoad(t){this._$window.on("load",t)}_validateInputTag(t){if(!t.sizes)throw new Error("AdsController: sizes is required tag:",t);if(!Array.isArray(t.sizes))throw new Error("AdsController: sizes must be an array");if(0===t.sizes.length)throw new Error("AdsController: sizes must contain at least one size");if("stack"===t.type){if(!t.invCodeBase)throw new Error("AdsController: invCodeBase is required");if(!t.tagIds)throw new Error("AdsController: stackItems is required");if(!Array.isArray(t.tagIds))throw new Error("AdsController: stackItems must be an array");if(0===t.tagIds.length)throw new Error("AdsController: stackItems must contain at least one value")}else{if(!t.invCode)throw new Error("AdsController: invCode is required");if(!t.tagId)throw new Error("AdsController: tagId is required")}return t}
1_generateStackContainerItems(t){let e=t.$container.innerHeight()??0;if(e>0){const a=t.$template.find("."+this.config.tagWrapperClass).outerHeight(!0)??0;if(t.$container.find("> *").each((t,a)=>{const s=$(a);if(s.hasClass(this.config.stack.templateClass)||s.hasClass(this.config.stack.innerClass))return;let n=0;(s.hasClass(this.config.tagWrapperClass)||s.hasClass(this.config.tagClass)||s[0].offsetParent)&&(n=s.outerHeight(!0)??0),e-=n}),a>0){const s=a>0?Math.floor(e/a):0;for(let e=t.items.length+1;e<=s;e++){if(e>t.tagIds.length)continue;const a=t.$template.clone(),s=a.find("."+this.config.tagClass);a.removeClass(this.config.stack.templateClass),a.attr("style",""),a.addClass(this.config.stack.itemClass),s.attr("id",t.invCodeBase+"_"+e),t.$inner.length?t.$inner.append(a):t.$container.append(a),t.items.push({$target:s,$wrapper:a.closest("."+this.config.tagWrapperClass)})}}}}_findTagByTargetId(t){return this.tags.find(e=>"stack"===e.type?e.items.find(e=>e.$target.attr("id")===t):e.$target.attr("id")===t)}_isInViewport(t,e=0){const a=t.getBoundingClientRect(),s=window.innerHeight||document.documentElement.clientHeight,n=s*(e/100),i=-n,o=s+n;return a.bottom>i&&a.top<o}_debounce=(t,e)=>{let a=null;return(...s)=>{window.clearTimeout(a),a=window.setTimeout(()=>{t(...s)},e)}}}function placeBefore(t,e){t.parent().hasClass("microdata-content-section")?e.insertBefore(t.parent()):e.insertBefore(t)}!function(){const t=$("#midcontentads");if(t.length){let e=$(".content h2");0===e.length&&(e=$(".content p"));const a=Math.floor(e.length/2);placeBefore($(e[a]),t.children())}}();const tags=[{invCode:"NIS_top_1",tagId:32549886,sizes:[[980,120],[980,240]]},{type:"stack",invCodeBase:"NIS_sidebar",tagIds:[31775705,31775708,31775710,31775713,31775714],sizes:[[400,250]]},{invCode:"NIS_desktop_sticky_400x500px",tagId:36889515,sizes:[[400,500],[400,250]]},{type:"stack",invCodeBase:"NIS_mobile_320x320px",tagIds:[{tagId:36908842,sizes:[[320,320],[300,250],[320,160],[320,80],[250,120],[510,240],[510,150]]},36908846,36908851,36908855],sizes:[[320,320],[300,250],[320,160],[320,80],[250,120]]}],adsController=new AdsController({debug:!0},tags);adsController.init();
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.