From 1909f724458e578614927ab2233e248c0f1b0126 Mon Sep 17 00:00:00 2001 From: Nick Walker Date: Wed, 18 Sep 2024 23:24:51 -0700 Subject: [PATCH] Fix bugs in results table Don't truncate the tens digit for durations/times with 2 hours digits Don't drop finish time column when displaying on small screens --- js/ResultsTable.js | 6 +++--- js/common.js | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/js/ResultsTable.js b/js/ResultsTable.js index 5eae655..1b8f028 100644 --- a/js/ResultsTable.js +++ b/js/ResultsTable.js @@ -95,16 +95,16 @@ export class ResultsTable extends HTMLElement { sorter: "number", formatter: cell => formatDuration(cell.getValue(), true), resizable: false, - responsive: index + responsive: index + 2 } }) let summaryColumns = [ { - title: "Laps", field: "nLaps", sorter: "number", resizable: false + title: "Laps", field: "nLaps", sorter: "number", resizable: false, index: 1 }] if (useFinishTimes) { summaryColumns = [{ - title: "Finish Time", field: "finishTime", sorter: "number", formatter: cell => formatDuration(cell.getValue(), true), resizable: false + title: "Finish Time", field: "finishTime", sorter: "number", formatter: cell => formatDuration(cell.getValue(), true), resizable: false, index: 0 }, ...summaryColumns] } diff --git a/js/common.js b/js/common.js index e4021f1..17eaaa2 100644 --- a/js/common.js +++ b/js/common.js @@ -17,7 +17,7 @@ export function formatDuration(seconds, includeHours = true, includeMilliseconds } let date = new Date(0); - + const hours = Math.floor(seconds / 3600) let milliseconds = (seconds % 1.0) * 1000 if (milliseconds > 0 && !includeMilliseconds) { // If we're not showing the milliseconds, have to round up @@ -34,7 +34,11 @@ export function formatDuration(seconds, includeHours = true, includeMilliseconds let end = 19 if (includeHours) { - start -= 2 + if (hours >= 10) { + start -= 3 + } else { + start -= 2 + } } if (includeMilliseconds) { end += 2