Spaces:
Running
Running
File size: 1,286 Bytes
e2f0cf4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | // Main JavaScript functionality for the stock trading app
document.addEventListener('DOMContentLoaded', function() {
// Initialize any necessary functionality
console.log('Stockfolio Tracker initialized');
// Simulate real-time price updates
setInterval(() => {
const priceElements = document.querySelectorAll('.price-up, .price-down');
priceElements.forEach(el => {
const isPositive = el.classList.contains('price-up');
const change = (Math.random() * 2).toFixed(2);
const sign = isPositive ? '+' : '-';
el.textContent = `${sign}${change}%`;
// Randomly toggle between positive and negative
if (Math.random() > 0.7) {
el.classList.toggle('price-up');
el.classList.toggle('price-down');
}
});
}, 3000);
// Add click handlers for stock rows
document.querySelectorAll('tr[class*="hover:bg-gray-50"]').forEach(row => {
row.addEventListener('click', function() {
const symbol = this.querySelector('td:first-child').textContent;
alert(`Viewing details for ${symbol}`);
// In a real app, this would navigate to the stock detail page
});
});
}); |