File size: 1,503 Bytes
16addb8 3e24472 16addb8 3e24472 16addb8 3e24472 16addb8 | 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 |
document.addEventListener('DOMContentLoaded', function() {
// Step tracking simulation
function updateStepData() {
// Simulate step data (in a real app, this would come from device sensors)
const steps = Math.floor(Math.random() * 10000);
const distance = Math.floor(steps * 0.762); // avg step length in meters
const calories = Math.floor(steps * 0.04); // avg calories per step
const percent = Math.min(100, Math.floor((steps / 10000) * 100));
document.getElementById('steps-count').textContent = steps.toLocaleString();
document.getElementById('distance').textContent = distance.toLocaleString();
document.getElementById('calories').textContent = calories.toLocaleString();
document.getElementById('steps-percent').textContent = percent;
document.getElementById('steps-progress').style.width = `${percent}%`;
// Update sync time
const now = new Date();
document.getElementById('last-sync').textContent = now.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
}
// Initial update
updateStepData();
// Update every 5 seconds
setInterval(updateStepData, 5000);
// Mobile menu toggle functionality will be handled by the navbar component
});
// Simple analytics tracking
function trackEvent(eventName) {
if (typeof gtag !== 'undefined') {
gtag('event', eventName);
}
console.log(`Event tracked: ${eventName}`);
} |