// Global variables let currentMarketData = {}; function getLang() { return document.documentElement.lang || 'en'; } // Market Data Fetching async function fetchMarketData() { try { const resp = await fetch('api/market_api.php'); if (!resp.ok) throw new Error('Network response was not ok'); const result = await resp.json(); if (result.success) { currentMarketData = result.data; updateUI(); } } catch (e) { console.error('Market API error', e); } } function updateUI() { // Update Home Page Market List (Market Trends Table) const homeList = document.getElementById('market-trends'); if (homeList) { let html = ''; const symbols = ['BTC', 'ETH', 'BNB', 'SOL', 'XRP', 'DOGE', 'ADA', 'TRX']; symbols.forEach(symbol => { const coin = currentMarketData[symbol]; if (coin) { const changeClass = coin.change >= 0 ? 'text-success' : 'text-danger'; const changeSign = coin.change >= 0 ? '+' : ''; const iconClass = coin.change >= 0 ? 'fa-arrow-trend-up' : 'fa-arrow-trend-down'; html += `