{"id":791,"date":"2026-12-05T11:56:51","date_gmt":"2026-12-05T16:56:51","guid":{"rendered":"https:\/\/www.markwheeler.com\/?p=791"},"modified":"2026-12-05T12:00:44","modified_gmt":"2026-12-05T17:00:44","slug":"gemini-vibe-coding-ticker","status":"publish","type":"post","link":"https:\/\/www.markwheeler.com\/?p=791","title":{"rendered":"Gemini Vibe Coding: Ticker"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I asked Gemini to create a Sports \/ News \/ Markets ticker to replace my instance of Magic Mirror. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"500\" src=\"https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_ncaa-1024x500.png\" alt=\"\" class=\"wp-image-792\" srcset=\"https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_ncaa-1024x500.png 1024w, https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_ncaa-300x146.png 300w, https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_ncaa-768x375.png 768w, https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_ncaa-1536x749.png 1536w, https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_ncaa-2048x999.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"434\" src=\"https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_markets-1024x434.png\" alt=\"\" class=\"wp-image-793\" srcset=\"https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_markets-1024x434.png 1024w, https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_markets-300x127.png 300w, https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_markets-768x326.png 768w, https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_markets-1536x651.png 1536w, https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_markets-2048x868.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">I also created an alternate LCARs version \ud83d\ude42<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"564\" src=\"https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_lcars-1024x564.png\" alt=\"\" class=\"wp-image-794\" srcset=\"https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_lcars-1024x564.png 1024w, https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_lcars-300x165.png 300w, https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_lcars-768x423.png 768w, https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_lcars-1536x847.png 1536w, https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_lcars-2048x1129.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">scores.php handles all the backend. All of the connections are grabbing public sources; no API keys needed. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\nob_start();\nini_set('display_errors', '0');\nerror_reporting(0);\n\nheader(\"Access-Control-Allow-Origin: *\");\nheader(\"Access-Control-Allow-Methods: GET, POST, OPTIONS\");\nheader(\"Access-Control-Allow-Headers: Content-Type\");\nheader(\"Content-Type: application\/json; charset=utf-8\");\n\nfunction sendJson($payload, $code = 200) {\n    if (ob_get_length()) {\n        ob_clean();\n    }\n    if (!headers_sent()) {\n        http_response_code($code);\n        header(\"Content-Type: application\/json; charset=utf-8\");\n    }\n    echo json_encode($payload);\n    exit;\n}\n\nregister_shutdown_function(function () {\n    $err = error_get_last();\n    if ($err &amp;&amp; in_array($err&#91;'type'], &#91;E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR], true)) {\n        sendJson(&#91;\n            \"error\"   => \"PHP Fatal Error\",\n            \"message\" => $err&#91;'message'],\n            \"line\"    => $err&#91;'line']\n        ], 500);\n    }\n});\n\nif (($_SERVER&#91;'REQUEST_METHOD'] ?? '') === 'OPTIONS') {\n    exit(0);\n}\n\n$rawInput = @file_get_contents('php:\/\/input');\n$input = $rawInput ? json_decode($rawInput, true) : &#91;];\n$league = $input&#91;'league'] ?? $_GET&#91;'league'] ?? 'nba';\n\n\/\/ Universal HTTP GET helper\nfunction httpGet($url, $userAgent = \"Mozilla\/5.0 (Windows NT 10.0; Win64; x64)\", $timeout = 8) {\n    if (function_exists('curl_init')) {\n        $ch = curl_init($url);\n        curl_setopt_array($ch, &#91;\n            CURLOPT_RETURNTRANSFER => true,\n            CURLOPT_FOLLOWLOCATION => true,\n            CURLOPT_MAXREDIRS      => 4,\n            CURLOPT_TIMEOUT        => $timeout,\n            CURLOPT_CONNECTTIMEOUT => 5,\n            CURLOPT_USERAGENT      => $userAgent,\n            CURLOPT_SSL_VERIFYPEER => false,\n            CURLOPT_SSL_VERIFYHOST => 0,\n            CURLOPT_HTTPHEADER     => &#91;\"Accept: application\/json, application\/rss+xml, application\/xml, text\/xml;q=0.9\"]\n        ]);\n        $body = curl_exec($ch);\n        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);\n        curl_close($ch);\n        if ($body !== false &amp;&amp; $code >= 200 &amp;&amp; $code &lt; 400) {\n            return $body;\n        }\n        return false;\n    }\n\n    $ctx = stream_context_create(&#91;\n        'http' => &#91;\n            'timeout'       => $timeout,\n            'ignore_errors' => true,\n            'header'        => \"User-Agent: {$userAgent}\\r\\n\"\n        ],\n        'ssl' => &#91;\n            'verify_peer'      => false,\n            'verify_peer_name' => false\n        ]\n    ]);\n\n    return @file_get_contents($url, false, $ctx);\n}\n\n\/\/ Parallel HTTP GET helper for fast multi-quote fetching\nfunction httpGetMulti($urls, $userAgent = \"Mozilla\/5.0 (Windows NT 10.0; Win64; x64)\", $timeout = 6) {\n    $results = &#91;];\n    if (function_exists('curl_multi_init')) {\n        $mh = curl_multi_init();\n        $handles = &#91;];\n        foreach ($urls as $key => $url) {\n            $ch = curl_init($url);\n            curl_setopt_array($ch, &#91;\n                CURLOPT_RETURNTRANSFER => true,\n                CURLOPT_FOLLOWLOCATION => true,\n                CURLOPT_MAXREDIRS      => 3,\n                CURLOPT_TIMEOUT        => $timeout,\n                CURLOPT_CONNECTTIMEOUT => 4,\n                CURLOPT_USERAGENT      => $userAgent,\n                CURLOPT_SSL_VERIFYPEER => false,\n                CURLOPT_SSL_VERIFYHOST => 0,\n                CURLOPT_HTTPHEADER     => &#91;\"Accept: application\/json\"]\n            ]);\n            curl_multi_add_handle($mh, $ch);\n            $handles&#91;$key] = $ch;\n        }\n\n        $running = null;\n        do {\n            curl_multi_exec($mh, $running);\n            curl_multi_select($mh, 0.2);\n        } while ($running > 0);\n\n        foreach ($handles as $key => $ch) {\n            $body = curl_multi_getcontent($ch);\n            $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);\n            $results&#91;$key] = ($body !== false &amp;&amp; $code >= 200 &amp;&amp; $code &lt; 400) ? $body : false;\n            curl_multi_remove_handle($mh, $ch);\n            curl_close($ch);\n        }\n        curl_multi_close($mh);\n        return $results;\n    }\n\n    foreach ($urls as $key => $url) {\n        $results&#91;$key] = httpGet($url, $userAgent, $timeout);\n    }\n    return $results;\n}\n\n\/\/ \u2500\u2500 Handle Markets \/ Stock Ticker Tab \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nif ($league === 'stocks') {\n    sendJson(&#91;\"quotes\" => fetchMarketQuotes()]);\n}\n\nfunction fetchMarketQuotes() {\n    $cacheDir = function_exists('sys_get_temp_dir') ? sys_get_temp_dir() : '\/tmp';\n    $cacheFile = rtrim($cacheDir, '\/\\\\') . '\/nas_ticker_markets_v2.json';\n\n    if (@file_exists($cacheFile) &amp;&amp; (time() - @filemtime($cacheFile)) &lt; 60) {\n        $cached = json_decode(@file_get_contents($cacheFile), true);\n        if (!empty($cached)) {\n            return $cached;\n        }\n    }\n\n    $symbols = &#91;\n        \"^DJI\"    => &#91;\"label\" => \"DOW JONES\",  \"display\" => \"DOW\"],\n        \"^GSPC\"   => &#91;\"label\" => \"S&amp;P 500\",    \"display\" => \"S&amp;P 500\"],\n        \"^IXIC\"   => &#91;\"label\" => \"NASDAQ\",     \"display\" => \"NASDAQ\"],\n        \"BTC-USD\" => &#91;\"label\" => \"BITCOIN\",    \"display\" => \"BTC\"],\n        \"CL=F\"    => &#91;\"label\" => \"CRUDE OIL\",  \"display\" => \"OIL\"],\n        \"ANT\"     => &#91;\"label\" => \"ANT\",        \"display\" => \"ANT\"],\n        \"NOBL\"    => &#91;\"label\" => \"PROSHARES S&amp;P 500 DIVIDEND ARISTOCRATS\", \"display\" => \"NOBL\"],\n        \"POWR\"    => &#91;\"label\" => \"POWR\",       \"display\" => \"POWR\"],\n        \"SKYY\"    => &#91;\"label\" => \"FIRST TRUST CLOUD COMPUTING ETF\",       \"display\" => \"SKYY\"],\n\t\t\"META\"    => &#91;\"label\" => \"META\",       \"display\" => \"META\"],\n\t\t\"ETTOX\"    => &#91;\"label\" => \"E*TRADE No Fee Total Market Index\",       \"display\" => \"ETTOX\"],\n\t\t\"DIS\"    => &#91;\"label\" => \"Disney\",       \"display\" => \"DIS\"]\n    ];\n\n    $urls = &#91;];\n    foreach ($symbols as $ticker => $info) {\n        $encoded = urlencode($ticker);\n        $urls&#91;$ticker] = \"https:\/\/query1.finance.yahoo.com\/v8\/finance\/chart\/{$encoded}?interval=1d&amp;range=1d\";\n    }\n\n    $responses = httpGetMulti($urls, \"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36\", 6);\n    $quotes = &#91;];\n\n    foreach ($symbols as $ticker => $info) {\n        $raw = $responses&#91;$ticker] ?? false;\n        $data = $raw ? json_decode($raw, true) : null;\n        $meta = $data&#91;'chart']&#91;'result']&#91;0]&#91;'meta'] ?? null;\n\n        if ($meta &amp;&amp; isset($meta&#91;'regularMarketPrice'])) {\n            $price = (float)$meta&#91;'regularMarketPrice'];\n            $prevClose = (float)($meta&#91;'chartPreviousClose'] ?? $meta&#91;'previousClose'] ?? $price);\n            $change = $price - $prevClose;\n            $changePct = ($prevClose > 0) ? (($change \/ $prevClose) * 100) : 0;\n\n            $quotes&#91;] = &#91;\n                \"symbol\"     => $info&#91;'display'],\n                \"raw_symbol\" => $ticker,\n                \"name\"       => $meta&#91;'shortName'] ?? $info&#91;'label'],\n                \"label\"      => $info&#91;'label'],\n                \"price\"      => $price,\n                \"change\"     => $change,\n                \"change_pct\" => $changePct,\n                \"state\"      => $meta&#91;'marketState'] ?? 'REGULAR'\n            ];\n        } else {\n            $quotes&#91;] = &#91;\n                \"symbol\"     => $info&#91;'display'],\n                \"raw_symbol\" => $ticker,\n                \"name\"       => $info&#91;'label'],\n                \"label\"      => $info&#91;'label'],\n                \"price\"      => null,\n                \"change\"     => 0,\n                \"change_pct\" => 0,\n                \"state\"      => \"UNAVAILABLE\"\n            ];\n        }\n    }\n\n    if (!empty($quotes)) {\n        @file_put_contents($cacheFile, json_encode($quotes));\n    }\n\n    return $quotes;\n}\n\n\/\/ \u2500\u2500 Handle Top 9 News Headlines (Google News RSS) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nif ($league === 'news') {\n    sendJson(&#91;\"articles\" => fetchTopNews()]);\n}\n\nfunction timeAgo($timestamp) {\n    $diff = max(1, time() - (int)$timestamp);\n    if ($diff &lt; 3600) return floor($diff \/ 60) . \"m ago\";\n    if ($diff &lt; 86400) return floor($diff \/ 3600) . \"h ago\";\n    return floor($diff \/ 86400) . \"d ago\";\n}\nfunction fetchTopNews() {\n    $cacheDir = function_exists('sys_get_temp_dir') ? sys_get_temp_dir() : '\/tmp';\n    $cacheFile = rtrim($cacheDir, '\/\\\\') . '\/nas_ticker_top9_news_v2.json';\n\n    if (@file_exists($cacheFile) &amp;&amp; (time() - @filemtime($cacheFile)) &lt; 300) {\n        $cached = json_decode(@file_get_contents($cacheFile), true);\n        if (!empty($cached)) {\n            return $cached;\n        }\n    }\n\n    \/\/ Reliable, open RSS feeds that do not block NAS IPs or require SimpleXML\n    $feeds = &#91;\n        &#91;\"url\" => \"https:\/\/feeds.npr.org\/1001\/rss.xml\",                  \"source\" => \"NPR News\"],\n        &#91;\"url\" => \"https:\/\/feeds.bbci.co.uk\/news\/world\/us_and_canada\/rss.xml\", \"source\" => \"BBC News\"],\n        &#91;\"url\" => \"https:\/\/www.cbsnews.com\/latest\/rss\/main\",             \"source\" => \"CBS News\"],\n    ];\n\n    $articles = &#91;];\n\n    foreach ($feeds as $feed) {\n        $xmlRaw = httpGet($feed&#91;'url'], \"Mozilla\/5.0 (Windows NT 10.0; Win64; x64)\", 8);\n        if (!$xmlRaw || stripos($xmlRaw, '&lt;item') === false) {\n            continue;\n        }\n\n        \/\/ Extract &lt;item> blocks without needing SimpleXML extension\n        if (preg_match_all('\/&lt;item\\b&#91;^>]*>(.*?)&lt;\\\/item>\/is', $xmlRaw, $itemMatches)) {\n            foreach ($itemMatches&#91;1] as $itemXml) {\n                $title = '';\n                if (preg_match('\/&lt;title>(?:&lt;!\\&#91;CDATA\\&#91;)?(.*?)(?:\\]\\]>)?&lt;\\\/title>\/is', $itemXml, $m)) {\n                    $title = trim(html_entity_decode(strip_tags($m&#91;1]), ENT_QUOTES | ENT_HTML5, 'UTF-8'));\n                }\n\n                $link = '';\n                if (preg_match('\/&lt;link>(?:&lt;!\\&#91;CDATA\\&#91;)?(.*?)(?:\\]\\]>)?&lt;\\\/link>\/is', $itemXml, $m)) {\n                    $link = trim($m&#91;1]);\n                }\n\n                $desc = '';\n                if (preg_match('\/&lt;description>(?:&lt;!\\&#91;CDATA\\&#91;)?(.*?)(?:\\]\\]>)?&lt;\\\/description>\/is', $itemXml, $m)) {\n                    $desc = html_entity_decode(strip_tags($m&#91;1]), ENT_QUOTES | ENT_HTML5, 'UTF-8');\n                    $desc = trim(preg_replace('\/\\s+\/', ' ', $desc));\n                }\n\n                $pubDate = time();\n                if (preg_match('\/&lt;pubDate>(.*?)&lt;\\\/pubDate>\/is', $itemXml, $m)) {\n                    $parsed = strtotime(trim($m&#91;1]));\n                    if ($parsed) {\n                        $pubDate = $parsed;\n                    }\n                }\n\n                if ($title === '' || $link === '') {\n                    continue;\n                }\n\n                if (strlen($desc) &lt; 20) {\n                    $desc = \"Top story via {$feed&#91;'source']} \u2014 click headline to read full coverage.\";\n                } elseif (strlen($desc) > 220) {\n                    $desc = substr($desc, 0, 217) . '...';\n                }\n\n                $articles&#91;] = &#91;\n                    \"title\"    => $title,\n                    \"url\"      => $link,\n                    \"domain\"   => $feed&#91;'source'],\n                    \"time_ago\" => timeAgo($pubDate),\n                    \"blurb\"    => $desc\n                ];\n\n                if (count($articles) >= 9) {\n                    break 2;\n                }\n            }\n        }\n    }\n\n    if (!empty($articles)) {\n        @file_put_contents($cacheFile, json_encode($articles));\n    }\n\n    return $articles;\n}\n\n\/\/ \u2500\u2500 Sports Scoreboards \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n$endpoints = &#91;\n    \"nba\"   => \"https:\/\/site.api.espn.com\/apis\/site\/v2\/sports\/basketball\/nba\/scoreboard\",\n    \"nfl\"   => \"https:\/\/site.api.espn.com\/apis\/site\/v2\/sports\/football\/nfl\/scoreboard\",\n    \"nhl\"   => \"https:\/\/site.api.espn.com\/apis\/site\/v2\/sports\/hockey\/nhl\/scoreboard\",\n    \"mlb\"   => \"https:\/\/site.api.espn.com\/apis\/site\/v2\/sports\/baseball\/mlb\/scoreboard\",\n    \"ncaaf\" => \"https:\/\/site.api.espn.com\/apis\/site\/v2\/sports\/football\/college-football\/scoreboard\",\n];\n\nif (!isset($endpoints&#91;$league])) {\n    sendJson(&#91;\"error\" => \"Unknown league\"], 400);\n}\n\nfunction getTeamLogo($team, $league) {\n    if (!empty($team&#91;'logo'])) {\n        return $team&#91;'logo'];\n    }\n    if (!empty($team&#91;'logos']&#91;0]&#91;'href'])) {\n        return $team&#91;'logos']&#91;0]&#91;'href'];\n    }\n    if ($league === 'ncaaf' &amp;&amp; !empty($team&#91;'id'])) {\n        return \"https:\/\/a.espncdn.com\/i\/teamlogos\/ncaa\/500\/{$team&#91;'id']}.png\";\n    }\n    $abbrev = strtolower($team&#91;'abbreviation'] ?? '');\n    if ($abbrev) {\n        return \"https:\/\/a.espncdn.com\/i\/teamlogos\/{$league}\/500\/{$abbrev}.png\";\n    }\n    return \"\";\n}\n\n\/\/ US Eastern Time offset helper (automatically handles EST vs EDT without requiring system tzdata)\nfunction getEasternOffsetSeconds($utcTimestamp) {\n    $year = (int)gmdate('Y', $utcTimestamp);\n    \/\/ Second Sunday in March at 07:00 UTC (2:00 AM EST)\n    $dstStart = strtotime(\"second sunday of march {$year} 07:00:00 UTC\");\n    \/\/ First Sunday in November at 06:00 UTC (2:00 AM EDT)\n    $dstEnd   = strtotime(\"first sunday of november {$year} 06:00:00 UTC\");\n    $isEdt = ($utcTimestamp >= $dstStart &amp;&amp; $utcTimestamp &lt; $dstEnd);\n    return $isEdt ? &#91;-14400, 'EDT'] : &#91;-18000, 'EST'];\n}\n\nfunction formatEasternTime($isoDate) {\n    if (empty($isoDate)) return \"\";\n    $utcTs = strtotime($isoDate);\n    if (!$utcTs) return \"\";\n    list($offset, $label) = getEasternOffsetSeconds($utcTs);\n    return gmdate('D g:i A', $utcTs + $offset) . \" {$label}\";\n}\n\nfunction parseEspnEvents($data, $league) {\n    $games = &#91;];\n    foreach ($data&#91;'events'] ?? &#91;] as $event) {\n        $comp = $event&#91;'competitions']&#91;0] ?? &#91;];\n        $competitors = $comp&#91;'competitors'] ?? &#91;];\n        if (count($competitors) &lt; 2) continue;\n\n        $home = ($competitors&#91;0]&#91;'homeAway'] ?? '') === 'home' ? $competitors&#91;0] : $competitors&#91;1];\n        $away = ($competitors&#91;0]&#91;'homeAway'] ?? '') === 'away' ? $competitors&#91;0] : $competitors&#91;1];\n\n        $homeTeam = $home&#91;'team'] ?? &#91;];\n        $awayTeam = $away&#91;'team'] ?? &#91;];\n\n        $homeRank = ($league === 'ncaaf' &amp;&amp; !empty($home&#91;'curatedRank']&#91;'current']) &amp;&amp; $home&#91;'curatedRank']&#91;'current'] &lt;= 25)\n            ? \"#{$home&#91;'curatedRank']&#91;'current']} \" : \"\";\n        $awayRank = ($league === 'ncaaf' &amp;&amp; !empty($away&#91;'curatedRank']&#91;'current']) &amp;&amp; $away&#91;'curatedRank']&#91;'current'] &lt;= 25)\n            ? \"#{$away&#91;'curatedRank']&#91;'current']} \" : \"\";\n\n        $statusObj  = $event&#91;'status'] ?? &#91;];\n        $statusType = $statusObj&#91;'type'] ?? &#91;];\n        $state      = $statusType&#91;'state'] ?? 'pre';\n\n        if ($state === 'in') {\n            $status = 'live';\n            $period = $statusType&#91;'shortDetail'] ?? $statusType&#91;'detail'] ?? 'In Progress';\n        } elseif ($state === 'post') {\n            $status = 'final';\n            $period = $statusType&#91;'shortDetail'] ?? 'Final';\n        } else {\n            $status = 'scheduled';\n            $period = '';\n        }\n\n        $scheduledTime = ($status === 'scheduled') ? formatEasternTime($event&#91;'date'] ?? '') : '';\n\n        $games&#91;] = &#91;\n            \"id\"             => $event&#91;'id'] ?? ($awayTeam&#91;'id'] ?? '') . '_' . ($homeTeam&#91;'id'] ?? ''),\n            \"home\"           => $homeRank . ($homeTeam&#91;'shortDisplayName'] ?? $homeTeam&#91;'displayName'] ?? '?'),\n            \"away\"           => $awayRank . ($awayTeam&#91;'shortDisplayName'] ?? $awayTeam&#91;'displayName'] ?? '?'),\n            \"home_logo\"      => getTeamLogo($homeTeam, $league),\n            \"away_logo\"      => getTeamLogo($awayTeam, $league),\n            \"home_score\"     => $status !== 'scheduled' ? (int)($home&#91;'score'] ?? 0) : null,\n            \"away_score\"     => $status !== 'scheduled' ? (int)($away&#91;'score'] ?? 0) : null,\n            \"status\"         => $status,\n            \"period\"         => $period,\n            \"scheduled_time\" => $scheduledTime\n        ];\n    }\n    return $games;\n}\n\nfunction fetchScoreboard($url, $league, $dateStr = null) {\n    $extra = ($league === 'ncaaf') ? \"groups=80&amp;limit=150\" : \"limit=50\";\n    $fullUrl = $dateStr ? \"{$url}?dates={$dateStr}&amp;{$extra}\" : \"{$url}?{$extra}\";\n\n    $raw = httpGet($fullUrl, \"Mozilla\/5.0\", 6);\n    if (!$raw) return &#91;];\n\n    $data = json_decode($raw, true);\n    return parseEspnEvents($data ?: &#91;], $league);\n}\n\nfunction sortGamesLiveFirst($games) {\n    $order = &#91;'live' => 0, 'scheduled' => 1, 'final' => 2];\n    usort($games, function ($a, $b) use ($order) {\n        $oa = $order&#91;$a&#91;'status']] ?? 3;\n        $ob = $order&#91;$b&#91;'status']] ?? 3;\n        return $oa &lt;=> $ob;\n    });\n    return $games;\n}\n\n$nowUtc = time();\nlist($etOffset, ) = getEasternOffsetSeconds($nowUtc);\n$etNowTs = $nowUtc + $etOffset;\n$todayEtStr = gmdate('Ymd', $etNowTs);\n\n\/\/ 1. Fetch ESPN's active scoreboard (includes all live games) + today's Eastern date\n$activeGames = fetchScoreboard($endpoints&#91;$league], $league, null);\n$todayGames  = fetchScoreboard($endpoints&#91;$league], $league, $todayEtStr);\n\n$merged = &#91;];\nforeach (array_merge($activeGames, $todayGames) as $g) {\n    $merged&#91;$g&#91;'id']] = $g;\n}\n$games = sortGamesLiveFirst(array_values($merged));\n\nif (!empty($games)) {\n    sendJson(&#91;\"source\" => \"today\", \"games\" => $games]);\n}\n\n\/\/ 2. Check yesterday (Eastern Time)\n$yesterdayEt = gmdate('Ymd', $etNowTs - 86400);\n$yesterdayGames = sortGamesLiveFirst(fetchScoreboard($endpoints&#91;$league], $league, $yesterdayEt));\nif (!empty($yesterdayGames)) {\n    sendJson(&#91;\"source\" => \"yesterday\", \"games\" => $yesterdayGames]);\n}\n\n\/\/ 3. Look ahead up to 7 days (Eastern Time)\nfor ($i = 1; $i &lt;= 7; $i++) {\n    $futureEt = gmdate('Ymd', $etNowTs + ($i * 86400));\n    $upcoming = fetchScoreboard($endpoints&#91;$league], $league, $futureEt);\n    if (!empty($upcoming)) {\n        sendJson(&#91;\"source\" => \"upcoming\", \"games\" => $upcoming]);\n    }\n}\n\n\/\/ 4. Fallback to recent results from the past 4 days\nfor ($i = 2; $i &lt;= 4; $i++) {\n    $pastEt = gmdate('Ymd', $etNowTs - ($i * 86400));\n    $recent = fetchScoreboard($endpoints&#91;$league], $league, $pastEt);\n    if (!empty($recent)) {\n        sendJson(&#91;\"source\" => \"recent\", \"games\" => $recent]);\n    }\n}\n\nsendJson(&#91;\"source\" => \"today\", \"games\" => &#91;]]);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This is the front-end HTML page. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html>\n&lt;html lang=\"en\">\n&lt;head>\n    &lt;meta charset=\"UTF-8\">\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    &lt;title>Sports, Markets &amp; News Ticker - NAS Edition&lt;\/title>\n    &lt;link rel=\"preconnect\" href=\"https:\/\/fonts.googleapis.com\">\n    &lt;link rel=\"preconnect\" href=\"https:\/\/fonts.gstatic.com\" crossorigin>\n    &lt;link href=\"https:\/\/fonts.googleapis.com\/css2?family=Rajdhani:wght@400;600;700&amp;family=Electrolize&amp;family=Orbitron:wght@700;900&amp;display=swap\" rel=\"stylesheet\">\n    &lt;style>\n        :root {\n            --electric-blue: #00d4ff;\n            --hot-pink: #ff006e;\n            --lime-green: #8fff00;\n            --deep-purple: #1a0033;\n            --dark-slate: #0f0820;\n            --accent-orange: #ff9500;\n            --text-white: #ffffff;\n            --text-gray: #b8c5d6;\n            --card-bg: rgba(26, 0, 51, 0.6);\n            --ticker-height: 40px;\n        }\n\n        * { margin: 0; padding: 0; box-sizing: border-box; }\n\n        body {\n            font-family: 'Rajdhani', sans-serif;\n            background: linear-gradient(135deg, var(--dark-slate) 0%, var(--deep-purple) 100%);\n            color: var(--text-white);\n            overflow-x: hidden;\n            min-height: 100vh;\n            padding-bottom: calc(var(--ticker-height) + 20px);\n        }\n\n        body::before {\n            content: '';\n            position: fixed;\n            top: -50%; left: -50%; width: 200%; height: 200%;\n            background-image: \n                radial-gradient(circle at 20% 50%, rgba(0, 212, 255, 0.1) 0%, transparent 50%),\n                radial-gradient(circle at 80% 80%, rgba(255, 0, 110, 0.1) 0%, transparent 50%);\n            animation: bgRotate 30s linear infinite;\n            pointer-events: none;\n            z-index: -1;\n        }\n\n        @keyframes bgRotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }\n\n        .container { max-width: 1800px; margin: 0 auto; padding: 20px; position: relative; z-index: 1; }\n\n        .controls-section { \n            margin: 10px 0 30px 0; \n            display: flex; gap: 15px; flex-wrap: wrap; \n            justify-content: space-between; align-items: center;\n            background: rgba(0,0,0,0.3); padding: 15px 20px;\n            border-radius: 12px; border: 1px solid rgba(255,255,255,0.08);\n        }\n\n        .controls-group { display: flex; gap: 10px; flex-wrap: wrap; }\n        \n        .league-btn, .control-btn {\n            font-family: 'Electrolize', sans-serif; padding: 10px 18px;\n            border-radius: 8px; cursor: pointer; transition: all 0.2s;\n            text-transform: uppercase; letter-spacing: 1px; font-size: 0.9rem;\n        }\n\n        .league-btn { background: var(--card-bg); border: 2px solid var(--electric-blue); color: white; }\n        .league-btn.active { background: linear-gradient(135deg, var(--electric-blue), var(--hot-pink)); border-color: transparent; }\n        .control-btn { background: rgba(255, 149, 0, 0.1); border: 2px solid var(--accent-orange); color: white; }\n\n        .weather-widget {\n            background: rgba(255, 255, 255, 0.05);\n            backdrop-filter: blur(10px);\n            border: 1px solid rgba(0, 212, 255, 0.3);\n            padding: 8px 16px; border-radius: 12px;\n            display: flex; align-items: center; gap: 12px;\n            font-family: 'Electrolize', sans-serif;\n        }\n\n        .weather-icon {\n            font-size: 1.8rem;\n            line-height: 1;\n            filter: drop-shadow(0 0 8px rgba(0, 212, 255, 0.4));\n        }\n\n        .weather-temp { font-size: 1.6rem; font-family: 'Orbitron'; color: var(--electric-blue); }\n        .weather-info { font-size: 0.75rem; color: var(--text-gray); text-transform: uppercase; letter-spacing: 1px; line-height: 1.3; }\n\n        .ticker-container {\n            background: var(--card-bg); border-radius: 20px; padding: 25px;\n            min-height: 500px; backdrop-filter: blur(10px);\n            border: 1px solid rgba(0, 212, 255, 0.2);\n        }\n\n        .games-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 20px; }\n\n        .game-card {\n            background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.1);\n            border-radius: 15px; padding: 18px; position: relative; transition: transform 0.3s, border-color 0.3s;\n        }\n        .game-card:hover { transform: scale(1.02); border-color: var(--electric-blue); }\n\n        .game-card.live {\n            border-color: var(--lime-green);\n            box-shadow: 0 0 22px rgba(143, 255, 0, 0.22);\n            background: linear-gradient(135deg, rgba(143, 255, 0, 0.06) 0%, rgba(0, 212, 255, 0.05) 100%);\n        }\n\n        .live-pill {\n            display: inline-block;\n            background: var(--lime-green);\n            color: var(--deep-purple);\n            padding: 2px 9px;\n            border-radius: 12px;\n            font-family: 'Electrolize', sans-serif;\n            font-weight: 700;\n            margin-right: 6px;\n            animation: livePulse 1.5s ease-in-out infinite;\n        }\n\n        @keyframes livePulse {\n            0%, 100% { opacity: 1; }\n            50% { opacity: 0.65; }\n        }\n\n        .matchup { display: flex; justify-content: space-between; align-items: center; margin: 10px 0; }\n        .team-info { display: flex; flex-direction: column; align-items: center; gap: 5px; flex: 1; }\n        .team-logo-wrap { width: 56px; height: 56px; display: grid; place-items: center; position: relative; }\n        .team-logo-placeholder, .team-logo-img { grid-area: 1 \/ 1; width: 100%; height: 100%; transition: opacity 0.4s; }\n        .team-logo-placeholder { border-radius: 50%; background: rgba(255,255,255,0.05); display: flex; align-items: center; justify-content: center; font-size: 0.6rem; color: var(--text-gray); font-family: 'Orbitron'; }\n        .team-logo-img { object-fit: contain; opacity: 0; z-index: 2; }\n        .score { font-family: 'Orbitron'; font-size: 2.2rem; color: var(--electric-blue); }\n        .winner .score { color: var(--lime-green); text-shadow: 0 0 10px var(--lime-green); }\n\n        \/* Markets Grid &amp; Cards *\/\n        .markets-grid {\n            display: grid;\n            grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));\n            gap: 20px;\n        }\n\n        .stock-card {\n            background: rgba(255, 255, 255, 0.03);\n            border: 1px solid rgba(255, 255, 255, 0.1);\n            border-radius: 16px;\n            padding: 22px 24px;\n            display: flex;\n            flex-direction: column;\n            justify-content: space-between;\n            gap: 12px;\n            transition: transform 0.25s, border-color 0.25s;\n        }\n\n        .stock-card:hover {\n            transform: translateY(-4px);\n            border-color: var(--electric-blue);\n        }\n\n        .stock-card.up { border-left: 4px solid var(--lime-green); }\n        .stock-card.down { border-left: 4px solid var(--hot-pink); }\n\n        .stock-header {\n            display: flex;\n            justify-content: space-between;\n            align-items: baseline;\n            gap: 10px;\n        }\n\n        .stock-symbol {\n            font-family: 'Orbitron', sans-serif;\n            font-size: 1.5rem;\n            font-weight: 900;\n            color: var(--electric-blue);\n            letter-spacing: 1px;\n        }\n\n        .stock-name {\n            font-family: 'Electrolize', sans-serif;\n            font-size: 0.78rem;\n            color: var(--text-gray);\n            text-transform: uppercase;\n            letter-spacing: 1px;\n            white-space: nowrap;\n            overflow: hidden;\n            text-overflow: ellipsis;\n            max-width: 60%;\n        }\n\n        .stock-price {\n            font-family: 'Orbitron', sans-serif;\n            font-size: 2.1rem;\n            font-weight: 700;\n            color: var(--text-white);\n        }\n\n        .stock-change {\n            font-family: 'Electrolize', sans-serif;\n            font-size: 1rem;\n            font-weight: 700;\n            letter-spacing: 1px;\n        }\n\n        .stock-change.up { color: var(--lime-green); text-shadow: 0 0 12px rgba(143, 255, 0, 0.4); }\n        .stock-change.down { color: var(--hot-pink); text-shadow: 0 0 12px rgba(255, 0, 110, 0.4); }\n\n        \/* News Grid &amp; Cards *\/\n        .news-grid {\n            display: grid;\n            grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));\n            gap: 18px;\n        }\n\n        .news-card {\n            background: rgba(255, 255, 255, 0.03);\n            border: 1px solid rgba(255, 255, 255, 0.1);\n            border-left: 4px solid var(--hot-pink);\n            border-radius: 14px;\n            padding: 18px 20px;\n            display: flex;\n            flex-direction: column;\n            justify-content: space-between;\n            gap: 10px;\n            transition: transform 0.25s, border-color 0.25s;\n        }\n\n        .news-card:hover {\n            transform: translateY(-3px);\n            border-color: var(--electric-blue);\n            border-left-color: var(--lime-green);\n        }\n\n        .news-meta {\n            display: flex;\n            justify-content: space-between;\n            align-items: center;\n            font-family: 'Electrolize', sans-serif;\n            font-size: 0.75rem;\n            color: var(--electric-blue);\n            letter-spacing: 1px;\n            text-transform: uppercase;\n        }\n\n        .news-headline {\n            font-size: 1.25rem;\n            font-weight: 700;\n            color: var(--text-white);\n            line-height: 1.3;\n            text-decoration: none;\n        }\n\n        .news-headline:hover { color: var(--lime-green); }\n\n        .news-blurb {\n            font-size: 0.98rem;\n            color: var(--text-gray);\n            line-height: 1.45;\n        }\n\n        .news-footer {\n            display: flex;\n            justify-content: space-between;\n            align-items: center;\n            font-family: 'Electrolize', sans-serif;\n            font-size: 0.75rem;\n            color: rgba(255, 255, 255, 0.5);\n            border-top: 1px solid rgba(255, 255, 255, 0.07);\n            padding-top: 8px;\n        }\n\n        .news-ticker-bar {\n            position: fixed; bottom: 0; left: 0; width: 100%;\n            height: var(--ticker-height); background: #000;\n            border-top: 1px solid var(--electric-blue);\n            z-index: 1000; overflow: hidden; display: flex; align-items: center;\n        }\n\n        .ticker-label {\n            background: var(--hot-pink); color: white; padding: 0 15px;\n            height: 100%; display: flex; align-items: center;\n            font-weight: bold; font-family: 'Orbitron'; font-size: 0.8rem;\n            z-index: 1001; position: relative; white-space: nowrap;\n        }\n\n        .ticker-wrapper { display: flex; white-space: nowrap; padding-left: 20px; }\n        .ticker-content {\n            display: inline-block; padding-right: 50px;\n            animation: marquee 45s linear infinite;\n            font-family: 'Electrolize', sans-serif; color: var(--lime-green);\n            font-size: 0.9rem; letter-spacing: 1px;\n        }\n\n        @keyframes marquee { 0% { transform: translateX(0); } 100% { transform: translateX(-100%); } }\n\n        .news-item { margin-right: 40px; display: inline-flex; align-items: center; }\n        .news-item::after { content: '\u2022'; margin-left: 40px; color: var(--text-gray); }\n\n        .loading { text-align: center; padding: 100px; font-size: 1.5rem; color: var(--electric-blue); font-family: 'Orbitron'; }\n\n        @media (max-width: 700px) {\n            .games-grid, .news-grid, .markets-grid { grid-template-columns: 1fr; }\n        }\n    &lt;\/style>\n&lt;\/head>\n&lt;body>\n\n    &lt;div class=\"container\">\n        &lt;div class=\"controls-section\">\n            &lt;div class=\"controls-group\" id=\"league-btns\">\n                &lt;button class=\"league-btn active\" data-league=\"nba\">NBA&lt;\/button>\n                &lt;button class=\"league-btn\" data-league=\"nfl\">NFL&lt;\/button>\n                &lt;button class=\"league-btn\" data-league=\"nhl\">NHL&lt;\/button>\n                &lt;button class=\"league-btn\" data-league=\"mlb\">MLB&lt;\/button>\n                &lt;button class=\"league-btn\" data-league=\"ncaaf\">NCAA Football&lt;\/button>\n                &lt;button class=\"league-btn\" data-league=\"stocks\">Markets&lt;\/button>\n                &lt;button class=\"league-btn\" data-league=\"news\">News&lt;\/button>\n            &lt;\/div>\n            \n            &lt;div style=\"display: flex; gap: 15px; align-items: center;\">\n                &lt;div class=\"weather-widget\">\n                    &lt;div class=\"weather-icon\" id=\"weather-icon\">\ud83c\udf21\ufe0f&lt;\/div>\n                    &lt;div class=\"weather-temp\" id=\"weather-temp\">--\u00b0&lt;\/div>\n                    &lt;div class=\"weather-info\">\n                        &lt;div>Kings Park West&lt;\/div>\n                        &lt;div id=\"weather-desc\" style=\"color: var(--lime-green)\">Loading...&lt;\/div>\n                    &lt;\/div>\n                &lt;\/div>\n\n                &lt;span id=\"connection-status\" style=\"font-size: 0.8rem; color: var(--lime-green);\">LIVE&lt;\/span>\n                &lt;button class=\"control-btn\" onclick=\"refreshScores()\">\ud83d\udd04&lt;\/button>\n                &lt;button class=\"control-btn\" id=\"cycle-btn\" onclick=\"toggleAutoCycle()\">\u23f8&lt;\/button>\n            &lt;\/div>\n        &lt;\/div>\n\n        &lt;div class=\"ticker-container\" id=\"ticker\">\n            &lt;div class=\"loading\">SYNCING DATA...&lt;\/div>\n        &lt;\/div>\n    &lt;\/div>\n\n    &lt;div class=\"news-ticker-bar\">\n        &lt;div class=\"ticker-label\">LATEST UPDATES&lt;\/div>\n        &lt;div class=\"ticker-wrapper\">\n            &lt;div class=\"ticker-content\" id=\"news-content\">\n                &lt;span class=\"news-item\">Syncing live weather, sports, markets &amp; news feeds...&lt;\/span>\n            &lt;\/div>\n            &lt;div class=\"ticker-content\" id=\"news-content-dup\">&lt;\/div>\n        &lt;\/div>\n    &lt;\/div>\n\n    &lt;script>\n        const BACKEND_URL = 'scores.php';\n        const LEAGUES = &#91;'nba', 'nfl', 'nhl', 'mlb', 'ncaaf', 'stocks', 'news'];\n        \n        \/\/ Coordinates for Kings Park West, VA\n        const WEATHER_LAT = 38.8054;\n        const WEATHER_LON = -77.3119;\n\n        let state = {\n            currentLeague: 'nba',\n            isAutoCycle: true,\n            currentIndex: 0,\n            weatherSummary: 'Kings Park West: Loading weather...'\n        };\n\n        const ticker = document.getElementById('ticker');\n        const newsContent = document.getElementById('news-content');\n        const newsDup = document.getElementById('news-content-dup');\n\n        function escapeHtml(str) {\n            return String(str || '')\n                .replace(\/&amp;\/g, '&amp;amp;')\n                .replace(\/&lt;\/g, '&amp;lt;')\n                .replace(\/>\/g, '&amp;gt;')\n                .replace(\/\"\/g, '&amp;quot;');\n        }\n\n        function fetchWithTimeout(url, options = {}, timeoutMs = 12000) {\n            const controller = new AbortController();\n            const id = setTimeout(() => controller.abort(), timeoutMs);\n            return fetch(url, { ...options, signal: controller.signal })\n                .finally(() => clearTimeout(id));\n        }\n\n        function decodeWeather(code, isDay = 1) {\n            const map = {\n                0:  { desc: 'Clear Sky',           icon: isDay ? '\u2600\ufe0f' : '\ud83c\udf19' },\n                1:  { desc: 'Mainly Clear',        icon: isDay ? '\ud83c\udf24\ufe0f' : '\ud83c\udf19' },\n                2:  { desc: 'Partly Cloudy',       icon: isDay ? '\u26c5' : '\u2601\ufe0f' },\n                3:  { desc: 'Overcast',            icon: '\u2601\ufe0f' },\n                45: { desc: 'Fog',                 icon: '\ud83c\udf2b\ufe0f' },\n                48: { desc: 'Depositing Rime Fog', icon: '\ud83c\udf2b\ufe0f' },\n                51: { desc: 'Light Drizzle',       icon: '\ud83c\udf26\ufe0f' },\n                53: { desc: 'Moderate Drizzle',    icon: '\ud83c\udf26\ufe0f' },\n                55: { desc: 'Dense Drizzle',       icon: '\ud83c\udf27\ufe0f' },\n                61: { desc: 'Slight Rain',         icon: '\ud83c\udf27\ufe0f' },\n                63: { desc: 'Moderate Rain',       icon: '\ud83c\udf27\ufe0f' },\n                65: { desc: 'Heavy Rain',          icon: '\ud83c\udf27\ufe0f' },\n                71: { desc: 'Slight Snow',         icon: '\ud83c\udf28\ufe0f' },\n                73: { desc: 'Moderate Snow',       icon: '\u2744\ufe0f' },\n                75: { desc: 'Heavy Snow',          icon: '\u2744\ufe0f' },\n                80: { desc: 'Rain Showers',        icon: '\ud83c\udf26\ufe0f' },\n                81: { desc: 'Moderate Showers',    icon: '\ud83c\udf27\ufe0f' },\n                82: { desc: 'Violent Showers',     icon: '\u26c8\ufe0f' },\n                95: { desc: 'Thunderstorm',        icon: '\u26c8\ufe0f' }\n            };\n            return map&#91;code] || { desc: 'Cloudy', icon: '\u2601\ufe0f' };\n        }\n\n        async function fetchWeather() {\n            try {\n                const url = `https:\/\/api.open-meteo.com\/v1\/forecast?latitude=${WEATHER_LAT}&amp;longitude=${WEATHER_LON}&amp;current=temperature_2m,relative_humidity_2m,is_day,weather_code,wind_speed_10m&amp;temperature_unit=fahrenheit&amp;wind_speed_unit=mph`;\n                const res = await fetchWithTimeout(url, {}, 8000);\n                const data = await res.json();\n                \n                if (data.current) {\n                    const temp = Math.round(data.current.temperature_2m);\n                    const wind = Math.round(data.current.wind_speed_10m);\n                    const humidity = data.current.relative_humidity_2m;\n                    const { desc, icon } = decodeWeather(data.current.weather_code, data.current.is_day);\n\n                    document.getElementById('weather-icon').innerText = icon;\n                    document.getElementById('weather-temp').innerText = `${temp}\u00b0`;\n                    document.getElementById('weather-desc').innerText = desc;\n                    \n                    state.weatherSummary = `${icon} Kings Park West: ${temp}\u00b0F (${desc}) \u2022 Wind ${wind} mph \u2022 Humidity ${humidity}%`;\n                }\n            } catch (err) {\n                console.error('Weather fetch failed:', err);\n                document.getElementById('weather-icon').innerText = '\u26a0\ufe0f';\n                document.getElementById('weather-desc').innerText = 'Offline';\n            }\n        }\n\n        async function fetchScores(league) {\n            try {\n                const res = await fetchWithTimeout(BACKEND_URL, {\n                    method: 'POST',\n                    headers: { 'Content-Type': 'application\/json' },\n                    body: JSON.stringify({ league })\n                }, 15000);\n\n                if (!res.ok) throw new Error(`HTTP ${res.status}`);\n                const text = await res.text();\n                let data;\n                try {\n                    data = JSON.parse(text);\n                } catch (parseErr) {\n                    throw new Error('Invalid JSON from scores.php');\n                }\n\n                if (league === 'stocks') {\n                    renderMarkets(data.quotes || &#91;]);\n                    updateBottomTickerFromMarkets(data.quotes || &#91;]);\n                } else if (league === 'news') {\n                    renderNews(data.articles || &#91;]);\n                    updateBottomTickerFromNews(data.articles || &#91;]);\n                } else {\n                    renderGames(data.games || &#91;], league, data.source);\n                    updateBottomTickerFromGames(data.games || &#91;]);\n                }\n\n                document.getElementById('connection-status').innerText = 'LIVE';\n                document.getElementById('connection-status').style.color = 'var(--lime-green)';\n            } catch (err) {\n                console.error('Fetch error:', err);\n                ticker.innerHTML = `&lt;div class=\"loading\" style=\"color:var(--hot-pink)\">ERROR: ${escapeHtml(err.message)}&lt;\/div>`;\n                document.getElementById('connection-status').innerText = 'OFFLINE';\n                document.getElementById('connection-status').style.color = 'var(--hot-pink)';\n            }\n        }\n\n        function formatPrice(price) {\n            if (price === null || price === undefined) return 'N\/A';\n            return Number(price).toLocaleString('en-US', {\n                minimumFractionDigits: 2,\n                maximumFractionDigits: 2\n            });\n        }\n\n        function renderMarkets(quotes) {\n            if (!quotes.length) {\n                ticker.innerHTML = `&lt;div class=\"loading\">Unable to load market quotes&lt;\/div>`;\n                return;\n            }\n\n            const headerBanner = `&lt;div style=\"text-align:center;color:var(--electric-blue);font-family:'Electrolize';letter-spacing:2px;margin-bottom:20px;\">LIVE MARKET WATCH \u2022 INDICES, COMMODITIES &amp; EQUITIES&lt;\/div>`;\n\n            ticker.innerHTML = headerBanner + `&lt;div class=\"markets-grid\">${quotes.map(q => {\n                const isUp = Number(q.change) >= 0;\n                const dirClass = q.price === null ? '' : (isUp ? 'up' : 'down');\n                const arrow = isUp ? '\u25b2' : '\u25bc';\n                const sign = isUp ? '+' : '';\n                const changeText = q.price === null\n                    ? 'UNAVAILABLE'\n                    : `${arrow} ${sign}${Number(q.change).toFixed(2)} (${sign}${Number(q.change_pct).toFixed(2)}%)`;\n\n                return `\n                    &lt;div class=\"stock-card ${dirClass}\">\n                        &lt;div class=\"stock-header\">\n                            &lt;div class=\"stock-symbol\">${escapeHtml(q.symbol)}&lt;\/div>\n                            &lt;div class=\"stock-name\" title=\"${escapeHtml(q.name)}\">${escapeHtml(q.name)}&lt;\/div>\n                        &lt;\/div>\n                        &lt;div class=\"stock-price\">${q.price !== null ? '$' + formatPrice(q.price) : 'N\/A'}&lt;\/div>\n                        &lt;div class=\"stock-change ${dirClass}\">${changeText}&lt;\/div>\n                    &lt;\/div>\n                `;\n            }).join('')}&lt;\/div>`;\n        }\n\n        function renderNews(articles) {\n            if (!articles.length) {\n                ticker.innerHTML = `&lt;div class=\"loading\">Unable to load news headlines&lt;\/div>`;\n                return;\n            }\n\n            const headerBanner = `&lt;div style=\"text-align:center;color:var(--electric-blue);font-family:'Electrolize';letter-spacing:2px;margin-bottom:20px;\">TOP 9 HEADLINES \u2022 GOOGLE NEWS&lt;\/div>`;\n\n            ticker.innerHTML = headerBanner + `&lt;div class=\"news-grid\">${articles.map((item, idx) => `\n                &lt;div class=\"news-card\">\n                    &lt;div class=\"news-meta\">\n                        &lt;span>#${idx + 1} \u2022 ${escapeHtml(item.domain)}&lt;\/span>\n                        &lt;span>${escapeHtml(item.time_ago)}&lt;\/span>\n                    &lt;\/div>\n                    &lt;a href=\"${escapeHtml(item.url)}\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"news-headline\">\n                        ${escapeHtml(item.title)}\n                    &lt;\/a>\n                    &lt;div class=\"news-blurb\">\n                        ${escapeHtml(item.blurb)}\n                    &lt;\/div>\n                    &lt;div class=\"news-footer\">\n                        &lt;span>Source: ${escapeHtml(item.domain)}&lt;\/span>\n                        &lt;a href=\"${escapeHtml(item.url)}\" target=\"_blank\" rel=\"noopener noreferrer\" style=\"color:var(--accent-orange);text-decoration:none;\">Read Article \u2197&lt;\/a>\n                    &lt;\/div>\n                &lt;\/div>\n            `).join('')}&lt;\/div>`;\n        }\n\n        function renderGames(games, league, source) {\n            if (!games.length) {\n                ticker.innerHTML = `&lt;div class=\"loading\">No Games for ${league.toUpperCase()}&lt;\/div>`;\n                return;\n            }\n\n            const sourceBanner = source === 'upcoming'\n                ? `&lt;div style=\"text-align:center;color:var(--accent-orange);font-family:'Electrolize';letter-spacing:2px;margin-bottom:20px;\">UPCOMING SCHEDULE (EASTERN TIME)&lt;\/div>`\n                : source === 'yesterday' || source === 'recent'\n                ? `&lt;div style=\"text-align:center;color:var(--accent-orange);font-family:'Electrolize';letter-spacing:2px;margin-bottom:20px;\">RECENT RESULTS&lt;\/div>`\n                : '';\n\n            ticker.innerHTML = sourceBanner + `&lt;div class=\"games-grid\">${games.map(g => {\n                const hScore = g.home_score ?? g.homeScore ?? null;\n                const aScore = g.away_score ?? g.awayScore ?? null;\n                const isFinal = \/final|closed\/i.test(g.status);\n                const isLive = \/live|progress\/i.test(g.status);\n\n                const detail = (g.period || g.scheduled_time || '').trim();\n                const statusBadge = isLive\n                    ? `&lt;span class=\"live-pill\">\u25cf LIVE&lt;\/span>${escapeHtml(detail)}`\n                    : escapeHtml(detail ? `${g.status.toUpperCase()} \u2022 ${detail}` : g.status.toUpperCase());\n\n                return `\n                    &lt;div class=\"game-card ${isLive ? 'live' : ''}\">\n                        &lt;div style=\"font-size: 0.75rem; color: ${isLive ? 'var(--lime-green)' : 'var(--text-gray)'}; font-weight: bold; margin-bottom: 10px;\">\n                            ${statusBadge}\n                        &lt;\/div>\n                        &lt;div class=\"matchup\">\n                            ${renderTeam(g.away_team || g.away, aScore, g.away_logo, isFinal &amp;&amp; aScore > hScore)}\n                            &lt;div style=\"font-weight:bold; color:rgba(255,255,255,0.15)\">@&lt;\/div>\n                            ${renderTeam(g.home_team || g.home, hScore, g.home_logo, isFinal &amp;&amp; hScore > aScore)}\n                        &lt;\/div>\n                    &lt;\/div>\n                `;\n            }).join('')}&lt;\/div>`;\n            wireLogos();\n        }\n\n        function renderTeam(name, score, logo, isWinner) {\n            const abbr = (name || \"TMW\").substring(0, 3).toUpperCase();\n            return `\n                &lt;div class=\"team-info ${isWinner ? 'winner' : ''}\">\n                    &lt;div class=\"team-logo-wrap\">\n                        &lt;div class=\"team-logo-placeholder\">${abbr}&lt;\/div>\n                        ${logo ? `&lt;img data-src=\"${logo}\" class=\"team-logo-img\" alt=\"${name}\">` : ''}\n                    &lt;\/div>\n                    &lt;div style=\"font-weight:bold; font-size:1.05rem; text-align:center;\">${name}&lt;\/div>\n                    &lt;div class=\"score\">${score !== null ? score : '-'}&lt;\/div>\n                &lt;\/div>\n            `;\n        }\n\n        function updateBottomTickerFromGames(games) {\n            const weatherItem = `&lt;span class=\"news-item\">${state.weatherSummary}&lt;\/span>`;\n            const sportsItems = games.slice(0, 8).map(g => {\n                const away = g.away_team || g.away;\n                const home = g.home_team || g.home;\n                const prefix = g.status === 'live' ? '\ud83d\udd34 LIVE: ' : '';\n                const scoreStr = (g.away_score !== null &amp;&amp; g.home_score !== null)\n                    ? `${prefix}${away} ${g.away_score} @ ${home} ${g.home_score} (${g.period || g.status})`\n                    : `${away} @ ${home} (${g.scheduled_time || g.status})`;\n                return `&lt;span class=\"news-item\">${escapeHtml(scoreStr)}&lt;\/span>`;\n            }).join('');\n            \n            newsContent.innerHTML = weatherItem + sportsItems;\n            newsDup.innerHTML = newsContent.innerHTML;\n        }\n\n        function updateBottomTickerFromMarkets(quotes) {\n            const weatherItem = `&lt;span class=\"news-item\">${state.weatherSummary}&lt;\/span>`;\n            const marketItems = quotes\n                .filter(q => q.price !== null)\n                .map(q => {\n                    const sign = q.change >= 0 ? '+' : '';\n                    return `&lt;span class=\"news-item\">\ud83d\udcc8 ${escapeHtml(q.symbol)}: $${formatPrice(q.price)} (${sign}${Number(q.change_pct).toFixed(2)}%)&lt;\/span>`;\n                }).join('');\n\n            newsContent.innerHTML = weatherItem + marketItems;\n            newsDup.innerHTML = newsContent.innerHTML;\n        }\n\n        function updateBottomTickerFromNews(articles) {\n            const weatherItem = `&lt;span class=\"news-item\">${state.weatherSummary}&lt;\/span>`;\n            const newsItems = articles.map(a => `&lt;span class=\"news-item\">\ud83d\udcf0 ${escapeHtml(a.title)} (${escapeHtml(a.domain)})&lt;\/span>`).join('');\n            \n            newsContent.innerHTML = weatherItem + newsItems;\n            newsDup.innerHTML = newsContent.innerHTML;\n        }\n\n        function wireLogos() {\n            document.querySelectorAll('.team-logo-img&#91;data-src]').forEach(img => {\n                const placeholder = img.previousElementSibling;\n                const reveal = () => { img.style.opacity = '1'; if (placeholder) placeholder.style.opacity = '0'; };\n                img.onload = reveal;\n                img.onerror = () => img.remove();\n                img.src = img.dataset.src;\n                img.removeAttribute('data-src');\n                if (img.complete &amp;&amp; img.naturalWidth > 0) reveal();\n            });\n        }\n\n        function refreshScores() {\n            ticker.innerHTML = `&lt;div class=\"loading\">LOADING ${state.currentLeague.toUpperCase()}...&lt;\/div>`;\n            fetchScores(state.currentLeague);\n        }\n\n        function toggleAutoCycle() {\n            state.isAutoCycle = !state.isAutoCycle;\n            document.getElementById('cycle-btn').innerText = state.isAutoCycle ? \"\u23f8\" : \"\u25b6\";\n        }\n\n        document.getElementById('league-btns').addEventListener('click', (e) => {\n            if (e.target.dataset.league) {\n                document.querySelectorAll('.league-btn').forEach(b => b.classList.remove('active'));\n                e.target.classList.add('active');\n                state.currentLeague = e.target.dataset.league;\n                state.currentIndex = LEAGUES.indexOf(state.currentLeague);\n                state.isAutoCycle = false;\n                document.getElementById('cycle-btn').innerText = \"\u25b6\";\n                refreshScores();\n            }\n        });\n\n        setInterval(() => {\n            if (state.isAutoCycle) {\n                state.currentIndex = (state.currentIndex + 1) % LEAGUES.length;\n                state.currentLeague = LEAGUES&#91;state.currentIndex];\n                document.querySelectorAll('.league-btn').forEach(b => b.classList.toggle('active', b.dataset.league === state.currentLeague));\n            }\n            fetchScores(state.currentLeague);\n        }, 30000);\n\n        setInterval(fetchWeather, 900000);\n\n        fetchWeather();\n        fetchScores(state.currentLeague);\n    &lt;\/script>\n&lt;\/body>\n&lt;\/html>\n<\/code><\/pre>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-189e4cbd-091f-42ba-aa74-e5cfd4688a48\" href=\"https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_lcars.html\">ticker_lcars<\/a><a href=\"https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_lcars.html\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-189e4cbd-091f-42ba-aa74-e5cfd4688a48\">Download<\/a><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Optional LCARs version. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I asked Gemini to create a Sports \/ News \/ Markets ticker to replace my instance of Magic Mirror. I also created an alternate LCARs version \ud83d\ude42 scores.php handles all the backend. All of the connections are grabbing public sources; no API keys needed. This is the front-end HTML page. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":792,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[130,132,9,11,131],"tags":[],"class_list":["post-791","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai","category-gemini","category-raspberry-pi","category-software","category-vibe-coded"],"jetpack_featured_media_url":"https:\/\/www.markwheeler.com\/wp-content\/uploads\/2026\/12\/ticker_ncaa-scaled.png","_links":{"self":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/791","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=791"}],"version-history":[{"count":1,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/791\/revisions"}],"predecessor-version":[{"id":796,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/791\/revisions\/796"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/media\/792"}],"wp:attachment":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=791"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}