From 5afa541b303d9a650b5fd5a46cd4dd7b839d6085 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 17 Mar 2021 14:21:02 +0100 Subject: [PATCH] Added formatted laptime ref #92 --- src/components/scans/ScansOverview.svelte | 67 ++++++++++------------- 1 file changed, 28 insertions(+), 39 deletions(-) diff --git a/src/components/scans/ScansOverview.svelte b/src/components/scans/ScansOverview.svelte index a082e79a..c8f7b334 100644 --- a/src/components/scans/ScansOverview.svelte +++ b/src/components/scans/ScansOverview.svelte @@ -21,6 +21,11 @@ } return id.toString() === searchvalue; } + function format_laptime(laptime){ + if(laptime < 60){return laptime.toString} + if(laptime < 3600){return `${Math.floor(laptime / 60)}min ${laptime - (Math.floor(laptime / 60)*60)}s`} + return `${Math.floor(laptime / 3600)}h ${laptime - (Math.floor(laptime / 3600)*3600)}min ${laptime - (Math.floor(laptime / 3600)*3600) - (Math.floor(laptime / 60)*60)}` + } {#if store.state.jwtinfo.userdetails.permissions.includes('SCAN:GET')} @@ -54,23 +59,18 @@ - Distance + Distance (+Track) + + + Laptime Status - - Track - - - Station - {$_('action')} @@ -110,8 +110,25 @@ {#if scan.distance < 1000} {scan.distance}m {:else}{scan.distance / 1000}km{/if} + {#if scan.track} + {scan.track.name} + + {/if} + + {#if scan.laptime} +
+ {format_laptime(scan.laptime)} +
+ {:else} +
+ Scan with fixed distance +
+ {/if} +
{#if scan.valid} @@ -123,34 +140,6 @@ {/if}
- - {#if scan.track} -
- {scan.track.name} - -
- {:else} -
- Scan with fixed distance -
- {/if} - - - {#if scan.station} -
- {scan.station.description || '#' + scan.station.id} - -
- {:else} -
- Scan with fixed distance -
- {/if} - {#if active_deletes[scan.id] === true}