diff --git a/index.html b/index.html
index 0c62589..90db50a 100644
--- a/index.html
+++ b/index.html
@@ -1174,7 +1174,7 @@
0
- Goal: 10,000
+ Goal: 5,000
@@ -1337,6 +1337,37 @@
+
+
+
+
+
Daily Step Goal
+
+
5,000
+
steps per day
+
+
+
+
+ 1,000
+ 100,000
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1372,7 +1403,7 @@ const WEBHOOK_BASE = window.STEPMATES_CONFIG.webhookBase;
const APP_URL = window.location.origin + window.location.pathname.replace(/\/$/, '');
-const STEP_GOAL = 10000;
+const STEP_GOAL = 5000;
// ─────────────────────────────────────────────
// INIT
@@ -1634,7 +1665,14 @@ window.showSetupPanel = function() {
// TABS & STEP DISPLAY
// ─────────────────────────────────────────────
const TAB_LABELS = { day: 'Today', week: 'This Week', month: 'This Month', year: 'This Year', alltime: 'All Time' };
-const GOALS = { day: 10000, week: 70000, month: 300000, year: 3650000, alltime: null };
+function getDailyGoal() {
+ return currentUserData.dailyGoal || 5000;
+}
+
+function getGoals() {
+ const d = getDailyGoal();
+ return { day: d, week: d * 7, month: d * 30, year: d * 365, alltime: null };
+}
window.setTab = function(tab, el) {
currentTab = tab;
@@ -1683,6 +1721,7 @@ function isSameWeek(d, today) {
function renderMySteps() {
const steps = getStepsForPeriod(currentUserData.stepsByDate, currentTab);
document.getElementById('my-step-count').textContent = steps.toLocaleString();
+ const GOALS = getGoals();
const goal = GOALS[currentTab];
if (goal) {
const pct = Math.min(100, Math.round((steps / goal) * 100));
@@ -1983,6 +2022,42 @@ window.copyWebhook = function(urlElId, btnId) {
});
}
+// ─────────────────────────────────────────────
+// GOAL MODAL
+// ─────────────────────────────────────────────
+window.openGoalModal = function() {
+ const current = getDailyGoal();
+ document.getElementById('goal-slider').value = current;
+ document.getElementById('goal-modal-display').textContent = current.toLocaleString();
+ document.getElementById('goal-modal').classList.add('open');
+}
+
+window.closeGoalModal = function() {
+ document.getElementById('goal-modal').classList.remove('open');
+}
+
+window.closeGoalModalOutside = function(e) {
+ if (e.target === document.getElementById('goal-modal')) closeGoalModal();
+}
+
+window.setGoalPreset = function(val) {
+ document.getElementById('goal-slider').value = val;
+ document.getElementById('goal-modal-display').textContent = val.toLocaleString();
+}
+
+window.saveGoal = async function() {
+ const val = parseInt(document.getElementById('goal-slider').value);
+ await updateDoc(doc(db, 'users', currentUser.uid), { dailyGoal: val });
+ currentUserData.dailyGoal = val;
+ renderMySteps();
+ closeGoalModal();
+ showToast('Goal updated ✓', 'success');
+}
+
+document.getElementById('goal-slider').addEventListener('input', function() {
+ document.getElementById('goal-modal-display').textContent = parseInt(this.value).toLocaleString();
+});
+
// ─────────────────────────────────────────────
// PROFILE MODAL
// ─────────────────────────────────────────────
@@ -2104,7 +2179,7 @@ document.getElementById('profile-name-input').addEventListener('input', updatePr
document.getElementById('profile-avatar-input').addEventListener('input', updateProfilePreview);
document.addEventListener('keydown', e => {
- if (e.key === 'Escape') { closeProfileModal(); closeMenu(); }
+ if (e.key === 'Escape') { closeProfileModal(); closeGoalModal(); closeMenu(); }
});
let ptrStartY = 0;