<!DOCTYPE html>

<html lang="en">

<head>

  <meta charset="UTF-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>Live Finance News Gadget</title>

  <style>

    :root {

      --bg: #ffffff;

      --text: #202124;

      --border: #dadce0;

      --accent: #1a73e8;

      --green: #137333;

      --red: #c5221f;

    }


    @media (prefers-color-scheme: dark) {

      :root {

        --bg: #202124;

        --text: #e8eaed;

        --border: #5f6368;

      }

    }


    body {

      font-family: 'Roboto', system-ui, sans-serif;

      background: var(--bg);

      color: var(--text);

      margin: 0;

      padding: 20px;

      display: flex;

      justify-content: center;

    }


    .finance-gadget {

      width: 100%;

      max-width: 420px;

      background: var(--bg);

      border: 1px solid var(--border);

      border-radius: 12px;

      box-shadow: 0 4px 12px rgba(0,0,0,0.1);

      overflow: hidden;

    }


    .header {

      background: var(--accent);

      color: white;

      padding: 14px 16px;

      font-size: 18px;

      font-weight: 500;

      display: flex;

      align-items: center;

      justify-content: space-between;

    }


    .header::after {

      content: "LIVE";

      font-size: 12px;

      background: rgba(255,255,255,0.3);

      padding: 2px 8px;

      border-radius: 12px;

      font-weight: 600;

    }


    .news-container {

      max-height: 520px;

      overflow-y: auto;

      padding: 8px 0;

    }


    .news-item {

      padding: 14px 16px;

      border-bottom: 1px solid var(--border);

      display: flex;

      gap: 12px;

      transition: background 0.2s;

    }


    .news-item:hover {

      background: rgba(26, 115, 232, 0.08);

    }


    .news-content {

      flex: 1;

    }


    .news-title {

      font-size: 15px;

      line-height: 1.3;

      margin: 0 0 6px 0;

      font-weight: 500;

    }


    .news-title a {

      color: inherit;

      text-decoration: none;

    }


    .news-title a:hover {

      text-decoration: underline;

    }


    .meta {

      font-size: 13px;

      color: #70757a;

      display: flex;

      align-items: center;

      gap: 8px;

      flex-wrap: wrap;

    }


    .ticker {

      font-weight: 600;

      font-size: 13px;

      padding: 1px 6px;

      border-radius: 4px;

      background: rgba(0,0,0,0.08);

    }


    .change {

      font-weight: 600;

    }


    .positive { color: var(--green); }

    .negative { color: var(--red); }


    .footer {

      padding: 10px 16px;

      text-align: center;

      font-size: 12px;

      color: #70757a;

      border-top: 1px solid var(--border);

    }


    .loading {

      text-align: center;

      padding: 30px;

      color: #70757a;

    }

  </style>

</head>

<body>


  <div class="finance-gadget">

    <div class="header">

      <span>Today's Financial News</span>

    </div>


    <div class="news-container" id="newsContainer">

      <!-- News items populated by JavaScript -->

      <div class="loading">Loading live news...</div>

    </div>


    <div class="footer">

      Powered by simulated live data • Updates every 60s

    </div>

  </div>


  <script>

    // Sample live news data (in real use, fetch from an API or RSS)

    let newsData = [

      {

        title: "Nvidia shares surge 4% after strong AI demand outlook",

        ticker: "NVDA",

        change: "+3.85%",

        source: "CNBC",

        time: "12 min ago",

        link: "https://www.cnbc.com"

      },

      {

        title: "Tesla reports record Q1 deliveries, stock jumps in after-hours",

        ticker: "TSLA",

        change: "+2.15%",

        source: "Reuters",

        time: "37 min ago",

        link: "#"

      },

      {

        title: "Indian Rupee strengthens against USD amid RBI intervention",

        ticker: "INR",

        change: "+0.45%",

        source: "Economic Times",

        time: "1 hr ago",

        link: "#"

      },

      {

        title: "Gold prices hit new all-time high as investors seek safe haven",

        ticker: "XAU",

        change: "+1.20%",

        source: "Bloomberg",

        time: "2 hrs ago",

        link: "#"

      },

      {

        title: "Apple to launch new AI features at WWDC 2026",

        ticker: "AAPL",

        change: "-0.35%",

        source: "The Verge",

        time: "3 hrs ago",

        link: "#"

      }

    ];


    function renderNews() {

      const container = document.getElementById('newsContainer');

      container.innerHTML = '';


      newsData.forEach(item => {

        const isPositive = item.change.startsWith('+');


        const html = `

          <div class="news-item">

            <div class="news-content">

              <div class="news-title">

                <a href="${item.link}" target="_blank">${item.title}</a>

              </div>

              <div class="meta">

                <span class="ticker">${item.ticker}</span>

                <span class="change ${isPositive ? 'positive' : 'negative'}">${item.change}</span>

                <span>${item.source}</span>

                <span>•</span>

                <span>${item.time}</span>

              </div>

            </div>

          </div>

        `;

        container.innerHTML += html;

      });

    }


    // Simulate live updates

    function simulateLiveUpdate() {

      // Randomly update one news item time

      if (newsData.length > 0) {

        const randomIndex = Math.floor(Math.random() * newsData.length);

        newsData[randomIndex].time = "Just now";

      }

      renderNews();

    }


    // Initial render

    window.onload = () => {

      renderNews();


      // Auto-refresh simulation every 60 seconds

      setInterval(() => {

        simulateLiveUpdate();

      }, 60000);

    };

  </script>


</body>

</html>

0 $type={blogger}:

Post a Comment