|
| 1 | +// Variables |
| 2 | +var terminal = document.getElementById('terminal'); |
| 3 | +var frostedRectangle = document.querySelector('.frosted-rectangle'); |
| 4 | +var terminal = document.getElementById('terminal'); |
| 5 | + |
| 6 | +// Event Listeners |
| 7 | +document.addEventListener('DOMContentLoaded', () => { |
| 8 | + // Toggle terminal visibility on button click |
| 9 | + setupTerminalToggle(); |
| 10 | + |
| 11 | + // Toggle senders-text visibility on arrow click |
| 12 | + setupSendersTextToggle(); |
| 13 | + |
| 14 | + // Toggle settings-text visibility on arrow click |
| 15 | + setupSettingsTextToggle(); |
| 16 | + |
| 17 | + // Add and remove account input fields |
| 18 | + setupAccountFields(); |
| 19 | +}); |
| 20 | + |
| 21 | +// Add event listener to the API key input |
| 22 | +var apiKeyInput = document.getElementById('api-key-input'); |
| 23 | +apiKeyInput.addEventListener('input', function () { |
| 24 | + if (this.value) { |
| 25 | + this.classList.add('no-underline'); |
| 26 | + } else { |
| 27 | + this.classList.remove('no-underline'); |
| 28 | + } |
| 29 | +}); |
| 30 | + |
| 31 | +// Functions |
| 32 | +function setupTerminalToggle() { |
| 33 | + const terminalToggleButton = document.getElementById('terminal-toggle-button'); |
| 34 | + const settingsButton = document.getElementById('settings-button'); |
| 35 | + const centeredContainer = document.querySelector('.centered-container'); |
| 36 | + const settingsContainer = document.querySelector('.settings-container'); |
| 37 | + const terminal = document.getElementById('terminal'); |
| 38 | + |
| 39 | + terminalToggleButton.addEventListener('click', () => { |
| 40 | + terminal.classList.toggle('blurred'); |
| 41 | + centeredContainer.classList.toggle('hidden'); |
| 42 | + settingsButton.classList.toggle('hidden'); |
| 43 | + if (!settingsContainer.classList.contains('hidden')) { |
| 44 | + settingsContainer.classList.add('hidden'); |
| 45 | + } |
| 46 | + }); |
| 47 | + |
| 48 | + settingsButton.addEventListener('click', () => { |
| 49 | + centeredContainer.classList.toggle('hidden'); |
| 50 | + settingsContainer.classList.toggle('hidden'); |
| 51 | + terminalToggleButton.classList.toggle('hidden'); |
| 52 | + }); |
| 53 | +} |
| 54 | + |
| 55 | +function setupSendersTextToggle() { |
| 56 | + var arrow = document.getElementById('arrow'); |
| 57 | + var sendersText = document.getElementById('senders-text'); |
| 58 | + |
| 59 | + arrow.addEventListener('click', function() { |
| 60 | + sendersText.classList.toggle('expanded'); |
| 61 | + arrow.style.transform = sendersText.classList.contains('expanded') ? 'rotate(180deg)' : 'rotate(0deg)'; |
| 62 | + }); |
| 63 | +} |
| 64 | + |
| 65 | +function setupSettingsTextToggle() { |
| 66 | + const openaiHeader = document.getElementById('openai-arrow'); |
| 67 | + const openaiText = document.getElementById('openai-text'); |
| 68 | + const accountsHeader = document.getElementById('accounts-arrow'); |
| 69 | + const accountsText = document.getElementById('accounts-text'); |
| 70 | + const apiKeyInput = document.getElementById('api-key-input'); |
| 71 | + const checkMark = document.createElement('span'); |
| 72 | + checkMark.innerHTML = '✔'; // Check mark character |
| 73 | + checkMark.classList.add('check-mark'); |
| 74 | + |
| 75 | + apiKeyInput.parentNode.insertBefore(checkMark, apiKeyInput.nextSibling); |
| 76 | + |
| 77 | + openaiHeader.addEventListener('click', () => { |
| 78 | + openaiText.classList.toggle('expanded'); |
| 79 | + openaiHeader.style.transform = openaiText.classList.contains('expanded') ? 'rotate(180deg)' : ''; |
| 80 | + }); |
| 81 | + |
| 82 | + accountsHeader.addEventListener('click', () => { |
| 83 | + accountsText.classList.toggle('expanded'); |
| 84 | + accountsHeader.style.transform = accountsText.classList.contains('expanded') ? 'rotate(180deg)' : ''; |
| 85 | + }); |
| 86 | + |
| 87 | + apiKeyInput.addEventListener('input', () => { |
| 88 | + if (apiKeyInput.value) { |
| 89 | + checkMark.style.display = 'inline'; |
| 90 | + apiKeyInput.classList.add('filled'); |
| 91 | + } else { |
| 92 | + checkMark.style.display = 'none'; |
| 93 | + apiKeyInput.classList.remove('filled'); |
| 94 | + } |
| 95 | + }); |
| 96 | + |
| 97 | + apiKeyInput.addEventListener('blur', () => { |
| 98 | + checkMark.style.display = 'none'; |
| 99 | + }); |
| 100 | + |
| 101 | + checkMark.addEventListener('click', () => { |
| 102 | + // Confirm the changes here (e.g., save the API key) |
| 103 | + checkMark.style.display = 'none'; |
| 104 | + }); |
| 105 | +} |
| 106 | + |
| 107 | +function setupAccountFields() { |
| 108 | + const addAccountBtn = document.querySelector('.add-account'); |
| 109 | + const removeAccountBtn = document.querySelector('.remove-account'); |
| 110 | + const accountList = document.querySelector('.account-list'); |
| 111 | + const emailProviders = { |
| 112 | + "gmail": "imap.gmail.com", |
| 113 | + "outlook": "imap-mail.outlook.com", |
| 114 | + "yahoo": "imap.mail.yahoo.com", |
| 115 | + "aol": "imap.aol.com", |
| 116 | + "icloud": "imap.mail.me.com", |
| 117 | + "zoho": "imap.zoho.com", |
| 118 | + "gmx": "imap.gmx.com", |
| 119 | + "fastmail": "imap.fastmail.com", |
| 120 | + "protonmail": "imap.protonmail.com", // ProtonMail requires a paid plan and Bridge for IMAP access |
| 121 | + "office365": "outlook.office365.com", |
| 122 | + "mailru": "imap.mail.ru", |
| 123 | + "yandex": "imap.yandex.com", |
| 124 | + "cpanel": "mail.yourdomain.com", // Replace 'yourdomain.com' with your actual domain |
| 125 | + "dovecot": "mail.yourdomain.com", // Replace 'yourdomain.com' with your actual domain |
| 126 | + "courier": "mail.yourdomain.com", // Replace 'yourdomain.com' with your actual domain |
| 127 | + "hmailserver": "mail.yourdomain.com", // Replace 'yourdomain.com' with your actual domain |
| 128 | + }; |
| 129 | + |
| 130 | + addAccountBtn.addEventListener('click', () => { |
| 131 | + const accountDiv = document.createElement('div'); |
| 132 | + accountDiv.classList.add('account'); |
| 133 | + |
| 134 | + const emailInput = document.createElement('input'); |
| 135 | + emailInput.type = 'email'; |
| 136 | + emailInput.placeholder = 'Email'; |
| 137 | + emailInput.classList.add('account-input'); |
| 138 | + |
| 139 | + const passwordInput = document.createElement('input'); |
| 140 | + passwordInput.type = 'password'; |
| 141 | + passwordInput.placeholder = 'Password'; |
| 142 | + passwordInput.classList.add('account-input'); |
| 143 | + |
| 144 | + const providerSelect = document.createElement('select'); |
| 145 | + providerSelect.classList.add('provider-select'); |
| 146 | + |
| 147 | + for (const provider in emailProviders) { |
| 148 | + const option = document.createElement('option'); |
| 149 | + option.value = emailProviders[provider]; |
| 150 | + option.textContent = provider; |
| 151 | + providerSelect.appendChild(option); |
| 152 | + } |
| 153 | + |
| 154 | + accountDiv.appendChild(emailInput); |
| 155 | + accountDiv.appendChild(passwordInput); |
| 156 | + accountDiv.appendChild(providerSelect); |
| 157 | + accountList.appendChild(accountDiv); |
| 158 | + }); |
| 159 | + |
| 160 | + removeAccountBtn.addEventListener('click', () => { |
| 161 | + if (accountList.childElementCount > 0) { |
| 162 | + accountList.removeChild(accountList.lastChild); |
| 163 | + } |
| 164 | + }); |
| 165 | +} |
| 166 | + |
| 167 | +function updateLogs() { |
| 168 | + // ... existing code ... |
| 169 | +} |
| 170 | + |
| 171 | +// Simulate receiving the summary after 3 seconds |
| 172 | +setTimeout(function() { |
| 173 | + // Add the summary text below the existing text in the frosted rectangle |
| 174 | + var summary = document.createElement('p'); |
| 175 | + summary.textContent = 'This is a paragraph summary returned by OpenAI.'; |
| 176 | + frostedRectangle.appendChild(summary); |
| 177 | + |
| 178 | + // Animate the frosted rectangle by increasing its max-height |
| 179 | + frostedRectangle.style.maxHeight = '800px'; |
| 180 | + frostedRectangle.style.paddingBottom = '40px'; |
| 181 | +}, 3000); |
0 commit comments