`; iframe.srcdoc = iframeContent; adContainer.appendChild(iframe); dialogContent.appendChild(closeButton); dialogContent.appendChild(title); dialogContent.appendChild(adContainer); _adIframeDialog.appendChild(dialogContent); document.body.appendChild(_adIframeDialog); } else { // Update existing iframe with new ad slot const iframe = document.getElementById('ad-iframe'); if (iframe) { const iframeContent = `
`; iframe.srcdoc = iframeContent; } } // Show dialog with fade-in animation setTimeout(() => { _adIframeDialog.style.opacity = '1'; }, 10); // Auto-close after 5 seconds (optional, can be removed if you want manual close only) if (_adIframeCloseTimer) { clearTimeout(_adIframeCloseTimer); } // Uncomment the following lines if you want auto-close after 5 seconds // _adIframeCloseTimer = setTimeout(() => { // closeAdIframeDialog(); // }, 5000); console.log('✅ [AD_IFRAME] Dialog shown successfully'); } function closeAdIframeDialog() { console.log('🔄 [AD_IFRAME] Closing iframe ad dialog'); if (_adIframeDialog) { _adIframeDialog.style.opacity = '0'; setTimeout(() => { if (_adIframeDialog && _adIframeDialog.parentNode) { _adIframeDialog.parentNode.removeChild(_adIframeDialog); _adIframeDialog = null; } }, 300); } if (_adIframeCloseTimer) { clearTimeout(_adIframeCloseTimer); _adIframeCloseTimer = null; } console.log('✅ [AD_IFRAME] Dialog closed successfully'); } // Make functions available globally for Flutter to call window.showAdIframeDialog = showAdIframeDialog; window.closeAdIframeDialog = closeAdIframeDialog;