From 9fa898d5aa0c29b71d6eae84ded6ba2b073a867e Mon Sep 17 00:00:00 2001 From: ElementalAlchemist Date: Sun, 9 Oct 2022 21:00:46 -0500 Subject: [PATCH] Fix doing the time conversion before the data required for the time conversion is loaded --- thrimbletrimmer/scripts/edit.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/thrimbletrimmer/scripts/edit.js b/thrimbletrimmer/scripts/edit.js index 59d68f5..d969114 100644 --- a/thrimbletrimmer/scripts/edit.js +++ b/thrimbletrimmer/scripts/edit.js @@ -208,7 +208,11 @@ window.addEventListener("DOMContentLoaded", async (event) => { unhideIDs.push("video-info-thumbnail-custom-options"); } - document.getElementsByClassName("video-info-thumbnail-mode-options").classList.add("hidden"); + for (const optionElement of document.getElementsByClassName( + "video-info-thumbnail-mode-options" + )) { + optionElement.classList.add("hidden"); + } for (elemID of unhideIDs) { document.getElementById(elemID).classList.remove("hidden"); } @@ -235,6 +239,7 @@ window.addEventListener("DOMContentLoaded", async (event) => { const thumbnailTemplatesList = await thumbnailTemplatesListResponse.json(); for (const templateFileName of thumbnailTemplatesList) { const templateOption = document.createElement("option"); + // Thumbnails are fetched from restreamer with file extensions. The thumbnail name is the file name. const templateName = templateFileName.substring(0, templateFileName.lastIndexOf(".")); templateOption.innerText = templateName; templateOption.value = templateName; @@ -248,9 +253,11 @@ window.addEventListener("DOMContentLoaded", async (event) => { } document.getElementById("video-info-thumbnail-mode").value = videoInfo.thumbnail_mode; if (videoInfo.thumbnail_time) { - document.getElementById("video-info-thumbnail-time").value = videoHumanTimeFromWubloaderTime( - videoInfo.thumbnail_time - ); + document.getElementById("video").addEventListener("loadedmetadata", (_event) => { + document.getElementById("video-info-thumbnail-time").value = videoHumanTimeFromWubloaderTime( + videoInfo.thumbnail_time + ); + }); } document.getElementById("submit-button").addEventListener("click", (_event) => {