mirror of
https://gitlab.rlp.net/proj-wise2526-video2document/video2document.git
synced 2026-06-15 18:01:52 +02:00
Added try/catch handling and some comments
This commit is contained in:
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
const { contextBridge, ipcRenderer, webUtils } = require('electron')
|
const { contextBridge, ipcRenderer, webUtils } = require('electron')
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld("explorer", {
|
try {
|
||||||
|
contextBridge.exposeInMainWorld("explorer", {
|
||||||
onFileDrop: (file) => webUtils.getPathForFile(file)
|
onFileDrop: (file) => webUtils.getPathForFile(file)
|
||||||
})
|
})
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error in preload.js");
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,18 @@
|
|||||||
const dropzone = document.getElementById("uploadContainer");
|
const dropzone = document.getElementById("uploadContainer");
|
||||||
|
|
||||||
dropzone.addEventListener("dragover", (e) =>{
|
dropzone.addEventListener("dragover", (e) =>{
|
||||||
|
try {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error in renderer.js dragover listener function")
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//listener for when a file get dropped on the drag&drop field
|
||||||
dropzone.addEventListener("drop", (e) => {
|
dropzone.addEventListener("drop", (e) => {
|
||||||
|
try {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
const files = e.dataTransfer.files
|
const files = e.dataTransfer.files
|
||||||
@@ -18,5 +25,9 @@ dropzone.addEventListener("drop", (e) => {
|
|||||||
const files1 = e.dataTransfer.files;
|
const files1 = e.dataTransfer.files;
|
||||||
handleFiles(files1);
|
handleFiles(files1);
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error in renderer.js with the listerner for the drop function");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
+34
-11
@@ -1,37 +1,60 @@
|
|||||||
const uploadContainer = document.getElementById('uploadContainer');
|
try {
|
||||||
const fileInput = document.getElementById('videoUpload');
|
const uploadContainer = document.getElementById('uploadContainer');
|
||||||
const fileName = document.getElementById('fileName');
|
const fileInput = document.getElementById('videoUpload');
|
||||||
const manualBtn = document.getElementById('manualUploadBtn');
|
const fileName = document.getElementById('fileName');
|
||||||
const videoPreview = document.getElementById('videoPreview');
|
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', () => {
|
manualBtn.addEventListener('click', () => {
|
||||||
|
try {
|
||||||
fileInput.click();
|
fileInput.click();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error in manualBtn EventListener click");
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//listener for the file explorer search when something got selected
|
||||||
fileInput.addEventListener('change', () => {
|
fileInput.addEventListener('change', () => {
|
||||||
|
try {
|
||||||
handleFiles(fileInput.files);
|
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) {
|
function handleFiles(files) {
|
||||||
|
try {
|
||||||
if (files.length > 0) {
|
if (files.length > 0) {
|
||||||
const file = files[0];
|
const file = files[0];
|
||||||
if (file.type.startsWith('video/')) {
|
if (file.type.startsWith('video/')) {
|
||||||
fileInput.files = files;
|
fileInput.files = files;
|
||||||
fileName.textContent = `Chosen video: ${file.name}`;
|
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){
|
function updateProgressBar(bar, value){
|
||||||
|
try {
|
||||||
value = Math.round(value);
|
value = Math.round(value);
|
||||||
bar.querySelector(".progress_fill").style.width = `${value}%`;
|
bar.querySelector(".progress_fill").style.width = `${value}%`;
|
||||||
bar.querySelector(".progress_text").textContent = `${value}%`;
|
bar.querySelector(".progress_text").textContent = `${value}%`;
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error in scripts.js updateProgressBar function");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user