yashisgoat's picture
i wanted it to look minimal and should track the steps
3e24472 verified
Raw History Blame Contribute Delete
1.5 kB
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}`);
}