Spaces:
Running
Running
File size: 2,467 Bytes
8c42bbe 8ae99e7 8c42bbe 8ae99e7 8c42bbe 8ae99e7 8c42bbe 8ae99e7 8c42bbe | 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
// 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
|