Skip to content

Commit

Permalink
Fix bugs in results table
Browse files Browse the repository at this point in the history
Don't truncate the tens digit for durations/times with 2 hours digits
Don't drop finish time column when displaying on small screens
  • Loading branch information
nickswalker committed Sep 19, 2024
1 parent 4e9adf4 commit 1909f72
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions js/ResultsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}

Expand Down
8 changes: 6 additions & 2 deletions js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 1909f72

Please sign in to comment.