@@ -319,7 +319,15 @@ <h1>Hello World!</h1>
319319 </ div >
320320 </ div >
321321 </ div >
322-
322+ < div class ="news-bar " id ="live-news-bar ">
323+ < div class ="ticker-wrapper ">
324+ < div class ="ticker-text " id ="ticker-content ">
325+ Fetching latest intelligence... < span > [ CONNECTING ]</ span >
326+ Establishing secure uplink... < span > [ STATUS ]</ span >
327+ Syncing with global servers...
328+ </ div >
329+ </ div >
330+ </ div >
323331 < script >
324332 const glow = document . getElementById ( 'glow-cursor' ) ;
325333 const card = document . getElementById ( 'tilt-card' ) ;
@@ -350,6 +358,34 @@ <h1>Hello World!</h1>
350358 card . addEventListener ( 'mouseenter' , ( ) => {
351359 card . style . transition = "none" ;
352360 } ) ;
361+ async function fetchNews ( ) {
362+ const ticker = document . getElementById ( 'ticker-content' ) ;
363+ // Using rss2json to convert the RSS feed to a format JS can read
364+ const rssUrl = 'https://www.theverge.com' ;
365+ const apiUrl = `https://api.rss2json.com{encodeURIComponent(rssUrl)}` ;
366+
367+ try {
368+ const response = await fetch ( apiUrl ) ;
369+ const data = await response . json ( ) ;
370+
371+ if ( data . status === 'ok' ) {
372+ // Join the news titles with your styled spans
373+ const headlines = data . items . map ( item =>
374+ `<span>[ ${ item . pubDate . split ( ' ' ) [ 0 ] } ]</span> ${ item . title . toUpperCase ( ) } `
375+ ) . join ( ' ••• ' ) ;
376+
377+ ticker . innerHTML = headlines + " ••• " + headlines ; // Double it for a smooth loop
378+ }
379+ } catch ( error ) {
380+ ticker . innerHTML = "<span>[ ERROR ]</span> Failed to sync live news. Operating in offline mode." ;
381+ console . error ( 'News Fetch Error:' , error ) ;
382+ }
383+ }
384+
385+ // Run the fetch when the page loads
386+ fetchNews ( ) ;
387+ // Refresh every 10 minutes
388+ setInterval ( fetchNews , 600000 ) ;
353389 </ script >
354390</ body >
355391</ html >
0 commit comments