From 1a681eb2b8d49f652fe61e06d2579fb089c8a177 Mon Sep 17 00:00:00 2001 From: "eric.minning" Date: Wed, 12 Nov 2025 20:14:56 +0100 Subject: [PATCH 1/2] Improved error log and implemented a variable and function for file path storage --- electron/main/preload.js | 10 +++++----- electron/main/renderer.js | 5 ++++- electron/main/script.js | 34 +++++++++++++++++++++++++++++----- 3 files changed, 38 insertions(+), 11 deletions(-) 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 From 4a91f03289ac118bb0b948f7b62fd8eded79b850 Mon Sep 17 00:00:00 2001 From: "eric.minning" Date: Fri, 14 Nov 2025 18:32:41 +0100 Subject: [PATCH 2/2] Implemented a dropdown field for the languages as well as functions and a file to easily implement other languages. --- electron/main/index.html | 12 +++-- electron/main/languages.js | 36 ++++++++++++++ electron/main/preload.js | 4 ++ electron/main/renderer.js | 23 ++++++--- electron/main/script.js | 99 ++++++++++++++++++-------------------- 5 files changed, 108 insertions(+), 66 deletions(-) create mode 100644 electron/main/languages.js diff --git a/electron/main/index.html b/electron/main/index.html index f88b4c2..a8430af 100644 --- a/electron/main/index.html +++ b/electron/main/index.html @@ -10,9 +10,10 @@
- - - + +

Video to document

