// script-modularized/modal.js export function showModal(id) { if (id === 'loginModal') { console.trace('showModal(\'loginModal\') called'); } const modal = document.getElementById(id); if (modal) modal.style.display = 'flex'; else console.error(`Modal with ID ${id} not found.`); } export function hideModal(id) { const modal = document.getElementById(id); if (modal) modal.style.display = 'none'; else console.error(`Modal with ID ${id} not found.`); } // Function to check if a modal is currently open/visible export function isModalOpen(modalId) { const modal = document.getElementById(modalId); // Check if the modal exists and its display style is not 'none' return modal && modal.style.display !== 'none'; } export function showMessage(title, content) { document.getElementById('messageModalTitle').textContent = title; document.getElementById('messageModalContent').textContent = content; } const confirmModalEl = document.getElementById('confirmModal'); const confirmProceedBtn = document.getElementById('confirmProceedBtn'); const confirmCancelBtn = document.getElementById('confirmCancelBtn'); export function showConfirm(title, message) { console.log('showConfirm function called with title:', title); console.log('showConfirm called with message:', message); return new Promise((resolve) => { document.getElementById('confirmModalTitle').textContent = title; document.getElementById('confirmModalContent').textContent = message; const handleProceed = () => { console.log('Confirm button clicked for:', message); hideModal('confirmModal'); resolve(true); }; const handleCancel = () => { console.log('Cancel button clicked for:', message); hideModal('confirmModal'); resolve(false); // Resolve with false on cancel }; confirmProceedBtn.addEventListener('click', handleProceed, { once: true }); confirmCancelBtn.addEventListener('click', handleCancel, { once: true }); showModal('confirmModal'); }); }