@@ -5121,7 +5216,7 @@
Sort
alertEl.textContent = `${res.message || 'Run imported!'}`;
alertEl.style.display = 'block';
- setTimeout(() => { window.location.reload(); }, 1500);
+ setTimeout(() => { window.location.href = `/?open=${res.runId}`; }, 1500);
} catch (err) {
confirmBtn.disabled = false;
@@ -6447,6 +6542,8 @@ ${c.name}
.then(data => {
document.getElementById('goalLoading').style.display = 'none';
+ let dynamicBtnText = 'LOG YOUR RUN';
+
if (data.error || data.goal_km === null) {
document.getElementById('goalSetup').style.display = 'block';
document.getElementById('goalProgressContainer').style.display = 'none';
@@ -6455,6 +6552,12 @@ ${c.name}
document.getElementById('goalInput').value = '';
}
} else {
+ // Check dynamic context for button
+ let remaining = data.goal_km - data.current_km;
+ if (remaining > 0 && remaining <= 5.5) {
+ dynamicBtnText = `${remaining.toFixed(1)} km to your weekly goal — log it!`;
+ }
+
document.getElementById('goalSetup').style.display = 'none';
document.getElementById('goalProgressContainer').style.display = 'block';
document.getElementById('editGoalBtn').style.display = 'block';
@@ -6490,6 +6593,17 @@ ${c.name}
percentEl.style.color = 'var(--accent)';
}
}
+
+ if (dynamicBtnText === 'LOG YOUR RUN') {
+ const hour = new Date().getHours();
+ const hasRunTodayStr = "{{ 'true' if runs and (runs[0]['date']|string).startswith(today) else 'false' }}";
+ if (hour >= 18 && hasRunTodayStr === 'false') {
+ dynamicBtnText = "Get today's run in";
+ }
+ }
+ const pBtnText = document.getElementById('primaryLogBtnText');
+ if (pBtnText) pBtnText.innerText = dynamicBtnText;
+
})
.catch(err => {
console.error('Goal load error', err);
@@ -7388,6 +7502,77 @@ Monthly Goal<
console.error("Error saving goal", err);
}
}
+
+ // Post-Log Navigation Logic
+ document.addEventListener('DOMContentLoaded', () => {
+ const params = new URLSearchParams(window.location.search);
+ const openRunId = params.get('open');
+ if (openRunId) {
+ switchTab('runs');
+ setTimeout(() => {
+ const cardDetails = document.getElementById(`runCardDetails-${openRunId}`);
+ if (cardDetails) {
+ setRunsView('cards');
+ const cardParent = cardDetails.closest('.run-card-modern') || cardDetails.closest('.run-card');
+ if (cardParent) {
+ cardParent.scrollIntoView({ behavior: 'smooth', block: 'center' });
+ cardParent.style.transition = 'box-shadow 0.3s ease, border 0.3s ease';
+ cardParent.style.boxShadow = '0 0 20px rgba(0, 242, 255, 0.4)';
+ cardParent.style.border = '1px solid rgba(0, 242, 255, 0.8)';
+ setTimeout(() => {
+ cardParent.style.boxShadow = '';
+ cardParent.style.border = '';
+ }, 3000);
+ }
+ if (!cardDetails.classList.contains('show')) {
+ toggleRunCard(openRunId);
+ }
+ } else {
+ const listRow = document.getElementById(`insight-${openRunId}`);
+ if (listRow) {
+ setRunsView('list');
+ const rowParent = listRow.previousElementSibling;
+ if (rowParent) {
+ rowParent.scrollIntoView({ behavior: 'smooth', block: 'center' });
+ rowParent.style.transition = 'background-color 0.3s ease';
+ rowParent.style.backgroundColor = 'rgba(0, 242, 255, 0.2)';
+ setTimeout(() => {
+ rowParent.style.backgroundColor = '';
+ }, 3000);
+ const bsCollapse = new bootstrap.Collapse(listRow) || bootstrap.Collapse.getInstance(listRow);
+ bsCollapse.show();
+ }
+ }
+ }
+ }, 500);
+
+ const newUrl = window.location.pathname;
+ window.history.replaceState({}, document.title, newUrl);
+ }
+
+ // Ripple Effect
+ const pBtn = document.getElementById('primaryLogBtn');
+ if (pBtn) {
+ pBtn.addEventListener('mousedown', function(e) {
+ const btn = e.currentTarget;
+ const circle = document.createElement('span');
+ const diameter = Math.max(btn.clientWidth, btn.clientHeight);
+ const radius = diameter / 2;
+
+ const rect = btn.getBoundingClientRect();
+ circle.style.width = circle.style.height = `${diameter}px`;
+ circle.style.left = `${e.clientX - rect.left - radius}px`;
+ circle.style.top = `${e.clientY - rect.top - radius}px`;
+ circle.classList.add('ripple');
+
+ const existingRipple = btn.querySelector('.ripple');
+ if (existingRipple) {
+ existingRipple.remove();
+ }
+ btn.appendChild(circle);
+ });
+ }
+ });