Spaces:
Running
Running
Download script.js from Nico85525/driver-dashboard-pro: direct link, hf CLI and curl.
- Browser
- Download file 2.47 kB
-
https://huggingface.co/spaces/Nico85525/driver-dashboard-pro/resolve/main/script.js
- Command line
-
hf download hf://spaces/Nico85525/driver-dashboard-pro/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Nico85525/driver-dashboard-pro/resolve/main/script.js
2.47 kB
| // Simulate real-time updates | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Update earnings every 30 seconds | |
| setInterval(() => { | |
| const earningsElement = document.querySelector('.text-2xl.font-bold'); | |
| if (earningsElement) { | |
| const currentEarnings = parseFloat(earningsElement.textContent.replace(', '')); | |
| const newEarnings = (currentEarnings + Math.random() * 2).toFixed(2); | |
| earningsElement.textContent = ' + newEarnings; | |
| } | |
| }, 30000); | |
| // Simulate ride completion | |
| setTimeout(() => { | |
| const progressBar = document.querySelector('.progress-fill'); | |
| if (progressBar) { | |
| progressBar.style.width = '100%'; | |
| } | |
| const progressText = document.querySelector('.text-right .text-xs'); | |
| if (progressText) { | |
| progressText.textContent = '100%'; | |
| } | |
| }, 5000); | |
| // Handle notification badge click | |
| const bellIcon = document.querySelector('[data-feather="bell"]'); | |
| if (bellIcon) { | |
| bellIcon.addEventListener('click', function() { | |
| document.getElementById('notification-badge').classList.add('hidden'); | |
| }); | |
| } | |
| }); | |
| // Toggle sidebar menu | |
| document.addEventListener('click', function(e) { | |
| if (e.target.closest('[data-feather="menu"]')) { | |
| alert('Sidebar menu would open here'); | |
| } | |
| }); | |
| // Simulate receiving push notifications | |
| function simulatePushNotification() { | |
| if ('serviceWorker' in navigator && 'PushManager' in window) { | |
| // In a real app, this would come from your backend | |
| console.log('Push notification received'); | |
| const notification = document.querySelector('notification-component'); | |
| if (notification) { | |
| notification.showNotification( | |
| 'New Ride Request', | |
| 'A new passenger is waiting for pickup nearby.', | |
| 'info' | |
| ); | |
| } | |
| } else { | |
| // Fallback for browsers that don't support push notifications | |
| const notification = document.querySelector('notification-component'); | |
| if (notification) { | |
| notification.showNotification( | |
| 'New Ride Request', | |
| 'A new passenger is waiting for pickup nearby.', | |
| 'info' | |
| ); | |
| } | |
| } | |
| } | |
| // Simulate periodic ride requests | |
| setInterval(simulatePushNotification, 60000); // Every minute in real app | |