Spaces:
Running
Running
Download script.js from Mrdeepc247/stockfolio-tracker: direct link, hf CLI and curl.
- Browser
- Download file 1.29 kB
-
https://huggingface.co/spaces/Mrdeepc247/stockfolio-tracker/resolve/main/script.js
- Command line
-
hf download hf://spaces/Mrdeepc247/stockfolio-tracker/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Mrdeepc247/stockfolio-tracker/resolve/main/script.js
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 | |
| }); | |
| }); | |
| }); |