<?php
require_once __DIR__ . '/../vendor/autoload.php';
use InvestorySpot\StockTicker\StockTicker;
$ticker = new StockTicker(__DIR__ . '/cache');
$ticker->set_refresh(300);
$quotes = $ticker->get_quotes('AAPL,GOOGL,MSFT,AMZN,NVDA,TSLA,META');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stock Ticker Demo</title>
<style>
body { font-family: system-ui, sans-serif; margin: 0; background: #111; color: #eee; }
.stock-ticker-wrap { overflow: hidden; white-space: nowrap; background: #1a1a2e; padding: 12px 0; border-bottom: 1px solid #333; }
.stock-ticker-track { display: inline-block; animation: ticker-scroll 40s linear infinite; }
@keyframes ticker-scroll { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }
.stock-ticker-item { display: inline-block; padding: 0 24px; font-size: 15px; }
.stock-ticker-symbol { font-weight: 700; margin-right: 6px; color: #fff; }
.stock-ticker-price { font-weight: 600; margin-right: 4px; }
.stock-ticker-change { font-size: 13px; }
.up { color: #00a32a; }
.down { color: #d63638; }
main { max-width: 800px; margin: 40px auto; padding: 0 20px; }
h1 { font-size: 24px; }
table.stock-ticker-table { width: 100%; border-collapse: collapse; margin-top: 20px; }
table.stock-ticker-table th, table.stock-ticker-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid #333; }
table.stock-ticker-table th { background: #1a1a2e; font-weight: 600; }
</style>
</head>
<body>
<?php echo $ticker->render_ticker($quotes); ?>
<main>
<h1>Stock Quotes</h1>
<?php echo $ticker->render_table($quotes); ?>
<p style="margin-top:24px;color:#888;font-size:13px;">
Data refreshes every <?php echo $ticker->get_refresh(); ?> seconds.
Provider: <?php echo $quotes[array_key_first($quotes)]['provider']; ?>.
</p>
</main>
</body>
</html>
|