Unnamed imported tracks (FIT, ...) take the file's name, backfilled once for earlier imports; split and best-effort times with seconds
CI / check (push) Successful in 18s
CI / deploy (push) Successful in 17s

This commit is contained in:
randy committed 2026-11-17 23:37:41 +01:00
1 parent 21c5c2f21b
commit d87b8b8f80
5 files changed
+30 -11

No files matched your search

+9 -2
View File
@@ -371,7 +371,7 @@ function statsTables(profile, bounds, laps, ride) {
const rows = segmentStats(profile, bounds).map((s, i) => {
const cells = [laps ? `${i + 1}` : km(s.to), ...(laps ? [km(s.meters)] : [])];
if (hasTime) cells.push(s.secs ? formatDuration(s.secs) : "", s.secs ? pace(s.secs, s.meters) : "");
if (hasTime) cells.push(s.secs ? formatClock(s.secs) : "", s.secs ? pace(s.secs, s.meters) : "");
cells.push(`↑ ${Math.round(s.gain)} m`, `↓ ${Math.round(s.loss)} m`);
if (hasHr) cells.push(s.hr ? `${Math.round(s.hr)} bpm` : "");
if (hasPower) cells.push(s.power ? `${Math.round(s.power)} W` : "");
@@ -385,7 +385,7 @@ function statsTables(profile, bounds, laps, ride) {
if (hasTime) {
BEST_DISTANCES_KM.filter((km) => km * 1000 <= total).forEach((km) => {
const secs = fastest(timed, km * 1000);
if (secs) best.push([`${km === 21.0975 ? "Half marathon" : km === 42.195 ? "Marathon" : `${km} km`}`, `${formatDuration(secs)} · ${pace(secs, km * 1000)}`]);
if (secs) best.push([`${km === 21.0975 ? "Half marathon" : km === 42.195 ? "Marathon" : `${km} km`}`, `${formatClock(secs)} · ${pace(secs, km * 1000)}`]);
});
}
if (hasPower) {
@@ -551,6 +551,13 @@ function formatDuration(totalSeconds) {
return hours > 0 ? `${hours}h ${minutes}m` : `${minutes}m`;
}
// 4:32, 1:02:05 — with seconds, for splits and best efforts.
function formatClock(totalSeconds) {
const s = Math.round(totalSeconds);
const mmss = `${String(Math.floor((s % 3600) / 60)).padStart(s >= 3600 ? 2 : 1, "0")}:${String(s % 60).padStart(2, "0")}`;
return s >= 3600 ? `${Math.floor(s / 3600)}:${mmss}` : mmss;
}
function escapeHtml(text) {
const div = document.createElement("div");
div.textContent = text;