From 28e955c9460ad4a4f0ebc6f6cd75654027bbdb69 Mon Sep 17 00:00:00 2001 From: Glenn Sorrentino Date: Sat, 18 May 2024 12:20:54 -0700 Subject: [PATCH] remove old js --- src/js/client-side-encryption.js | 47 -------------------------------- src/js/inbox.js | 9 ------ src/js/mailvelope.js | 22 --------------- src/js/settings.js | 33 ---------------------- 4 files changed, 111 deletions(-) delete mode 100644 src/js/client-side-encryption.js delete mode 100644 src/js/inbox.js delete mode 100644 src/js/mailvelope.js delete mode 100644 src/js/settings.js diff --git a/src/js/client-side-encryption.js b/src/js/client-side-encryption.js deleted file mode 100644 index 606a172..0000000 --- a/src/js/client-side-encryption.js +++ /dev/null @@ -1,47 +0,0 @@ -document.addEventListener('DOMContentLoaded', function() { - // Client-side encryption - const form = document.getElementById('messageForm'); - const messageField = document.querySelector('textarea[name="content"]'); - const encryptedFlag = document.getElementById('clientSideEncrypted'); - const publicKeyArmored = document.getElementById('publicKey') ? document.getElementById('publicKey').value : ''; - - async function encryptMessage(publicKeyArmored, message) { - if (!publicKeyArmored) { - console.log('Public key not provided for encryption. Encryption cannot proceed.'); - return false; - } - - try { - const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored }); - const messageText = await openpgp.createMessage({ text: message }); - const encryptedMessage = await openpgp.encrypt({ - message: messageText, - encryptionKeys: publicKey, - }); - console.log('Message encrypted client-side successfully.'); - return encryptedMessage; - } catch (error) { - console.error('Error encrypting message:', error); - return false; - } - } - - if (form) { - form.addEventListener('submit', async function(event) { - event.preventDefault(); - - const messageWithNote = messageField.value; - const encryptedMessage = await encryptMessage(publicKeyArmored, messageWithNote); - - if (encryptedMessage) { - messageField.value = encryptedMessage; - encryptedFlag.value = 'true'; - form.submit(); // Programmatically submit the form - } else { - console.log('Client-side encryption failed, submitting plaintext.'); - encryptedFlag.value = 'false'; - form.submit(); // Submit the plaintext message for potential server-side encryption - } - }); - } -}); diff --git a/src/js/inbox.js b/src/js/inbox.js deleted file mode 100644 index b43936b..0000000 --- a/src/js/inbox.js +++ /dev/null @@ -1,9 +0,0 @@ -document.addEventListener('DOMContentLoaded', function() { - // Handle message deletion confirmation - document.getElementById('deleteMessageButton')?.addEventListener('click', function(event) { - const confirmed = confirm('Are you sure you want to delete this message? This cannot be undone.'); - if (!confirmed) { - event.preventDefault(); - } - }); -}); diff --git a/src/js/mailvelope.js b/src/js/mailvelope.js deleted file mode 100644 index 5bb5522..0000000 --- a/src/js/mailvelope.js +++ /dev/null @@ -1,22 +0,0 @@ -document.addEventListener('DOMContentLoaded', function() { - // Mailvelope decryption logic - const encryptedMessages = document.querySelectorAll('.message.encrypted'); - encryptedMessages.forEach(messageElement => { - const encryptedContent = messageElement.dataset.encryptedContent; - const decryptionContainer = messageElement.querySelector('.mailvelope-decryption-container'); - - if (window.mailvelope) { - mailvelope.createDisplayContainer({ - id: decryptionContainer.getAttribute('id'), - encryptedMsg: encryptedContent, - }).then(displayContainer => { - messageElement.querySelector('.decrypted-content').style.display = 'none'; - decryptionContainer.appendChild(displayContainer.element); - }).catch(error => { - console.error('Decryption error:', error); - }); - } else { - console.log('Mailvelope not detected'); - } - }); -}); diff --git a/src/js/settings.js b/src/js/settings.js deleted file mode 100644 index a62be04..0000000 --- a/src/js/settings.js +++ /dev/null @@ -1,33 +0,0 @@ -document.addEventListener('DOMContentLoaded', function() { - // Tab functionality - const tabs = document.querySelectorAll('.tab'); - const tabContents = document.querySelectorAll('.tab-content'); - - function removeActiveClasses() { - tabs.forEach(tab => tab.classList.remove('active')); - tabContents.forEach(content => content.style.display = 'none'); - } - - tabs.forEach(tab => { - tab.addEventListener('click', function() { - removeActiveClasses(); - this.classList.add('active'); - const activeTabContent = document.getElementById(this.getAttribute('data-tab')); - if (activeTabContent) { - activeTabContent.style.display = 'block'; - } - }); - }); - - if (tabs.length > 0) { - tabs[0].click(); // Open the first tab automatically - } - - // Deletion account confirmation logic - document.getElementById('deleteAccountButton')?.addEventListener('click', function(event) { - const confirmed = confirm('Are you sure you want to delete your account? This cannot be undone.'); - if (!confirmed) { - event.preventDefault(); - } - }); -});