Added try/catch handling and some comments

This commit is contained in:
2025-11-11 16:02:07 +01:00
parent f4c45f8371
commit da3a8c7d8c
3 changed files with 78 additions and 39 deletions
+44 -21
View File
@@ -1,37 +1,60 @@
const uploadContainer = document.getElementById('uploadContainer');
const fileInput = document.getElementById('videoUpload');
const fileName = document.getElementById('fileName');
const manualBtn = document.getElementById('manualUploadBtn');
const videoPreview = document.getElementById('videoPreview');
try {
const uploadContainer = document.getElementById('uploadContainer');
const fileInput = document.getElementById('videoUpload');
const fileName = document.getElementById('fileName');
const manualBtn = document.getElementById('manualUploadBtn');
const videoPreview = document.getElementById('videoPreview');
} catch (error) {
console.log("Error in skript value setting section");
}
//listener for the file explorer search
manualBtn.addEventListener('click', () => {
fileInput.click();
try {
fileInput.click();
} catch (error) {
console.log("Error in manualBtn EventListener click");
}
});
//listener for the file explorer search when something got selected
fileInput.addEventListener('change', () => {
handleFiles(fileInput.files);
try {
handleFiles(fileInput.files);
} catch (error) {
console.log("Error in manualBtn EventListener change");
}
});
//function to display the file path in the drop down box
function handleFiles(files) {
if (files.length > 0) {
const file = files[0];
if (file.type.startsWith('video/')) {
fileInput.files = files;
fileName.textContent = `Chosen video: ${file.name}`;
try {
if (files.length > 0) {
const file = files[0];
if (file.type.startsWith('video/')) {
fileInput.files = files;
fileName.textContent = `Chosen video: ${file.name}`;
}
}
}
} catch (error) {
console.log("Error in script.js handleFiles function");
}
}
//function to regulate the progress on the progressbar
function updateProgressBar(bar, value){
value = Math.round(value);
bar.querySelector(".progress_fill").style.width = `${value}%`;
bar.querySelector(".progress_text").textContent = `${value}%`;
try {
value = Math.round(value);
bar.querySelector(".progress_fill").style.width = `${value}%`;
bar.querySelector(".progress_text").textContent = `${value}%`;
} catch (error) {
console.log("Error in scripts.js updateProgressBar function");
}
}