rss-reader/static/js/app.js

51 lines
1.3 KiB
JavaScript
Raw Normal View History

2025-02-02 01:23:21 -08:00
// Logout functionality
document.getElementById('logoutButton').addEventListener('click', async () => {
try {
const response = await fetch('/logout', {
method: 'POST',
});
if (response.ok) {
window.location.href = '/login';
}
} catch (error) {
console.error('Logout failed:', error);
}
});
// Modal functionality
const modal = document.getElementById('addFeedModal');
const addFeedButton = document.getElementById('addFeedButton');
const cancelButton = document.getElementById('cancelAddFeed');
const confirmButton = document.getElementById('confirmAddFeed');
const addFeedForm = document.getElementById('addFeedForm');
function showModal() {
modal.classList.add('show');
}
function hideModal() {
modal.classList.remove('show');
addFeedForm.reset();
}
addFeedButton.addEventListener('click', showModal);
cancelButton.addEventListener('click', hideModal);
// Close modal when clicking outside
modal.addEventListener('click', (e) => {
if (e.target === modal) {
hideModal();
}
});
confirmButton.addEventListener('click', async () => {
const feedUrl = document.getElementById('feedUrl').value;
if (!feedUrl) {
return;
}
// TODO: Add API endpoint integration here
console.log('Feed URL to add:', feedUrl);
hideModal();
});