cryptoinsightx / index.html
LBazzo's picture
remove the inicial page of an analyzing crypto pair message that does not go away. make sure to fix that and anything else that needs to finish the app - Follow Up Deployment
0752f31 verified
Raw History Blame Contribute Delete
51.5 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> <title>CryptoInsightX - Real-time Crypto Analysis</title> <link rel="manifest" href="/manifest.json"> <link rel="icon" type="image/x-icon" href="http://static.photos/black/32x32/1"> <script src="https://cdn.tailwindcss.com"></script> <link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet"> <script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script> <script src="https://unpkg.com/feather-icons"></script> <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet"> <style> body { font-family: 'Inter', sans-serif; background-color: #0f172a; color: #e2e8f0; } .gradient-text { background: linear-gradient(90deg, #3b82f6, #8b5cf6); -webkit-background-clip: text; background-clip: text; color: transparent; } .chart-container { background-color: #1e293b; border-radius: 0.75rem; border: 1px solid #334155; } .card-hover:hover { transform: translateY(-4px); transition: transform 0.3s ease; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2); } </style> </head> <body class="min-h-screen"> <div class="container mx-auto px-4 py-8"> <!-- Header/Navbar --> <header class="flex justify-between items-center mb-10"> <div class="flex items-center"> <i data-feather="bar-chart-2" class="text-indigo-500 mr-2" width="28" height="28"></i> <h1 class="text-2xl font-bold gradient-text">CryptoInsightX</h1> </div> <nav class="hidden md:flex space-x-6"> <a href="#" class="text-slate-300 hover:text-indigo-400 font-medium">Dashboard</a> <a href="#" class="text-slate-300 hover:text-indigo-400 font-medium">Markets</a> <a href="#" class="text-slate-300 hover:text-indigo-400 font-medium">Strategies</a> <a href="#" class="text-slate-300 hover:text-indigo-400 font-medium">News</a> </nav> <button class="md:hidden"> <i data-feather="menu" class="text-slate-300"></i> </button> </header> <!-- Main Content --> <main> <div id="loading-overlay" class="fixed inset-0 bg-slate-900/90 flex items-center justify-center z-50 hidden"> <div class="text-center"> <div class="inline-block animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-indigo-500 mb-4"></div> <p class="text-slate-300 text-lg">Analyzing crypto pair...</p> </div> </div> <!-- Crypto Pair Selector Section --> <section class="mb-12" data-aos="fade-up"> <div class="max-w-2xl mx-auto"> <div class="relative"> <div class="flex"> <select id="base-currency-select" class="flex-1 bg-slate-800 text-slate-200 border-r border-slate-700 rounded-l-lg py-4 px-4 appearance-none focus:outline-none focus:ring-2 focus:ring-indigo-500"> <option value="">Select cryptocurrency</option> <option value="BTC">Bitcoin (BTC)</option> <option value="ETH">Ethereum (ETH)</option> <option value="BNB">Binance Coin (BNB)</option> <option value="SOL">Solana (SOL)</option> <option value="XRP">Ripple (XRP)</option> <option value="ADA">Cardano (ADA)</option> <option value="DOGE">Dogecoin (DOGE)</option> <option value="DOT">Polkadot (DOT)</option> <option value="MATIC">Polygon (MATIC)</option> <option value="AVAX">Avalanche (AVAX)</option> </select> <div class="bg-slate-700 text-slate-300 px-4 flex items-center justify-center border-r border-slate-600"> / </div> <select id="quote-currency-select" class="flex-1 bg-slate-800 text-slate-200 rounded-r-lg py-4 px-4 appearance-none focus:outline-none"> <option value="USDT">USDT</option> <option value="USD">USD</option> <option value="BTC">BTC</option> <option value="ETH">ETH</option> <option value="BNB">BNB</option> </select> </div> <button id="analyze-btn" class="mt-4 w-full bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg px-4 py-3 flex items-center justify-center"> <i data-feather="search" class="mr-2" width="16"></i> Analyze Selected Pair </button> </div> <p class="text-slate-500 text-sm mt-2">Select a cryptocurrency pair to receive real-time analysis</p> </div> </section> <!-- Crypto Pair Display --> <section id="crypto-pair-section" class="mb-10 hidden" data-aos="fade-up"> <div class="bg-slate-800 rounded-xl p-6 border border-slate-700"> <div class="flex flex-col md:flex-row justify-between items-start md:items-center"> <div class="flex items-center mb-4 md:mb-0" id="pair-header"> <img id="pair-icon" src="http://static.photos/blue/64x64/1" class="w-12 h-12 rounded-full mr-4"> <div> <h2 id="pair-name" class="text-xl font-bold text-white">BTC/USDT</h2> <div class="flex items-center"> <span id="price-change" class="text-green-500 font-medium mr-2">+4.32%</span> <span id="current-price" class="text-slate-400">$42,856.21</span> </div> </div> </div> <div class="flex space-x-3"> <button id="watchlist-btn" class="bg-slate-700 hover:bg-slate-600 text-slate-200 px-4 py-2 rounded-lg flex items-center"> <i data-feather="star" class="mr-2" width="16"></i> Watchlist </button> <button id="refresh-btn" class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg flex items-center"> <i data-feather="refresh-cw" class="mr-2" width="16"></i> Refresh Data </button> </div> </div> </div> </section> <!-- Search Section --> <section class="mb-12" data-aos="fade-up"> <div class="max-w-2xl mx-auto"> <div class="relative"> <input type="text" placeholder="Search crypto pair (e.g. BTC/USDT)" class="w-full bg-slate-800 rounded-lg py-4 px-6 text-slate-200 placeholder-slate-400 focus:ring-2 focus:ring-indigo-500 focus:border-transparent" > <button class="absolute right-3 top-3 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg px-4 py-2 flex items-center"> <i data-feather="search" class="mr-2" width="16"></i> Analyze </button> </div> </div> </section> <!-- Display Selected Pair --> <section class="mb-10" data-aos="fade-up"> <div class="bg-slate-800 rounded-xl p-6 border border-slate-700"> <div class="flex flex-col md:flex-row justify-between items-start md:items-center"> <div class="flex items-center mb-4 md:mb-0"> <img src="http://static.photos/blue/64x64/1" alt="BTC" class="w-12 h-12 rounded-full mr-4"> <div> <h2 class="text-xl font-bold text-white">BTC/USDT</h2> <div class="flex items-center"> <span class="text-green-500 font-medium mr-2">+4.32%</span> <span class="text-slate-400">$42,856.21</span> </div> </div> </div> <div class="flex space-x-3"> <button class="bg-slate-700 hover:bg-slate-600 text-slate-200 px-4 py-2 rounded-lg flex items-center"> <i data-feather="star" class="mr-2" width="16"></i> Watchlist </button> <button class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg flex items-center"> <i data-feather="refresh-cw" class="mr-2" width="16"></i> Refresh Data </button> </div> </div> </div> </section> <!-- Dashboard Grid --> <div id="dashboard-grid" class="grid grid-cols-1 lg:grid-cols-3 gap-6 hidden"> <!-- Overview Card --> <div id="overview-card" class="lg:col-span-2 bg-slate-800 rounded-xl p-6 border border-slate-700 card-hover" data-aos="fade-right"> <div class="flex justify-between items-center mb-6"> <h2 class="text-lg font-semibold text-white">Overview</h2> <div id="pair-info" class="hidden md:flex items-center space-x-2"> <span id="market-cap" class="text-sm text-slate-400">$820.2B</span> <span class="text-slate-600">|</span> <span id="24h-volume" class="text-sm text-slate-400">$28.4B</span> <span class="text-slate-600">|</span> <span id="circulating-supply" class="text-sm text-slate-400">19.5M BTC</span> </div> <div class="flex space-x-2"> <button class="bg-slate-700 text-indigo-400 px-3 py-1 rounded-lg text-sm">1D</button> <button class="bg-slate-700 text-slate-300 px-3 py-1 rounded-lg text-sm">1W</button> <button class="bg-slate-700 text-slate-300 px-3 py-1 rounded-lg text-sm">1M</button> </div> </div> <!-- TradingView Chart Widget --> <div id="main-chart" class="tradingview-widget-container mb-6" style="height:300px;"> <div id="tv-chart-1h" style="height:100%;"></div> <div id="chart-error" class="hidden absolute inset-0 bg-slate-900/80 rounded-lg flex items-center justify-center"> <p class="text-red-400 text-center px-4">Chart failed to load. Please refresh.</p> </div> <script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script> <script type="text/javascript"> new TradingView.widget({ "autosize": true, "symbol": "BINANCE:BTCUSDT", "interval": "60", "timezone": "Etc/UTC", "theme": "dark", "style": "1", "locale": "en", "toolbar_bg": "#0f172a", "enable_publishing": false, "hide_top_toolbar": false, "hide_side_toolbar": false, "allow_symbol_change": true, "details": true, "studies": ["RSI@tv-basicstudies", "MACD@tv-basicstudies"], "container_id": "tv-chart-1h" }); </script> </div> <!-- Multi-timeframe Chart Tabs --> <div class="flex border-b border-slate-700 mb-4"> <button class="timeframe-tab active px-4 py-2 text-indigo-400 font-medium" data-timeframe="5">5m</button> <button class="timeframe-tab px-4 py-2 text-slate-400" data-timeframe="15">15m</button> <button class="timeframe-tab px-4 py-2 text-slate-400" data-timeframe="60">1h</button> <button class="timeframe-tab px-4 py-2 text-slate-400" data-timeframe="240">4h</button> </div> <!-- Additional TradingView Chart Container --> <div class="grid grid-cols-1 lg:grid-cols-2 gap-4"> <div id="5m-chart-container" class="tradingview-widget-container chart-container" style="height:300px;"> <div id="tv-chart-5m" style="height:100%;"></div> <script type="text/javascript"> new TradingView.widget({ "autosize": true, "symbol": "BINANCE:BTCUSDT", "interval": "5", "timezone": "Etc/UTC", "theme": "dark", "style": "1", "locale": "en", "toolbar_bg": "#0f172a", "enable_publishing": false, "hide_top_toolbar": true, "hide_side_toolbar": true, "allow_symbol_change": false, "container_id": "tv-chart-5m" }); </script> </div> <div id="15m-chart-container" class="tradingview-widget-container chart-container" style="height:300px;"> <div id="tv-chart-15m" style="height:100%;"></div> <script type="text/javascript"> new TradingView.widget({ "autosize": true, "symbol": "BINANCE:BTCUSDT", "interval": "15", "timezone": "Etc/UTC", "theme": "dark", "style": "1", "locale": "en", "toolbar_bg": "#0f172a", "enable_publishing": false, "hide_top_toolbar": true, "hide_side_toolbar": true, "allow_symbol_change": false, "container_id": "tv-chart-15m" }); </script> </div> </div> <div class="grid grid-cols-2 md:grid-cols-4 gap-4"> <div class="bg-slate-900 p-4 rounded-lg"> <p class="text-slate-400 text-sm mb-1">Market Cap</p> <p class="text-white font-semibold">$820.2B</p> </div> <div class="bg-slate-900 p-4 rounded-lg"> <p class="text-slate-400 text-sm mb-1">24h Volume</p> <p class="text-white font-semibold">$28.4B</p> </div> <div class="bg-slate-900 p-4 rounded-lg"> <p class="text-slate-400 text-sm mb-1">Circulating Supply</p> <p class="text-white font-semibold">19.5M BTC</p> </div> <div class="bg-slate-900 p-4 rounded-lg"> <p class="text-slate-400 text-sm mb-1">All Time High</p> <p class="text-white font-semibold">$69,045</p> </div> </div> </div> <!-- Trading Signals --> <div id="signals-card" class="bg-slate-800 rounded-xl p-6 border border-slate-700 card-hover" data-aos="fade-left"> <div class="flex justify-between items-center mb-6"> <h2 class="text-lg font-semibold text-white">Trading Signals</h2> <span class="text-xs px-2 py-1 rounded-full bg-green-900 text-green-400">LIVE</span> </div> <div class="space-y-6"> <div id="day-trade-signal"> <div class="flex justify-between items-center mb-2"> <p class="text-slate-300">Day Trade Probability</p> <span id="day-trade-value" class="text-green-400 font-medium">68% Profit</span> <span id="day-trade-confidence" class="text-xs px-2 py-1 rounded-full bg-green-900/30 text-green-400 ml-2">HIGH</span> </div> <div class="w-full bg-slate-700 rounded-full h-2"> <div id="day-trade-bar" class="bg-green-500 h-2 rounded-full" style="width: 68%"></div> </div> </div> <div id="long-term-signal"> <div class="flex justify-between items-center mb-2"> <p class="text-slate-300">Long-Term Hold</p> <span id="long-term-value" class="text-green-400 font-medium">82% Profit</span> <span id="long-term-confidence" class="text-xs px-2 py-1 rounded-full bg-yellow-900/30 text-yellow-400 ml-2">MEDIUM</span> </div> <div class="w-full bg-slate-700 rounded-full h-2"> <div id="long-term-bar" class="bg-green-500 h-2 rounded-full" style="width: 82%"></div> </div> </div> <div> <div class="flex justify-between items-center mb-2"> <p class="text-slate-300">Long-Term Hold</p> <p class="text-green-400 font-medium">82% Profit</p> </div> <div class="w-full bg-slate-700 rounded-full h-2"> <div class="bg-green-500 h-2 rounded-full" style="width: 82%"></div> </div> </div> <div class="bg-indigo-900/30 p-4 rounded-lg border border-indigo-800"> <h3 class="text-indigo-400 font-medium mb-2 text-sm">Recommended Strategy</h3> <p class="text-white">Buy in range $42,200-$42,500 with target $44,000 (5% profit). Stop loss at $41,800.</p> </div> <div class="flex justify-between items-center"> <div> <p class="text-slate-400 text-sm">Best Entry Point</p> <p class="text-white font-medium">$42,350</p> </div> <div> <p class="text-slate-400 text-sm">Best Exit Point</p> <p class="text-white font-medium">$44,100</p> </div> </div> </div> </div> <!-- Market Sentiment --> <div id="sentiment-card" class="bg-slate-800 rounded-xl p-6 border border-slate-700 card-hover" data-aos="fade-right"> <div class="flex justify-between items-center mb-6"> <h2 class="text-lg font-semibold text-white">Market Sentiment</h2> <div class="flex space-x-1"> <i data-feather="twitter" class="text-sky-400"></i> <i data-feather="linkedin" class="text-blue-500"></i> <i data-feather="message-square" class="text-green-500"></i> </div> </div> <canvas id="sentimentChart" height="180" class="chart-container p-4 mb-6"></canvas> <div class="flex justify-around items-center text-center"> <div> <div class="w-12 h-12 rounded-full bg-green-900/30 flex items-center justify-center mx-auto mb-2"> <i data-feather="thumbs-up" class="text-green-400"></i> </div> <p class="text-green-400 font-medium">72% Bullish</p> </div> <div> <div class="w-12 h-12 rounded-full bg-red-900/30 flex items-center justify-center mx-auto mb-2"> <i data-feather="thumbs-down" class="text-red-400"></i> </div> <p class="text-red-400 font-medium">19% Bearish</p> </div> <div> <div class="w-12 h-12 rounded-full bg-slate-700 flex items-center justify-center mx-auto mb-2"> <i data-feather="minus" class="text-slate-400"></i> </div> <p class="text-slate-400">9% Neutral</p> </div> </div> </div> <!-- Latest News --> <div id="news-card" class="bg-slate-800 rounded-xl p-6 border border-slate-700 card-hover" data-aos="fade-up"> <div class="flex justify-between items-center mb-6"> <h2 class="text-lg font-semibold text-white">Latest News</h2> <button class="text-indigo-400 text-sm flex items-center"> View All <i data-feather="chevron-right" class="ml-1" width="16"></i> </button> </div> <div id="news-container" class="space-y-4"> <div class="flex news-item"> <img src="http://static.photos/finance/80x80/1" alt="News" class="w-16 h-16 rounded-lg object-cover mr-4"> <div> <h3 class="text-white font-medium mb-1">Bitcoin ETF Approval Expected Soon</h3> <p class="text-slate-400 text-sm line-clamp-2">Major financial institutions are preparing for Bitcoin ETF approvals possibly coming next month, which could significantly impact markets.</p> <a href="#" class="text-indigo-400 hover:text-indigo-300 text-xs mt-1 inline-block">Read more →</a> </div> </div> <div class="flex"> <img src="http://static.photos/finance/80x80/2" alt="News" class="w-16 h-16 rounded-lg object-cover mr-4"> <div> <h3 class="text-white font-medium mb-1">Whale Activity Spikes as BTC Reaches Resistance</h3> <p class="text-slate-400 text-sm line-clamp-2">Large Bitcoin holders have been moving coins to exchanges, indicating possible profit taking at current levels.</p> </div> </div> <div class="flex"> <img src="http://static.photos/finance/80x80/3" alt="News" class="w-16 h-16 rounded-lg object-cover mr-4"> <div> <h3 class="text-white font-medium mb-1">Ethereum Layer 2 Solutions See Record Growth</h3> <p class="text-slate-400 text-sm line-clamp-2">Transaction volume on Ethereum Layer 2 networks has grown 150% this quarter, pointing to increasing adoption.</p> </div> </div> </div> </div> <!-- Technical Indicators --> <div id="indicators-card" class="bg-slate-800 rounded-xl p-6 border border-slate-700 card-hover" data-aos="fade-left"> <div class="flex justify-between items-center mb-6"> <h2 class="text-lg font-semibold text-white">Technical Indicators</h2> <button class="text-indigo-400 text-sm">Show All</button> </div> <div class="grid gap-4"> <div> <div class="flex justify-between mb-2"> <div class="flex items-center"> <span class="w-4 h-4 bg-indigo-500 rounded-full mr-2"></span> <span class="text-slate-300">RSI (14)</span> </div> <span class="text-slate-300">57.2</span> </div> <div class="w-full bg-slate-700 rounded-full h-2"> <div class="bg-indigo-500 h-2 rounded-full" style="width: 57.2%"></div> </div> </div> <div> <div class="flex justify-between mb-2"> <div class="flex items-center"> <span class="w-4 h-4 bg-purple-500 rounded-full mr-2"></span> <span class="text-slate-300">MACD</span> </div> <span class="text-green-400">Bullish</span> </div> </div> <div> <div class="flex justify-between mb-2"> <div class="flex items-center"> <span class="w-4 h-4 bg-sky-500 rounded-full mr-2"></span> <span class="text-slate-300">Volume (24h)</span> </div> <span class="text-green-400">+12.4%</span> </div> <div class="w-full bg-slate-700 rounded-full h-2"> <div class="bg-sky-500 h-2 rounded-full" style="width: 70%"></div> </div> </div> <div> <div class="flex justify-between mb-2"> <div class="flex items-center"> <span class="w-4 h-4 bg-amber-500 rounded-full mr-2"></span> <span class="text-slate-300">Bollinger Bands</span> </div> <span class="text-green-400">Upper Band Test</span> </div> </div> </div> </div> </div> </main> <script> // Initialize animations AOS.init(); // Initialize UI elements document.addEventListener('DOMContentLoaded', function() { feather.replace(); // Initialize TradingView charts initTradingViewCharts(); // Initialize sentiment chart initSentimentChart(); // Set up event listeners document.getElementById('analyze-btn').addEventListener('click', handleSearch); document.getElementById('refresh-btn').addEventListener('click', handleRefresh); // Default to hidden dashboard until analysis completes document.getElementById('dashboard-grid').classList.add('hidden'); document.getElementById('crypto-pair-section').classList.add('hidden'); }); function initTradingViewCharts() { // Main 1h chart new TradingView.widget({ "autosize": true, "symbol": "BINANCE:BTCUSDT", "interval": "60", "timezone": "Etc/UTC", "theme": "dark", "style": "1", "locale": "en", "toolbar_bg": "#0f172a", "enable_publishing": false, "hide_top_toolbar": false, "hide_side_toolbar": false, "allow_symbol_change": true, "details": true, "studies": ["RSI@tv-basicstudies", "MACD@tv-basicstudies"], "container_id": "tv-chart-1h" }); // 5m chart new TradingView.widget({ "autosize": true, "symbol": "BINANCE:BTCUSDT", "interval": "5", "timezone": "Etc/UTC", "theme": "dark", "style": "1", "locale": "en", "toolbar_bg": "#0f172a", "enable_publishing": false, "hide_top_toolbar": true, "hide_side_toolbar": true, "allow_symbol_change": false, "container_id": "tv-chart-5m" }); // 15m chart new TradingView.widget({ "autosize": true, "symbol": "BINANCE:BTCUSDT", "interval": "15", "timezone": "Etc/UTC", "theme": "dark", "style": "1", "locale": "en", "toolbar_bg": "#0f172a", "enable_publishing": false, "hide_top_toolbar": true, "hide_side_toolbar": true, "allow_symbol_change": false, "container_id": "tv-chart-15m" }); } function initSentimentChart() { const ctx = document.getElementById('sentimentChart').getContext('2d'); const chart = new Chart(ctx, { type: 'doughnut', data: { labels: ['Bullish', 'Bearish', 'Neutral'], datasets: [{ data: [72, 19, 9], backgroundColor: [ 'rgba(16, 185, 129, 0.8)', 'rgba(239, 68, 68, 0.8)', 'rgba(148, 163, 184, 0.8)' ], borderColor: [ 'rgba(16, 185, 129, 1)', 'rgba(239, 68, 68, 1)', 'rgba(148, 163, 184, 1)' ], borderWidth: 1 }] }, options: { responsive: true, maintainAspectRatio: false, cutout: '70%', plugins: { legend: { display: false } } } }); window.sentimentChart = chart; } async function handleSearch() { const base = document.getElementById('base-currency-select').value; const quote = document.getElementById('quote-currency-select').value; if (!base) { alert('Please select a cryptocurrency to analyze'); return; } const pair = `${base}/${quote}`; showLoading(); // First update UI immediately with the pair updatePairDisplay(pair); showDashboard(); try { // Get cached analysis if available const cachedAnalysis = getCachedAnalysis(pair); if (cachedAnalysis) { updateUIWithRealData(cachedAnalysis); } // Fetch fresh data const data = await fetchPairData(pair); // Cache the analysis for 1 minute cacheAnalysis(pair, data); updateUIWithRealData(data); } catch (error) { console.error("Analysis error:", error); alert('Analysis failed. Please try again.'); } finally { hideLoading(); } } const analysisCache = {}; function getCachedAnalysis(pair) { const cached = analysisCache[pair]; if (cached && Date.now() - cached.timestamp < 60000) { // 1 minute cache return cached.data; } return null; } function cacheAnalysis(pair, data) { analysisCache[pair] = { data: data, timestamp: Date.now() }; } // Optimized loading flow async function fetchPairData(pair) { showLoading(); try { const [base] = pair.split('/'); // Try real API first try { const response = await fetch(`${API_BASE_URL}/pair-analysis?base=${base}`); if (response.ok) { const data = await response.json(); updateUIWithRealData(data); return; } } catch (apiError) { console.error("API Error:", apiError); } // Fallback to mock data const mockData = getMockData(base); updateUIWithRealData(mockData); } catch (error) { console.error("Error fetching data:", error); hideLoading(); alert('Analysis failed. Please try again.'); } finally { hideLoading(); } } function handleRefresh() { const currentPair = document.getElementById('pair-name').textContent; if (currentPair) { showLoading(); setTimeout(() => { hideLoading(); }, 1000); } } function showLoading() { document.getElementById('loading-overlay').classList.remove('hidden'); } function hideLoading() { document.getElementById('loading-overlay').classList.add('hidden'); // Ensure loading is always hidden even if called multiple times setTimeout(() => { document.getElementById('loading-overlay').classList.add('hidden'); }, 500); } function showDashboard() { const pairSection = document.getElementById('crypto-pair-section'); const dashboard = document.getElementById('dashboard-grid'); // Only show if we have valid data if (document.getElementById('pair-name').textContent) { pairSection.classList.remove('hidden'); dashboard.classList.remove('hidden'); } else { pairSection.classList.add('hidden'); dashboard.classList.add('hidden'); } } function updatePairDisplay(pair) { const [base, quote] = pair.split('/'); document.getElementById('pair-name').textContent = pair; document.getElementById('pair-icon').src = `http://static.photos/blue/64x64/${base.charCodeAt(0) % 100}`; // Update charts immediately (empty at first) updateCharts(pair); // Update current price with loading state const priceEl = document.querySelector('.text-slate-400'); priceEl.textContent = 'Loading...'; const changeEl = document.querySelector('.text-green-500'); changeEl.textContent = '0.00%'; changeEl.className = 'text-slate-400 font-medium mr-2'; } function updateCharts(pair) { const [base, quote] = pair.split('/'); const symbol = `BINANCE:${base}${quote}`; // Main chart if (window.tvWidget) { window.tvWidget.setSymbol(symbol); } // 5m chart if (window.tvWidget5m) { window.tvWidget5m.setSymbol(symbol); } // 15m chart if (window.tvWidget15m) { window.tvWidget15m.setSymbol(symbol); } } </script> <footer class="mt-20 pt-8 pb-12 border-t border-slate-800"> <div class="flex flex-col md:flex-row justify-between items-center"> <div class="flex items-center mb-4 md:mb-0"> <i data-feather="bar-chart-2" class="text-indigo-500 mr-2"></i> <span class="text-white font-medium">CryptoInsightX</span> </div> <div class="flex space-x-6"> <a href="#" class="text-slate-400 hover:text-indigo-400">Terms</a> <a href="#" class="text-slate-400 hover:text-indigo-400">Privacy</a> <a href="#" class="text-slate-400 hover:text-indigo-400">API</a> <a href="#" class="text-slate-400 hover:text-indigo-400">Contact</a> </div> </div> <div class="mt-6 text-center md:text-left text-sm text-slate-500"> <p>© 2023 CryptoInsightX. All market data is real-time and provided for informational purposes only.</p> <p class="mt-2">Cryptocurrency trading involves substantial risk of loss and is not suitable for every investor.</p> </div> </footer> </div> <script> // Initialize animations AOS.init(); feather.replace(); // Backend API Configuration const API_BASE_URL = 'https://api.cryptoinsightx.com/v1'; let currentPair = 'BTC/USDT'; // Initialize real-time data fetch async function initApp() { try { await fetchPairData(currentPair); setInterval(() => fetchPairData(currentPair), 60000); // Update every minute } catch (error) { console.error('Initialization error:', error); // Fallback to mock data if API fails updateUIWithRealData(getMockData()); } } // Fetch crypto pair data async function fetchPairData(pair) { const [base, quote] = pair.split('/'); try { // Fetch comprehensive data const response = await fetch(`${API_BASE_URL}/pair-analysis?base=${base}&quote=${quote}`); if (!response.ok) throw new Error('API response error'); const data = await response.json(); updateUIWithRealData(data); } catch (error) { console.error('Error fetching pair data:', error); // Fallback to mock data updateUIWithRealData(getMockData(base, quote)); } } // Mock data generator for development/testing function getMockData(base = 'BTC', quote = 'USDT') { const now = new Date(); const mockSentiment = { bullish: 65 + Math.floor(Math.random() * 15), bearish: 15 + Math.floor(Math.random() * 10), neutral: 20 - Math.floor(Math.random() * 5) }; return { base_symbol: base, quote_symbol: quote, current_price: 42000 + Math.floor(Math.random() * 1000), price_change_percentage_24h: (Math.random() * 5).toFixed(2), market_cap: 800000000000 + Math.floor(Math.random() * 20000000000), total_volume: 25000000000 + Math.floor(Math.random() * 5000000000), circulating_supply: 19400000, ath: 69000, sentiment: mockSentiment, news: [ { title: `${base} Price Surges Amid Market Rally`, source: "CryptoNews", url: "#", image_url: "http://static.photos/finance/80x80/1", published_at: now.toISOString(), summary: `${base} price has surged 5% today as the broader cryptocurrency market experiences a significant rally.` }, { title: `New ${base} Adoption By Major Retailer`, source: "Blockchain Daily", url: "#", image_url: "http://static.photos/finance/80x80/2", published_at: new Date(now - 86400000).toISOString(), summary: `A major online retailer has announced it will begin accepting ${base} as payment starting next month.` } ], analysis: { day_trade: { probability: 65 + Math.floor(Math.random() * 10), confidence: "high" }, long_term: { probability: 75 + Math.floor(Math.random() * 10), confidence: "medium" }, recommended_strategy: `Buy on dips below $42,000, target $44,500 for 5-7% gains. Set stop loss at $41,200.`, entry_points: "$42,100 - $42,500", exit_points: "$44,200 - $44,800" } }; } // Update UI with real backend data function updateUIWithRealData(data) { // Update price display document.querySelector('.text-slate-400').textContent = `${data.current_price.toLocaleString()}`; const changeElement = document.querySelector('.text-green-500.font-medium'); const changePercent = data.price_change_percentage_24h; changeElement.textContent = `${changePercent > 0 ? '+' : ''}${changePercent.toFixed(2)}%`; changeElement.className = changePercent > 0 ? 'text-green-500 font-medium mr-2' : 'text-red-500 font-medium mr-2'; // Update market data document.querySelectorAll('.bg-slate-900 p')[0].textContent = `${(data.market_cap / 1000000000).toFixed(1)}B`; document.querySelectorAll('.bg-slate-900 p')[1].textContent = `${(data.total_volume / 1000000000).toFixed(1)}B`; document.querySelectorAll('.bg-slate-900 p')[2].textContent = `${data.circulating_supply.toLocaleString()} ${data.base_symbol}`; document.querySelectorAll('.bg-slate-900 p')[3].textContent = `${data.ath.toLocaleString()}`; // Update charts (TradingView handles this via symbol change) updateTradingViewCharts(data.base_symbol, data.quote_symbol); // Update trading signals updateTradingSignals(data.analysis.signals); // Update sentiment updateSentimentChart(data.sentiment); // Update news updateNewsSection(data.news); } function updateTradingViewCharts(base, quote) { const symbol = `BINANCE:${base}${quote}`; // Update all chart widgets document.querySelectorAll('.tradingview-widget-container script').forEach(script => { const newScript = document.createElement('script'); newScript.type = 'text/javascript'; newScript.text = script.text.replace(/symbol: "[^"]+"/, `symbol: "${symbol}"`); script.parentNode.replaceChild(newScript, script); }); } function updateTradingSignals(signals) { document.querySelectorAll('.bg-green-500.h-2')[0].style.width = `${signals.day_trade.probability}%`; document.querySelectorAll('.bg-green-500.h-2')[1].style.width = `${signals.long_term.probability}%`; document.querySelector('.text-white').textContent = signals.recommended_strategy; } function updateSentimentChart(sentiment) { sentimentChart.data.datasets[0].data = [ sentiment.bullish, sentiment.bearish, sentiment.neutral ]; sentimentChart.update(); } function updateNewsSection(newsItems) { const newsContainer = document.querySelector('.space-y-4'); newsContainer.innerHTML = ''; newsItems.forEach(news => { const newsElement = document.createElement('div'); newsElement.className = 'flex'; newsElement.innerHTML = ` <img src="${news.image_url || 'http://static.photos/finance/80x80/3'}" alt="News" class="w-16 h-16 rounded-lg object-cover mr-4"> <div> <h3 class="text-white font-medium mb-1">${news.title}</h3> <p class="text-slate-400 text-sm line-clamp-2">${news.summary}</p> </div> `; newsContainer.appendChild(newsElement); }); } // Initialize Sentiment Chart const sentimentCtx = document.getElementById('sentimentChart').getContext('2d'); const sentimentChart = new Chart(sentimentCtx, { type: 'doughnut', data: { labels: ['Bullish', 'Bearish', 'Neutral'], datasets: [{ data: [72, 19, 9], backgroundColor: [ 'rgba(16, 185, 129, 0.8)', 'rgba(239, 68, 68, 0.8)', 'rgba(148, 163, 184, 0.8)' ], borderColor: [ 'rgba(16, 185, 129, 1)', 'rgba(239, 68, 68, 1)', 'rgba(148, 163, 184, 1)' ], borderWidth: 1 }] }, options: { responsive: true, maintainAspectRatio: false, cutout: '70%', plugins: { legend: { display: false } } } }); let isAnalyzing = false; async function handleSearch() { if (isAnalyzing) return; isAnalyzing = true; const base = document.getElementById('base-currency-select').value; const quote = document.getElementById('quote-currency-select').value; if (!base) { alert('Please select a cryptocurrency to analyze'); isAnalyzing = false; return; } try { await fetchPairData(`${base}/${quote}`); } catch (error) { console.error("Search error:", error); alert('Analysis failed. Please try again.'); } finally { isAnalyzing = false; } } // Initialize UI document.addEventListener('DOMContentLoaded', function() { feather.replace(); AOS.init(); // Initialize with no selection to force user to choose document.getElementById('base-currency-select').value = ''; document.getElementById('quote-currency-select').value = 'USDT'; // Setup search handler document.getElementById('analyze-btn').addEventListener('click', handleSearch); document.getElementById('refresh-btn').addEventListener('click', handleRefresh); }); </script> </body> </html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<title>CryptoInsightX - Real-time Crypto Analysis</title>
<link rel="manifest" href="/manifest.json">
<link rel="icon" type="image/x-icon" href="http://static.photos/black/32x32/1">
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet">
<script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Inter', sans-serif;
background-color: #0f172a;
color: #e2e8f0;
}
.gradient-text {
background: linear-gradient(90deg, #3b82f6, #8b5cf6);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
.chart-container {
background-color: #1e293b;
border-radius: 0.75rem;
border: 1px solid #334155;
}
.card-hover:hover {
transform: translateY(-4px);
transition: transform 0.3s ease;
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}
</style>
</head>
<body class="min-h-screen">
<div class="container mx-auto px-4 py-8">
<!-- Header/Navbar -->
<header class="flex justify-between items-center mb-10">
<div class="flex items-center">
<i data-feather="bar-chart-2" class="text-indigo-500 mr-2" width="28" height="28"></i>
<h1 class="text-2xl font-bold gradient-text">CryptoInsightX</h1>
</div>
<nav class="hidden md:flex space-x-6">
<a href="#" class="text-slate-300 hover:text-indigo-400 font-medium">Dashboard</a>
<a href="#" class="text-slate-300 hover:text-indigo-400 font-medium">Markets</a>
<a href="#" class="text-slate-300 hover:text-indigo-400 font-medium">Strategies</a>
<a href="#" class="text-slate-300 hover:text-indigo-400 font-medium">News</a>
</nav>
<button class="md:hidden">
<i data-feather="menu" class="text-slate-300"></i>
</button>
</header>
<!-- Main Content -->
<main>
<div id="loading-overlay" class="fixed inset-0 bg-slate-900/90 flex items-center justify-center z-50 hidden">
<div class="text-center">
<div class="inline-block animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-indigo-500 mb-4"></div>
<p class="text-slate-300 text-lg">Analyzing crypto pair...</p>
</div>
</div>
<!-- Crypto Pair Selector Section -->
<section class="mb-12" data-aos="fade-up">
<div class="max-w-2xl mx-auto">
<div class="relative">
<div class="flex">
<select id="base-currency-select" class="flex-1 bg-slate-800 text-slate-200 border-r border-slate-700 rounded-l-lg py-4 px-4 appearance-none focus:outline-none focus:ring-2 focus:ring-indigo-500">
<option value="">Select cryptocurrency</option>
<option value="BTC">Bitcoin (BTC)</option>
<option value="ETH">Ethereum (ETH)</option>
<option value="BNB">Binance Coin (BNB)</option>
<option value="SOL">Solana (SOL)</option>
<option value="XRP">Ripple (XRP)</option>
<option value="ADA">Cardano (ADA)</option>
<option value="DOGE">Dogecoin (DOGE)</option>
<option value="DOT">Polkadot (DOT)</option>
<option value="MATIC">Polygon (MATIC)</option>
<option value="AVAX">Avalanche (AVAX)</option>
</select>
<div class="bg-slate-700 text-slate-300 px-4 flex items-center justify-center border-r border-slate-600">
/
</div>
<select id="quote-currency-select" class="flex-1 bg-slate-800 text-slate-200 rounded-r-lg py-4 px-4 appearance-none focus:outline-none">
<option value="USDT">USDT</option>
<option value="USD">USD</option>
<option value="BTC">BTC</option>
<option value="ETH">ETH</option>
<option value="BNB">BNB</option>
</select>
</div>
<button id="analyze-btn" class="mt-4 w-full bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg px-4 py-3 flex items-center justify-center">
<i data-feather="search" class="mr-2" width="16"></i>