in public/content.js [87:129]
function createOrUpdateLoginModal() {
let modal = document.getElementById('resVaultLoginModal');
const modalContent = generateLoginModalContent();
if (!modal) {
// Create the modal if it doesn't exist
modal = document.createElement('div');
modal.id = 'resVaultLoginModal';
modal.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 1000;
display: block;
`;
modal.innerHTML = modalContent;
document.body.appendChild(modal);
// Attach a single event listener to the modal for event delegation
modal.addEventListener('click', async (event) => {
if (event.target.id === 'resVaultLoginModalClose') {
modal.style.display = 'none';
} else if (event.target.id === 'resVaultLoginModalAuthenticate') {
const isConnected = await checkConnectionStatus();
if (isConnected) {
handleLoginTransactionSubmit();
} else {
sendMessageToPage('error');
}
modal.style.display = 'none';
}
});
} else {
// Update the modal content if it already exists
modal.innerHTML = modalContent;
modal.style.display = 'block'; // Ensure the modal is visible again
}
return modal;
}