function openSmartPopup(url, title, width = 800, height = 600) // Prevent double-popup if already open if (window.popupRef && !window.popupRef.closed) window.popupRef.focus(); return window.popupRef; // Center the window const left = (screen.width - width) / 2; const top = (screen.height - height) / 2;
// Use it const win = window.open('/help', 'HelpWindow', getCenteredFeatures(900, 650)); window.open features
return popup;
// Optional: Auto-clean reference when closed const checkClosed = setInterval(() => if (popup.closed) clearInterval(checkClosed); if (window.popupRef === popup) window.popupRef = null; function openSmartPopup(url, title, width = 800, height =