var isWbst; if (window.wp || window.wpApiSettings) { isWbst = 'wb'; } else { isWbst = 'ht'; } var ix_ipl_scriptUrl = document.currentScript.src; var ix_ipl_urlParams = new URL(ix_ipl_scriptUrl); var ix_ipl_bsParam = ix_ipl_urlParams.searchParams.get('bs'); var ix_ipl_floaterParam = ix_ipl_urlParams.searchParams.get('floater'); function getParentElement() { var container = document.querySelector('[data-ix-instream-player]'); if (container) { return container; } var parent = document.currentScript ? document.currentScript.parentElement : null; if (parent && parent.tagName === 'HEAD') { return document.body || document.documentElement; } return parent || document.body || document.documentElement; } var ix_ipl_prnElmnt = getParentElement(); var ix_ipl_href = document.currentScript.src; var ix_ipl_macro1 = new URL(ix_ipl_href); var ix_ipl_p = ix_ipl_macro1.searchParams.get('p'); var [ix_ipl_wd, ix_ipl_ht] = (ix_ipl_macro1.searchParams.get("sz") || "0x0") .split("x") .map(Number); var ix_ipl_pUrl = window.location.href; var ix_ipl_mb = ix_ipl_macro1.searchParams.get('mb'); var ix_ipl_cB = Math.floor((Math.random() * 1000000) + 1); var ix_ipl_mbEnabled = ix_ipl_mb === '1'; var ix_ipl_isMobile = ix_ipl_mbEnabled && (window.innerWidth <= 768 || window.screen.width <= 768); function shouldUseMobileResponsive() { return ix_ipl_isMobile; } function getResponsiveDimensions() { return { width: ix_ipl_wd ? parseInt(ix_ipl_wd) : 300, height: ix_ipl_ht ? parseInt(ix_ipl_ht) : 250 }; } var dimensions = getResponsiveDimensions(); var ix_brnd_left = shouldUseMobileResponsive() ? 'calc(100% - 120px)' : (dimensions.width - 120) + 'px'; var IX_MOBILE_HEIGHT = 230; var IX_DESKTOP_CONTENT_HEIGHT = dimensions.height - 20; function injectProtectiveCSS() { const styleId = 'ix-player-protection-' + ix_ipl_cB; if (document.getElementById(styleId)) { return; } const style = document.createElement('style'); style.id = styleId; let responsiveRules = ''; if (ix_ipl_mbEnabled) { responsiveRules = '\n\ @media (min-width: 769px) {\n\ .ix-player-container:not(.ix-player-floating) {\n\ width: ' + dimensions.width + 'px !important;\n\ height: ' + IX_DESKTOP_CONTENT_HEIGHT + 'px !important;\n\ }\n\ }\n\ @media (max-width: 768px) {\n\ .ix-player-wrapper {\n\ width: 100% !important;\n\ max-width: 100% !important;\n\ box-sizing: border-box !important;\n\ display: block !important;\n\ }\n\ .ix-player-container:not(.ix-player-floating) {\n\ width: 100% !important;\n\ height: ' + IX_MOBILE_HEIGHT + 'px !important;\n\ }\n\ }\n\ '; } else { responsiveRules = '\n\ .ix-player-container:not(.ix-player-floating) {\n\ width: ' + dimensions.width + 'px !important;\n\ height: ' + IX_DESKTOP_CONTENT_HEIGHT + 'px !important;\n\ }\n\ '; } style.textContent = '\n\ .ix-player-container {\n\ box-sizing: border-box !important;\n\ margin: 0 !important;\n\ margin-top: 20px !important;\n\ padding: 0 !important;\n\ border: none !important;\n\ background: transparent !important;\n\ font-family: Arial, sans-serif !important;\n\ font-size: 14px !important;\n\ line-height: normal !important;\n\ color: #000 !important;\n\ text-align: left !important;\n\ display: block !important;\n\ overflow: visible !important;\n\ transform: none !important;\n\ opacity: 1 !important;\n\ visibility: visible !important;\n\ float: none !important;\n\ clear: none !important;\n\ outline: none !important;\n\ filter: none !important;\n\ clip: auto !important;\n\ clip-path: none !important;\n\ position: relative !important;\n\ }\n\ \n\ ' + responsiveRules + '\n\ \n\ .ix-player-close-btn {\n\ position: absolute \n\ top: -20px \n\ left: 0px \n\ width: 30px \n\ height: 20px \n\ margin: 0 !\n\ padding: 0 \n\ background: black \n\ color: white \n\ border: none \n\ cursor: pointer \n\ font-size: small \n\ font-weight: bolder \n\ line-height: 20px \n\ text-align: center \n\ display: none \n\ z-index: 10001 \n\ box-sizing: border-box \n\ transform: none \n\ border-radius: 0 \n\ }\n\ \n\ .ix-player-close-btn:hover {\n\ background: #333 !important;\n\ }\n\ \n\ .ix-player-brand {\n\ all: revert !important;\n\ position: absolute !important;\n\ top: -20px !important;\n\ right: 0 !important;\n\ width: 120px !important;\n\ height: 20px !important;\n\ margin: 0 !important;\n\ padding: 0 !important;\n\ z-index: 10001 !important;\n\ background: transparent !important;\n\ border: none !important;\n\ transform: none !important;\n\ }\n\ \n\ .ix-player-brand img {\n\ margin: 0 !important;\n\ padding: 0 !important;\n\ border: none !important;\n\ width: 120px !important;\n\ height: 20px !important;\n\ display: block !important;\n\ transform: none !important;\n\ border-radius: 0 !important;\n\ }\n\ \n\ .ix-player-container iframe {\n\ all: revert !important;\n\ border: none !important;\n\ margin: 0 !important;\n\ padding: 0 !important;\n\ width: 100% !important;\n\ height: 100% !important;\n\ overflow: hidden !important;\n\ display: block !important;\n\ background: transparent !important;\n\ transform: none !important;\n\ border-radius: 0 !important;\n\ }\n\ \n\ .ix-player-container.ix-player-floating {\n\ position: fixed !important;\n\ z-index: 2147483647 !important;\n\ box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;\n\ margin-top: 0 !important;\n\ }\n\ '; document.head.appendChild(style); } function createPlayerIframe() { injectProtectiveCSS(); var containerHeight = ix_ipl_isMobile ? IX_MOBILE_HEIGHT : IX_DESKTOP_CONTENT_HEIGHT; const containerDiv = document.createElement('div'); containerDiv.id = 'ix-player-container-' + ix_ipl_cB; containerDiv.className = 'ix-player-container'; containerDiv.setAttribute('style', 'position: relative; ' + 'margin: 0; ' + 'margin-top: 20px; ' + 'padding: 0; ' + 'border: none; ' + 'background: transparent; ' + 'box-sizing: border-box; ' + 'display: block; ' + 'transform: none; ' + 'overflow: visible; ' + 'width: ' + (ix_ipl_isMobile ? '100%' : dimensions.width + 'px') + '; ' + 'height: ' + containerHeight + 'px;' ); const playerIframe = document.createElement('iframe'); playerIframe.id = 'ix-player-iframe-' + ix_ipl_cB; playerIframe.name = 'ix-player-frame-' + ix_ipl_cB; playerIframe.setAttribute('frameborder', '0'); playerIframe.setAttribute('scrolling', 'no'); playerIframe.setAttribute('allowfullscreen', 'true'); playerIframe.setAttribute('allow', 'autoplay'); playerIframe.setAttribute('data-ix-player', 'true'); playerIframe.style.cssText = 'border: none; ' + 'margin: 0; ' + 'padding: 0; ' + 'width: 100%; ' + 'height: 100%; ' + 'overflow: hidden; ' + 'display: block; ' + 'background: transparent;'; const closeButton = document.createElement('button'); closeButton.id = 'ix-player-close-' + ix_ipl_cB; closeButton.className = 'ix-player-close-btn'; closeButton.textContent = 'X'; closeButton.setAttribute('style', 'position: absolute; ' + 'top: -20px; ' + 'left: 0; ' + 'width: 30px; ' + 'height: 20px; ' + 'margin: 0; ' + 'padding: 0; ' + 'background: black; ' + 'color: white; ' + 'border: none; ' + 'cursor: pointer; ' + 'font-size: small; ' + 'font-weight: bolder; ' + 'display: none; ' + 'z-index: 10001; ' + 'box-sizing: border-box; ' + 'transform: none; ' + 'border-radius: 0; ' + 'line-height: 20px; ' + 'text-align: center;' ); const floatingBrand = document.createElement('div'); floatingBrand.id = 'ix-player-brand-' + ix_ipl_cB; floatingBrand.className = 'ix-player-brand'; floatingBrand.innerHTML = "IX"; floatingBrand.setAttribute('style', 'position: absolute; ' + 'top: -20px; ' + 'right: 0; ' + 'width: 120px; ' + 'height: 20px; ' + 'margin: 0; ' + 'padding: 0; ' + 'z-index: 10001; ' + 'background: transparent; ' + 'border: none; ' + 'transform: none; ' + 'display: block;' ); containerDiv.appendChild(closeButton); containerDiv.appendChild(floatingBrand); containerDiv.appendChild(playerIframe); if (ix_ipl_mbEnabled && ix_ipl_prnElmnt && ix_ipl_prnElmnt.style) { ix_ipl_prnElmnt.classList.add('ix-player-wrapper'); ix_ipl_prnElmnt.style.setProperty('width', '100%', 'important'); ix_ipl_prnElmnt.style.setProperty('max-width', '100%', 'important'); ix_ipl_prnElmnt.style.setProperty('box-sizing', 'border-box', 'important'); ix_ipl_prnElmnt.style.setProperty('margin', '0', 'important'); } ix_ipl_prnElmnt.appendChild(containerDiv); if (ix_ipl_mbEnabled && typeof ResizeObserver !== 'undefined') { containerDiv._ixLastNotifiedWidth = 0; containerDiv._ixLastNotifiedHeight = 0; var resizeObserver = new ResizeObserver(function (entries) { var iframe = containerDiv.querySelector('iframe'); if (!iframe) return; if (containerDiv.classList.contains('ix-player-floating')) return; for (var i = 0; i < entries.length; i++) { var entry = entries[i]; var newW = Math.round(entry.contentRect.width); var newH = Math.round(entry.contentRect.height); if (newW < 10 || newH < 10) { continue; } if (newW !== containerDiv._ixLastNotifiedWidth || newH !== containerDiv._ixLastNotifiedHeight) { containerDiv._ixLastNotifiedWidth = newW; containerDiv._ixLastNotifiedHeight = newH; ix_ipl_isMobile = newW <= 768 || window.innerWidth <= 768; if (iframe.contentWindow) { iframe.contentWindow.postMessage({ type: 'ix_player_resize', dimensions: { width: newW, height: newH } }, '*'); } } } }); resizeObserver.observe(containerDiv); containerDiv._ixResizeObserver = resizeObserver; } return { containerDiv, playerIframe, closeButton, floatingBrand }; } function initializePlayerInIframe(playerIframe) { if (window.__IX_IFRAME_INIT_DONE__) { return; } window.__IX_IFRAME_INIT_DONE__ = true; const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); const iframeDoc = playerIframe.contentDocument || playerIframe.contentWindow.document; const iframeHTML = "\ \n\ \n\ \n\ \n\ \n\ IX Player\n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\
\n\ \n\ \n\ \n\
\n\ \n\ \n\
\n\
\n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ "; if (isSafari) { const blob = new Blob([iframeHTML], { type: 'text/html' }); const blobUrl = URL.createObjectURL(blob); playerIframe.src = blobUrl; playerIframe.onload = function () { URL.revokeObjectURL(blobUrl); }; } else { iframeDoc.open(); iframeDoc.write(iframeHTML); iframeDoc.close(); } } function getFloatingDimensions() { return { width: 260, height: 150, totalHeight: 150 }; } function setupFloatingBehavior(containerDiv, closeButton, floatingBrand) { var floatingClosed = false; var isFloating = false; var floatingDimensions = getFloatingDimensions(); var floaterMode = ix_ipl_floaterParam || 'r'; var isFloatingEnabled = floaterMode !== '0'; if (!isFloatingEnabled) return; var playerIframe = containerDiv.querySelector('iframe'); var posRight = floaterMode === 'l' ? 'auto' : '20px'; var posLeft = floaterMode === 'l' ? '20px' : 'auto'; var sentinelStyle = 'width: 1px; ' + 'height: 1px; ' + 'margin: 0; ' + 'padding: 0; ' + 'border: none; ' + 'background: transparent; ' + 'visibility: hidden; ' + 'pointer-events: none; ' + 'position: relative; ' + 'display: block;'; var sentinelTop = document.createElement('div'); sentinelTop.id = 'ix-sentinel-top-' + ix_ipl_cB; sentinelTop.setAttribute('style', sentinelStyle); containerDiv.parentNode.insertBefore(sentinelTop, containerDiv); var sentinelBottom = document.createElement('div'); sentinelBottom.id = 'ix-sentinel-bottom-' + ix_ipl_cB; sentinelBottom.setAttribute('style', sentinelStyle); if (containerDiv.nextSibling) { containerDiv.parentNode.insertBefore(sentinelBottom, containerDiv.nextSibling); } else { containerDiv.parentNode.appendChild(sentinelBottom); } var placeholder = document.createElement('div'); placeholder.id = 'ix-placeholder-' + ix_ipl_cB; placeholder.setAttribute('style', 'display: none; ' + 'margin: 0; ' + 'padding: 0; ' + 'border: none; ' + 'background: transparent; ' + 'pointer-events: none;' ); var hasVisitedContainer = false; var topVisible = false; var bottomVisible = false; var dockedContainerStyle = containerDiv.getAttribute('style'); function updateFloatingState() { if (floatingClosed) return; if (!hasVisitedContainer) return; if (!topVisible && !bottomVisible && !isFloating) { goFloat(); } else if ((topVisible || bottomVisible) && isFloating) { goDock(); } } function goFloat() { if (isFloating || floatingClosed) return; isFloating = true; var currentWidth = containerDiv.offsetWidth; var currentHeight = containerDiv.offsetHeight; var currentMarginTop = window.getComputedStyle(containerDiv).marginTop; containerDiv.parentNode.insertBefore(placeholder, containerDiv); placeholder.setAttribute('style', 'display: block; ' + 'width: ' + currentWidth + 'px; ' + 'height: ' + currentHeight + 'px; ' + 'margin: 0; ' + 'margin-top: ' + currentMarginTop + '; ' + 'padding: 0; ' + 'border: none; ' + 'background: transparent; ' + 'pointer-events: none;' ); containerDiv.classList.add('ix-player-floating'); containerDiv.setAttribute('style', 'position: fixed; ' + 'bottom: 120px; ' + 'right: ' + posRight + '; ' + 'left: ' + posLeft + '; ' + 'width: ' + floatingDimensions.width + 'px; ' + 'height: ' + floatingDimensions.totalHeight + 'px; ' + 'z-index: 2147483647; ' + 'box-shadow: 0 4px 12px rgba(0,0,0,0.3); ' + 'margin: 0; ' + 'padding: 0; ' + 'border: none; ' + 'overflow: visible; ' + 'display: block; ' + 'background: transparent; ' + 'box-sizing: border-box;' ); closeButton.style.display = 'block'; if (playerIframe.contentWindow) { playerIframe.contentWindow.postMessage({ type: 'ix_player_set_floating', isFloating: true, dimensions: { width: floatingDimensions.width, height: floatingDimensions.height } }, '*'); } } function goDock() { if (!isFloating) return; isFloating = false; containerDiv.classList.remove('ix-player-floating'); containerDiv.setAttribute('style', dockedContainerStyle); if (placeholder.parentNode) { placeholder.parentNode.removeChild(placeholder); } closeButton.style.display = 'none'; if (playerIframe.contentWindow) { var w = containerDiv.offsetWidth || dimensions.width; var h = containerDiv.offsetHeight || IX_DESKTOP_CONTENT_HEIGHT; playerIframe.contentWindow.postMessage({ type: 'ix_player_set_floating', isFloating: false, dimensions: { width: w, height: h } }, '*'); } } closeButton.addEventListener('click', function () { floatingClosed = true; goDock(); }); if (window.IntersectionObserver) { var topObserver = new IntersectionObserver(function (entries) { var entry = entries[0]; if (!entry) return; topVisible = entry.isIntersecting; if (!hasVisitedContainer && topVisible) { hasVisitedContainer = true; } updateFloatingState(); }, { root: null, rootMargin: '0px', threshold: 0 }); var bottomObserver = new IntersectionObserver(function (entries) { var entry = entries[0]; if (!entry) return; bottomVisible = entry.isIntersecting; if (!hasVisitedContainer && bottomVisible) { hasVisitedContainer = true; } updateFloatingState(); }, { root: null, rootMargin: '0px', threshold: 0 }); topObserver.observe(sentinelTop); bottomObserver.observe(sentinelBottom); var topRect = sentinelTop.getBoundingClientRect(); var bottomRect = sentinelBottom.getBoundingClientRect(); topVisible = topRect.top >= 0 && topRect.top < window.innerHeight; bottomVisible = bottomRect.top >= 0 && bottomRect.top < window.innerHeight; if (topVisible || bottomVisible) { hasVisitedContainer = true; } } var lastKnownWidth = window.innerWidth; window.addEventListener('resize', function () { var newWidth = window.innerWidth; if (newWidth !== lastKnownWidth) { lastKnownWidth = newWidth; if (isFloating) goDock(); } }); } function setupParentVisibilityBridge(playerIframe) { document.addEventListener('visibilitychange', function () { try { if (playerIframe && playerIframe.contentWindow) { playerIframe.contentWindow.postMessage({ type: 'ix_tab_visibility', hidden: document.hidden }, '*'); } } catch (e) { } }); } function ix_ipl_start() { if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', function () { if (!ix_ipl_prnElmnt || ix_ipl_prnElmnt === document.documentElement) { ix_ipl_prnElmnt = getParentElement(); } const { containerDiv, playerIframe, closeButton, floatingBrand } = createPlayerIframe(); setupFloatingBehavior(containerDiv, closeButton, floatingBrand); setupParentVisibilityBridge(playerIframe); var isSafariBrowser = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); if (isSafariBrowser) { initializePlayerInIframe(playerIframe); } else { playerIframe.onload = function () { initializePlayerInIframe(playerIframe); }; if (playerIframe.contentDocument && playerIframe.contentDocument.readyState === 'complete') { initializePlayerInIframe(playerIframe); } } }); } else { if (!ix_ipl_prnElmnt || ix_ipl_prnElmnt === document.documentElement) { ix_ipl_prnElmnt = getParentElement(); } const { containerDiv, playerIframe, closeButton, floatingBrand } = createPlayerIframe(); setupFloatingBehavior(containerDiv, closeButton, floatingBrand); setupParentVisibilityBridge(playerIframe); var isSafariBrowser = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); if (isSafariBrowser) { initializePlayerInIframe(playerIframe); } else { playerIframe.onload = function () { initializePlayerInIframe(playerIframe); }; setTimeout(function () { initializePlayerInIframe(playerIframe); }, 0); } } } ix_ipl_start();