From 24e410f81a6ee4973415a9c9d3ac3e709bad4942 Mon Sep 17 00:00:00 2001 From: Sundog Date: Tue, 3 Sep 2024 12:09:42 -0400 Subject: [PATCH] more refactoring --- layout.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/layout.html b/layout.html index facc34e..ffe5275 100644 --- a/layout.html +++ b/layout.html @@ -399,12 +399,17 @@ }); } + const secs_to_human_duration = (secs) => { + // date and time munging using substring? it's more likely than you think + return new Date(secs * 1000).toISOString().substring(11, 19); + } + const populate_media_library = (rows) => { const media_library_target = document.querySelector("#media_library_contents"); media_library_target.innerHTML = ""; rows.forEach((row) => { - const duration = new Date(row['duration_secs'] * 1000).toISOString().substring(11, 19); + const duration = secs_to_human_duration(row['duration_secs']); const template = document.getElementById("media_item_template"); const template_clone = template.content.firstElementChild.cloneNode(true); template_clone.querySelector(".media_item_title").innerHTML = row['title']; @@ -468,7 +473,7 @@ const current_timecode = document.getElementById("media_item_preview").currentTime; const template = document.getElementById("media_item_edl_insert_listitem"); const template_clone = template.content.cloneNode(true); - const formatted_timestamp = new Date(current_timecode * 1000).toISOString().substring(11, 19); + const formatted_timestamp = secs_to_human_duration(current_timecode); template_clone.querySelector('input[name="media_item_edl_insert"]').value = formatted_timestamp; template_clone.firstElementChild.setAttribute('data-timestamp', current_timecode); const target = document.querySelector("#media_item_edl_outpoint_listitem");