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')
|
||||
|
||||
contextBridge.exposeInMainWorld("explorer", {
|
||||
onFileDrop: (file) => webUtils.getPathForFile(file)
|
||||
})
|
||||
try {
|
||||
contextBridge.exposeInMainWorld("explorer", {
|
||||
onFileDrop: (file) => webUtils.getPathForFile(file)
|
||||
})
|
||||
} catch (error) {
|
||||
console.log("Error in preload.js");
|
||||
}
|
||||
|
||||
|
||||
+26
-15
@@ -2,21 +2,32 @@
|
||||
const dropzone = document.getElementById("uploadContainer");
|
||||
|
||||
dropzone.addEventListener("dragover", (e) =>{
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
dropzone.addEventListener("drop", (e) => {
|
||||
e.stopPropagation()
|
||||
e.preventDefault()
|
||||
const files = e.dataTransfer.files
|
||||
const filePath = window.explorer.onFileDrop(files[0])
|
||||
var holdy = filePath + "";
|
||||
if(holdy.endsWith(".mp4")){
|
||||
console.log(filePath)
|
||||
|
||||
const files1 = e.dataTransfer.files;
|
||||
handleFiles(files1);
|
||||
try {
|
||||
e.stopPropagation();
|
||||
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) => {
|
||||
try {
|
||||
e.stopPropagation()
|
||||
e.preventDefault()
|
||||
const files = e.dataTransfer.files
|
||||
const filePath = window.explorer.onFileDrop(files[0])
|
||||
var holdy = filePath + "";
|
||||
if(holdy.endsWith(".mp4")){
|
||||
console.log(filePath)
|
||||
|
||||
const files1 = e.dataTransfer.files;
|
||||
handleFiles(files1);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("Error in renderer.js with the listerner for the drop function");
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
+44
-21
@@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user