|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() { |
|
|
|
|
|
console.log('CryptoSwap Galaxy Explorer loaded'); |
|
|
|
|
|
|
|
|
document.querySelectorAll('a[href^="#"]').forEach(anchor => { |
|
|
anchor.addEventListener('click', function (e) { |
|
|
e.preventDefault(); |
|
|
document.querySelector(this.getAttribute('href')).scrollIntoView({ |
|
|
behavior: 'smooth' |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
function updateTicker() { |
|
|
const coins = ['BTC', 'ETH', 'SOL', 'XRP', 'ADA']; |
|
|
const ticker = document.getElementById('exchange-ticker'); |
|
|
|
|
|
if (ticker) { |
|
|
let tickerContent = ''; |
|
|
coins.forEach(coin => { |
|
|
const price = (Math.random() * 10000).toFixed(2); |
|
|
const change = (Math.random() * 5 - 2.5).toFixed(2); |
|
|
const isPositive = parseFloat(change) > 0; |
|
|
|
|
|
tickerContent += ` |
|
|
<div class="flex items-center px-4"> |
|
|
<span class="font-medium">${coin}</span> |
|
|
<span class="mx-2">$${price}</span> |
|
|
<span class="${isPositive ? 'text-green-400' : 'text-red-400'}"> |
|
|
${isPositive ? '+' : ''}${change}% |
|
|
</span> |
|
|
</div> |
|
|
`; |
|
|
}); |
|
|
|
|
|
ticker.innerHTML = tickerContent; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
setInterval(updateTicker, 5000); |
|
|
updateTicker(); |