diff --git a/electron/main/preload.js b/electron/main/preload.js index 5a7a5d7..2ea0ca5 100644 --- a/electron/main/preload.js +++ b/electron/main/preload.js @@ -1,12 +1,12 @@ - - const { contextBridge, ipcRenderer, webUtils } = require('electron') try { contextBridge.exposeInMainWorld("explorer", { onFileDrop: (file) => webUtils.getPathForFile(file) - }) + }) + contextBridge.exposeInMainWorld("extractor", { + extract: (file) => ipcRenderer.send("extract", file) + }) } catch (error) { console.log("Error in preload.js"); -} - +} \ No newline at end of file diff --git a/electron/main/renderer.js b/electron/main/renderer.js index ad684ef..4175191 100644 --- a/electron/main/renderer.js +++ b/electron/main/renderer.js @@ -4,7 +4,8 @@ uploadContainer.addEventListener("dragover", (e) =>{ e.stopPropagation(); e.preventDefault(); } catch (error) { - console.log("Error in renderer.js dragover listener function") + console.log("Error in renderer.js dragover listener function"); + console.log(error); } }); @@ -21,10 +22,12 @@ uploadContainer.addEventListener("drop", (e) => { console.log(filePath) const files1 = e.dataTransfer.files; + setCurrentPathVariable(filePath); handleFiles(files1); } } catch (error) { console.log("Error in renderer.js with the listerner for the drop function"); + console.log(error); } diff --git a/electron/main/script.js b/electron/main/script.js index ab94700..8935a38 100644 --- a/electron/main/script.js +++ b/electron/main/script.js @@ -1,10 +1,11 @@ - +var curSelecPath = ""; //listener for the file explorer search manualUploadBtn.addEventListener('click', () => { try { videoUpload.click(); } catch (error) { console.log("Error in manualBtn EventListener click"); + console.log(error); } }); @@ -23,16 +24,16 @@ function checkBoxes() { if(isChecked){ //Code to submit the video - var pathTest = fileName.textContent + ""; - if(pathTest.endsWith(".mp4") || holdy.endsWith(".mov") || holdy.endsWith(".avi") || holdy.endsWith( ".mkv")){ - mapFunctions.get("extraction-video-to-audio").function({inputVideoPath: pathTest, outputType:"wav"}); + if(curSelecPath.endsWith(".mp4") || holdy.endsWith(".mov") || holdy.endsWith(".avi") || holdy.endsWith( ".mkv")){ + window.extractor.extract({inputVideoPath: curSelecPath, outputType:"wav"}) } } else { //language only english at the moment alert('Please select at least one document type.'); } } catch (error) { - console.log("Error") + console.log("Error in script.js checkBoxes function"); + console.log(error); } // mapFunctions.get("extraction-video-to-audio").function({inputVideoPath:"./a.mp4", outputType:"wav"}) @@ -40,6 +41,7 @@ function checkBoxes() { //language changing feature function changeLanguage(language) { + try { if (language === 'en') { document.getElementById('title').textContent = 'Video to document'; document.getElementById('h1').textContent = 'Video to document'; @@ -71,6 +73,11 @@ function changeLanguage(language) { document.getElementById('label_summary').textContent = 'टाइमस्टैम्प के साथ सारांश'; document.getElementById('submitButton').textContent = 'जमा करना'; } + } catch (error) { + console.log("Error in script.js changeLanguage function"); + console.log(error); + } + } @@ -80,6 +87,7 @@ videoUpload.addEventListener('change', () => { handleFiles(videoUpload.files); } catch (error) { console.log("Error in manualBtn EventListener change"); + console.log(error); } }); @@ -94,10 +102,16 @@ function handleFiles(files) { if (file.type.startsWith('video/')) { videoUpload.files = files; fileName.textContent = `Chosen video: ${file.name}`; + setCurrentPathVariable(files[0]) + }else{ + setCurrentPathVariable(""); } + }else{ + setCurrentPathVariable(""); } } catch (error) { console.log("Error in script.js handleFiles function"); + console.log(error); } } @@ -110,6 +124,16 @@ function updateProgressBar(bar, value){ bar.querySelector(".progress_text").textContent = `${value}%`; } catch (error) { console.log("Error in scripts.js updateProgressBar function"); + console.log(error); } +} + +function setCurrentPathVariable(value){ + try { + curSelecPath = value + ""; + } catch (error) { + console.log("Error in script.js setCurrentPathVariable"); + console.log(error); + } } \ No newline at end of file