(function () { if (window.__externalWarningInitialized) return; window.__externalWarningInitialized = true; const allowedDomains = [ 'scu.edu', 'docs.google.com', 'qualtrics.com' ]; function isExternalWarningLink(link) { const href = link.getAttribute('href'); if (!href) return false; if (href.startsWith('#')) return false; if (href.startsWith('mailto:')) return false; if (href.startsWith('tel:')) return false; if (href.startsWith('javascript:')) return false; const url = new URL(href, window.location.href); const hostname = url.hostname.toLowerCase(); return !allowedDomains.some(function (domain) { return hostname === domain || hostname.endsWith('.' + domain); }); } function createModal() { if (document.getElementById('externalSiteWarningModal')) return; const modal = document.createElement('div'); modal.id = 'externalSiteWarningModal'; modal.innerHTML = ` `; document.body.appendChild(modal); if (!document.getElementById('externalSiteWarningStyles')) { const style = document.createElement('style'); style.id = 'externalSiteWarningStyles'; style.innerHTML = ` .ext-warning-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: none; align-items: center; justify-content: center; z-index: 999999; } .ext-warning-overlay.active { display: flex; } .ext-warning-modal { background: #fff; max-width: 700px; width: 90%; border-radius: 6px; box-shadow: 0 4px 20px rgba(0,0,0,0.25); overflow: hidden; } .ext-warning-header, .ext-warning-body, .ext-warning-footer { padding: 1rem; } .ext-warning-header h2 { margin: 0; font-size: 1.25rem; } .ext-warning-body p { margin: 0; padding: 0.75rem 1.25rem; border-radius: .25rem; background: #fff3cd; } .ext-warning-footer { display: flex; justify-content: flex-end; gap: 0.5rem; } .ext-warning-cancel, .ext-warning-proceed { padding: 0.5rem 1rem; border-radius: 4px; border: 0; cursor: pointer; text-decoration: none; font: inherit; } .ext-warning-cancel { background: #6c757d; color: #fff; } .ext-warning-proceed { background: #b30738; color: #fff; } `; document.head.appendChild(style); } } function init() { createModal(); const modal = document.getElementById('externalSiteWarningModal'); const overlay = modal.querySelector('.ext-warning-overlay'); const proceedLink = modal.querySelector('.ext-warning-proceed'); const cancelButton = modal.querySelector('.ext-warning-cancel'); function openModal(href) { proceedLink.setAttribute('href', href); overlay.classList.add('active'); overlay.setAttribute('aria-hidden', 'false'); cancelButton.focus(); } function closeModal() { overlay.classList.remove('active'); overlay.setAttribute('aria-hidden', 'true'); proceedLink.setAttribute('href', '#'); } cancelButton.addEventListener('click', closeModal); overlay.addEventListener('click', function (event) { if (event.target === overlay) closeModal(); }); document.addEventListener('keydown', function (event) { if (event.key === 'Escape') closeModal(); }); document.addEventListener('click', function (event) { const link = event.target.closest('a'); if (!link) return; if (link.closest('#externalSiteWarningModal')) return; if (!isExternalWarningLink(link)) return; event.preventDefault(); openModal(link.getAttribute('href')); }); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } })();