From 21a8489df989f386158bb2a4a3a1030bd75464cf Mon Sep 17 00:00:00 2001 From: N0H3dy Date: Wed, 8 Mar 2023 02:25:36 -0500 Subject: [PATCH] Added the loading bar for the transcript --- .../templates/Frontend/video-editing.html | 19 +++---- static/css/video-editing.css | 29 +++++++++++ static/js/background.js | 0 static/js/upload-video.js | 51 ++++++++++++++++++- static/js/video-editing.js | 4 +- 5 files changed, 90 insertions(+), 13 deletions(-) delete mode 100644 static/js/background.js diff --git a/Frontend/templates/Frontend/video-editing.html b/Frontend/templates/Frontend/video-editing.html index 291b242..965b141 100644 --- a/Frontend/templates/Frontend/video-editing.html +++ b/Frontend/templates/Frontend/video-editing.html @@ -23,6 +23,14 @@
+ +
+
+
+
+
+ +
@@ -31,12 +39,7 @@ @@ -46,11 +49,10 @@

- + -
+
@@ -66,7 +68,6 @@ -
diff --git a/static/css/video-editing.css b/static/css/video-editing.css index d1680b9..be7b903 100644 --- a/static/css/video-editing.css +++ b/static/css/video-editing.css @@ -174,6 +174,35 @@ nav ul li a{ } + +#loading-container{ + width: 70%; + padding: 50px 0; + background: #1d2026; + box-shadow: 0 0 30px rgba(0,0,0, 0.8); + border-radius: 5px; + text-align: center; + z-index: 1; + display: none; + +} + +.bar { + background: #b6b6b6; + width: 90%; + height: 50px; + margin: 10px auto; + border-radius: 50px; + overflow: hidden; +} + +.fill { + height: 100%; + width: 1%; + background: linear-gradient(45deg, #008998, #00d199); +} + + #editor-container { display: flex; position: absolute; diff --git a/static/js/background.js b/static/js/background.js deleted file mode 100644 index e69de29..0000000 diff --git a/static/js/upload-video.js b/static/js/upload-video.js index c65d825..b7dc994 100644 --- a/static/js/upload-video.js +++ b/static/js/upload-video.js @@ -1,3 +1,6 @@ +console.log("start of upload.js"); + + const form = document.querySelector("form"), fileInput = document.querySelector(".file-input"), progressArea = document.querySelector(".progress-area"), @@ -70,7 +73,7 @@ function uploadFile(file){ xhr.addEventListener("load", doneHandler); - // Define a POST request to uploads + // Define bar POST request to uploads xhr.open("POST", "/uploads/"); @@ -90,5 +93,49 @@ function uploadFile(file){ // Finally, hide the upload screen - document.getElementById("wrapper").style.visibility = "hidden"; + document.getElementById("wrapper").style.display = "none"; + + // If the upload feild is gone show the loading bar + + if(document.getElementById("wrapper").style.display == "none"){ + + let container = document.getElementById("loading-container"); + let fill = document.querySelector(".fill"); + let transcript = document.querySelector(".transcript-container").innerHTML; + console.log(transcript); + + container.style.display = "block"; + const video = document.getElementById('video'); + let video_len; + + // Check if video has been loaded and grab the length of the video + + video.addEventListener('loadedmetadata', () => { + video_len = video.duration; + console.log(video_len); + }); + + // Loop through the video length + + var bar = 0; + var run = setInterval(frames,2); + function frames(){ + bar++; + if (fill.style.width.substring(0,3) == "100"){ + clearInterval(run); + container.style.display = "none"; + }else{ + fill.style.width = bar/video_len + "%"; + } + + if (document.querySelector(".transcript-container").innerHTML != transcript){ + fill.style.width = "100%"; + } + } + + } + + } + + diff --git a/static/js/video-editing.js b/static/js/video-editing.js index 3af8ca7..694f754 100644 --- a/static/js/video-editing.js +++ b/static/js/video-editing.js @@ -1,4 +1,5 @@ -console.log("last line test case"); +console.log("start of video-editing.js"); + let transcriptArea = document.getElementById("transcript"); let transcriptHTML = ` `; @@ -43,7 +44,6 @@ function processData(data) { paragraph += ` ${word}`; } else { - line += ` ${word}`; paragraph += ` ${word}`; }