News Aggregator

Generated on: ${new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })}

`; if (currentNews.length === 0) { pdfContent += `

No news available for download.

`; } else { currentNews.forEach(article => { pdfContent += `

${article.title}

${article.description}

Source: ${article.source} Date: ${new Date(article.date).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })}

Read Original Article

`; }); } element.innerHTML = pdfContent; html2pdf().from(element).save('News_Aggregator_Report.pdf'); } // Event Listeners searchButton.onclick = searchNews; searchInput.addEventListener('keypress', function(event) { if (event.key === 'Enter') { searchNews(); } }); categoryButtons.forEach(button => { button.onclick = function() { const category = this.dataset.category; filterNewsByCategory(category); }; }); downloadPdfButton.onclick = downloadPdf; // Initial display of all news displayNews(allNews); });
Scroll to Top