diff --git a/static/css/components/modal.css b/static/css/components/modal.css index a88edff..45f9929 100644 --- a/static/css/components/modal.css +++ b/static/css/components/modal.css @@ -26,7 +26,22 @@ } .modal-header { - margin-bottom: 1.5rem; + padding: 1rem; + border-bottom: 1px solid rgba(255, 255, 255, 0.1); +} + +.modal-header.error { + color: var(--primary-red); +} + +.modal-header.error h2 { + display: flex; + align-items: center; + gap: 0.5rem; +} + +.modal-header.error i { + font-size: 1.2em; } .modal-header h2 { diff --git a/static/js/app.js b/static/js/app.js index 0aab649..f04e896 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -32,6 +32,36 @@ document.addEventListener('DOMContentLoaded', function() { } }); + // Error modal functionality + const errorModal = document.getElementById('errorModal'); + const errorModalMessage = document.getElementById('errorModalMessage'); + const errorModalClose = document.getElementById('errorModalClose'); + + function showError(message) { + errorModalMessage.textContent = message; + errorModal.classList.add('show'); + } + + function hideError() { + errorModal.classList.remove('show'); + } + + errorModalClose.addEventListener('click', hideError); + + // Close error modal when clicking outside + errorModal.addEventListener('click', (e) => { + if (e.target === errorModal) { + hideError(); + } + }); + + // Close error modal when pressing escape + document.addEventListener('keydown', (e) => { + if (e.key === 'Escape' && errorModal.classList.contains('show')) { + hideError(); + } + }); + // OPML import handlers opmlFileInput.addEventListener('change', async (e) => { if (e.target.files.length > 0) { @@ -48,20 +78,20 @@ document.addEventListener('DOMContentLoaded', function() { if (response.ok) { const result = await response.json(); if (result.success) { - alert('OPML import successful: ' + result.message); + showError('OPML import successful: ' + result.message); // Refresh the feed list if feeds were imported if (result.feeds_imported) { handleFeeds(); } } else { - alert('OPML import failed: ' + result.message); + showError('OPML import failed: ' + result.message); } } else { - alert('Failed to import OPML file. Please try again.'); + showError('Failed to import OPML file. Please try again.'); } } catch (error) { console.error('OPML import failed:', error); - alert('Failed to import OPML file. Please try again.'); + showError('Failed to import OPML file. Please try again.'); } } // Clear the input so the same file can be selected again diff --git a/templates/index.html.tera b/templates/index.html.tera index 44578ad..b347450 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -35,6 +35,21 @@ + + + + +