@@ -46,7 +47,8 @@
- - + + + \ No newline at end of file diff --git a/electron/main/languages.js b/electron/main/languages.js new file mode 100644 index 0000000..6262dc0 --- /dev/null +++ b/electron/main/languages.js @@ -0,0 +1,36 @@ +var languageOptions = { + "eng":{ + "title": "Video to document", + "h1": "Video to document", + "p1": "Drag and drop video file", + "fileName": "No video chosen", + "manualUploadBtn": "Search video", + "checkbox_group": "Choose prefered document style:", + "label_format": "Meeting report", + "label_summary": "Summary with timestamps", + "submitButton": "Submit" + }, + "de":{ + "title": "Video zu Dokument", + "h1": "Video zu Dokument", + "p1": "Video per Drag & Drop ablegen", + "fileName": "Kein Video ausgewaehlt", + "manualUploadBtn": "Video suchen", + "checkbox_group": "Bevorzugte Dokumentvarianten:", + "label_format": "Meeting Bericht", + "label_summary": "Zusammenfassung mit Zeitstempeln", + "submitButton": "Absenden" + }, + "in":{ + "title": "दस्तावेज़ के लिए वीडियो", + "h1": "दस्तावेज़ के लिए वीडियो", + "p1": "वीडियो फ़ाइल खींचें और छोड़ें", + "fileName": "कोई वीडियो नहीं चुना गया", + "manualUploadBtn": "वीडियो खोजें", + "checkbox_group": "पसंदीदा दस्तावेज़ शैली चुनें:", + "label_format": "बैठक रिपोर्ट", + "label_summary": "टाइमस्टैम्प के साथ सारांश", + "submitButton": "जमा करना" + } + +}; \ No newline at end of file diff --git a/electron/main/preload.js b/electron/main/preload.js index 2ea0ca5..4cc8eb6 100644 --- a/electron/main/preload.js +++ b/electron/main/preload.js @@ -7,6 +7,10 @@ try { contextBridge.exposeInMainWorld("extractor", { extract: (file) => ipcRenderer.send("extract", file) }) + contextBridge.exposeInMainWorld("electronAPI", { + getFilePath: (file) => {return webUtils.getPathForFile(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 4175191..2291f64 100644 --- a/electron/main/renderer.js +++ b/electron/main/renderer.js @@ -4,8 +4,7 @@ uploadContainer.addEventListener("dragover", (e) =>{ e.stopPropagation(); e.preventDefault(); } catch (error) { - console.log("Error in renderer.js dragover listener function"); - console.log(error); + console.log("Error in renderer.js dragover listener function") } }); @@ -22,13 +21,21 @@ 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); - } - - -}) \ No newline at end of file + } +}) + + + window.addEventListener('load', (e) => { + console.log("test"); + loadLanguageOptions(); +}); + +language_option.addEventListener('change', (e)=>{ + const select = document.getElementById('language_option'); + console.log(select.value); + changeLanguage(select.value); +}); diff --git a/electron/main/script.js b/electron/main/script.js index 8935a38..c66c976 100644 --- a/electron/main/script.js +++ b/electron/main/script.js @@ -1,11 +1,9 @@ -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); } }); @@ -24,16 +22,16 @@ function checkBoxes() { if(isChecked){ //Code to submit the video - if(curSelecPath.endsWith(".mp4") || holdy.endsWith(".mov") || holdy.endsWith(".avi") || holdy.endsWith( ".mkv")){ - window.extractor.extract({inputVideoPath: curSelecPath, outputType:"wav"}) + var pathTest = window.electronAPI.getFilePath(videoUpload.files[0]); + if(pathTest.endsWith(".mp4") || holdy.endsWith(".mov") || holdy.endsWith(".avi") || holdy.endsWith( ".mkv")){ + window.extractor.extract({inputVideoPath: pathTest, outputType:"wav"}) } } else { //language only english at the moment alert('Please select at least one document type.'); } } catch (error) { - console.log("Error in script.js checkBoxes function"); - console.log(error); + console.log(error) } // mapFunctions.get("extraction-video-to-audio").function({inputVideoPath:"./a.mp4", outputType:"wav"}) @@ -42,58 +40,31 @@ 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'; - document.getElementById('p1').textContent = 'Drag and drop video file'; - document.getElementById('fileName').textContent = 'No video chosen'; - document.getElementById('manualUploadBtn').textContent = 'Search video'; - document.getElementById('checkbox_group').textContent = 'Choose prefered document style:'; - document.getElementById('label_format').textContent = 'Meeting report'; - document.getElementById('label_summary').textContent = 'Summary with timestamps'; - document.getElementById('submitButton').textContent = 'Submit'; - } else if (language === 'de') { - document.getElementById('title').textContent = 'Video zu Dokument'; - document.getElementById('h1').textContent = 'Video zu Dokument'; - document.getElementById('p1').textContent = 'Video per Drag & Drop ablegen'; - document.getElementById('fileName').textContent = 'Kein Video ausgewaehlt'; - document.getElementById('manualUploadBtn').textContent = 'Video suchen'; - document.getElementById('checkbox_group').textContent = 'Bevorzugte Dokumentvarianten:'; - document.getElementById('label_format').textContent = 'Meeting Bericht'; - document.getElementById('label_summary').textContent = 'Zusammenfassung mit Zeitstempeln'; - document.getElementById('submitButton').textContent = 'Absenden'; - } else if(language == "in") { - document.getElementById('title').textContent = 'दस्तावेज़ के लिए वीडियो'; - document.getElementById('h1').textContent = 'दस्तावेज़ के लिए वीडियो'; - document.getElementById('p1').textContent = 'वीडियो फ़ाइल खींचें और छोड़ें'; - document.getElementById('fileName').textContent = 'कोई वीडियो नहीं चुना गया'; - document.getElementById('manualUploadBtn').textContent = 'वीडियो खोजें'; - document.getElementById('checkbox_group').textContent = 'पसंदीदा दस्तावेज़ शैली चुनें:'; - document.getElementById('label_format').textContent = 'बैठक रिपोर्ट'; - document.getElementById('label_summary').textContent = 'टाइमस्टैम्प के साथ सारांश'; - document.getElementById('submitButton').textContent = 'जमा करना'; - } + document.getElementById('title').textContent = languageOptions[language].title; + document.getElementById('h1').textContent = languageOptions[language].h1; + document.getElementById('p1').textContent = languageOptions[language].p1; + document.getElementById('fileName').textContent = languageOptions[language].fileName; + document.getElementById('manualUploadBtn').textContent = languageOptions[language].manualUploadBtn; + document.getElementById('checkbox_group').textContent = languageOptions[language].checkbox_group; + document.getElementById('label_format').textContent = languageOptions[language].label_format; + document.getElementById('label_summary').textContent = languageOptions[language].label_summary; + document.getElementById('submitButton').textContent = languageOptions[language].submitButton; } catch (error) { - console.log("Error in script.js changeLanguage function"); console.log(error); } - + } - //listener for the file explorer search when something got selected videoUpload.addEventListener('change', () => { try { handleFiles(videoUpload.files); } catch (error) { console.log("Error in manualBtn EventListener change"); - console.log(error); } }); - - //function to display the file path in the drop down box function handleFiles(files) { try { @@ -102,16 +73,10 @@ 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); } } @@ -124,16 +89,44 @@ 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){ +//function to load ai options to the drop down list +function loadAiOptions(options){ try { - curSelecPath = value + ""; + var menu = document.getElementById('ai_type'); + for(i = 0; i < options.length; i++){ + var opty = options[i]; + var namey = "option" + i; + var choice = document.createElement(namey); + choice.textContent = "t"; + choice.value = i; + menu.appendChild(choice); + } } catch (error) { - console.log("Error in script.js setCurrentPathVariable"); + console.log("Error in script.js loadAiOptions function"); + console.log(error); + } +} + +//function to load language options to the drop down list +function loadLanguageOptions(){ + try { + var menu = document.getElementById('language_option'); + var object_holdy; + var choice ; + object_holdy = Object.keys(languageOptions); + for(i = 0; i < object_holdy.length; i++){ + choice = document.createElement('option'); + choice.textContent = object_holdy[i]; + choice.value = object_holdy[i]; + menu.appendChild(choice); + } + + } catch (error) { + console.log("Error in script.js loadLanguageOptions function"); console.log(error); } } \ No newline at end of file