stockfolio-tracker / script.js
Mrdeepc247's picture
stock trading app
e2f0cf4 verified
Raw History Blame Contribute Delete
1.29 kB
// 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
});
});
});