From 51cea8b17cb6fa0bb547875f843208345d8f3693 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Laurent?= <francois.laurent@posteo.net>
Date: Sun, 29 May 2022 23:24:05 +0200
Subject: [PATCH] bugfix for empty labels file + no outline on player focus

---
 src/files.jl        | 3 ++-
 src/larvatagger.css | 3 +++
 src/models.jl       | 2 ++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/files.jl b/src/files.jl
index 022ea3e..3c89f43 100644
--- a/src/files.jl
+++ b/src/files.jl
@@ -172,10 +172,11 @@ function loadfile(path)
     file = Formats.load(path)
     data = isempty(file.run) ? file.timeseries : file.run
     # tracks
-    times = PlanarLarvae.times(data)
     if file isa Formats.FIMTrack
+        times = PlanarLarvae.times(data)
         tracks = [LarvaModel(track, times) for track in values(getrun(file))]
     else
+        times = PlanarLarvae.times(gettimeseries(file))
         tracks = [LarvaModel(id, ts, times) for (id, ts) in pairs(gettimeseries(file))]
     end
     # dataset
diff --git a/src/larvatagger.css b/src/larvatagger.css
index c4bbf26..d47a8a6 100644
--- a/src/larvatagger.css
+++ b/src/larvatagger.css
@@ -149,6 +149,9 @@ input[type=text]:disabled {
 .player button {
 	margin-left: 0.25rem;
 }
+.player input[type=range]:focus {
+	outline: none;
+}
 
 #tag-selector {
 	width: 1000px;
diff --git a/src/models.jl b/src/models.jl
index 1351c3d..77176a6 100644
--- a/src/models.jl
+++ b/src/models.jl
@@ -212,6 +212,7 @@ struct LarvaModel
 end
 
 function LarvaModel(id::LarvaID, timeseries::PlanarLarvae.TimeSeries{<:NamedTuple}, times::Vector{PlanarLarvae.Time})
+    @assert !isempty(times)
     alignedsteps = map(timeseries) do (t, _)
         findfirst(t′-> abs(t - t′) < TIME_PRECISION, times)
     end
@@ -221,6 +222,7 @@ function LarvaModel(id::LarvaID, timeseries::PlanarLarvae.TimeSeries{<:NamedTupl
 end
 
 function LarvaModel(track::Track, times::Vector{PlanarLarvae.Time})
+    @assert !isempty(times)
     alignedsteps = map(track.timestamps) do t
         findfirst(t′-> abs(t - t′) < TIME_PRECISION, times)
     end
-- 
GitLab