AIBusiness.news | Latest in AI Technology

Featured AI Stories

Florida Medical Device Symposium

Latest AI News

Loading latest news...

AI News Feed

Live

Loading feed...

Subscribe to Updates

Get the latest AI news delivered to your inbox weekly.

© 2023 AIBusiness.news. All rights reserved.

document.addEventListener('DOMContentLoaded', function() { // Function to fetch and display RSS feed (right column) async function fetchRSSFeed() { const rssFeedContainer = document.getElementById('rss-feed'); try { // Replace this URL with your actual RSS feed URL const response = await fetch('https://cors-anywhere.herokuapp.com/https://www.artificialintelligence-news.com/feed/'); const data = await response.text(); const parser = new DOMParser(); const xml = parser.parseFromString(data, 'application/xml'); const items = xml.querySelectorAll('item'); // Clear loading indicator rssFeedContainer.innerHTML = ''; // Get the first 5 items or all if less than 5 const displayCount = Math.min(items.length, 5); for (let i = 0; i < displayCount; i++) { const item = items[i]; const title = item.querySelector('title').textContent; const link = item.querySelector('link').textContent; const pubDate = new Date(item.querySelector('pubDate').textContent); const timeAgo = getTimeAgo(pubDate); const feedItem = document.createElement('div'); feedItem.className = 'border-b border-gray-200 pb-3 mb-3 last:border-0 last:mb-0 last:pb-0'; feedItem.innerHTML = `

${title}

${timeAgo}
`; rssFeedContainer.appendChild(feedItem); } } catch (error) { console.error('Error fetching RSS feed:', error); rssFeedContainer.innerHTML = '

Error loading feed. Please try again later.

'; } } // Function to fetch and display latest news (middle section) async function fetchLatestNews() { const newsContainer = document.getElementById('latest-news-grid'); try { // For demo purposes, creating mock news data // In production, replace this with actual API fetch const newsData = [ { title: "Google's DeepMind Achieves Breakthrough in Protein Folding", description: "AI system solves one of biology's grand challenges, predicting protein structures with unprecedented accuracy.", category: "Research", timeAgo: "2 hours ago", imageUrl: "https://via.placeholder.com/300x200" }, { title: "Microsoft Invests $1 Billion in OpenAI Partnership", description: "Tech giant backs leading AI research lab to develop artificial general intelligence technologies.", category: "Business", timeAgo: "5 hours ago", imageUrl: "https://via.placeholder.com/300x200" }, { title: "AI Startups Raised Record $33 Billion in Funding This Year", description: "Venture capital investments in artificial intelligence hit all-time high despite economic headwinds.", category: "Finance", timeAgo: "1 day ago", imageUrl: "https://via.placeholder.com/300x200" }, { title: "New EU AI Regulations Could Reshape Global Standards", description: "Proposed rules focus on transparency, accountability, and risk-based approach to AI governance.", category: "Policy", timeAgo: "2 days ago", imageUrl: "https://via.placeholder.com/300x200" }, { title: "Stanford Launches Advanced AI Research Center", description: "Leading university establishes dedicated institute focused on responsible AI development.", category: "Education", timeAgo: "3 days ago", imageUrl: "https://via.placeholder.com/300x200" }, { title: "AI-Generated Art Wins Major Competition, Sparks Controversy", description: "Digital artwork created using neural networks beats human competitors, raising questions about creativity.", category: "Culture", timeAgo: "4 days ago", imageUrl: "https://via.placeholder.com/300x200" } ]; // Clear loading indicator newsContainer.innerHTML = ''; // Add each news item to the grid newsData.forEach(item => { const newsCard = document.createElement('div'); newsCard.className = 'article-card bg-white rounded-xl overflow-hidden shadow-md hover:shadow-lg transition'; newsCard.innerHTML = ` ${item.title}
${item.category}

${item.title}

${item.description}

${item.timeAgo} Read more
`; newsContainer.appendChild(newsCard); }); } catch (error) { console.error('Error fetching latest news:', error); newsContainer.innerHTML = '

Error loading news. Please try again later.

'; } } // Helper function to get time ago function getTimeAgo(date) { const seconds = Math.floor((new Date() - date) / 1000); let interval = seconds / 31536000; if (interval > 1) return Math.floor(interval) + " years ago"; interval = seconds / 2592000; if (interval > 1) return Math.floor(interval) + " months ago"; interval = seconds / 86400; if (interval > 1) return Math.floor(interval) + " days ago"; interval = seconds / 3600; if (interval > 1) return Math.floor(interval) + " hours ago"; interval = seconds / 60; if (interval > 1) return Math.floor(interval) + " minutes ago"; return Math.floor(seconds) + " seconds ago"; } // Load both feeds when page loads fetchRSSFeed(); fetchLatestNews(); // Add refresh functionality document.getElementById('refresh-news').addEventListener('click', function() { const newsContainer = document.getElementById('latest-news-grid'); newsContainer.innerHTML = `

Loading latest news...

`; // Add a small delay to show the loading animation setTimeout(fetchLatestNews, 800); }); });