mirror of
https://gitlab.rlp.net/proj-wise2526-video2document/video2document.git
synced 2026-06-15 18:01:52 +02:00
149 lines
4.4 KiB
JavaScript
149 lines
4.4 KiB
JavaScript
//listener for the file explorer search
|
|
manualUploadBtn.addEventListener('click', () => {
|
|
try {
|
|
videoUpload.click();
|
|
} catch (error) {
|
|
console.log("Error in manualBtn EventListener click");
|
|
}
|
|
|
|
});
|
|
|
|
//function to check if one checkbox is at least klicked
|
|
function checkBoxes() {
|
|
try {
|
|
const checkboxes = document.querySelectorAll('input[name="docFormat"]');
|
|
let isChecked = false;
|
|
|
|
checkboxes.forEach(function(checkbox){
|
|
if(checkbox.checked){
|
|
isChecked = true;
|
|
}
|
|
});
|
|
|
|
if(isChecked){
|
|
//Code to submit the video
|
|
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)
|
|
}
|
|
|
|
// mapFunctions.get("extraction-video-to-audio").function({inputVideoPath:"./a.mp4", outputType:"wav"})
|
|
}
|
|
|
|
//language changing feature
|
|
function changeLanguage(language) {
|
|
try {
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
//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");
|
|
}
|
|
|
|
});
|
|
|
|
//function to display the file path in the drop down box
|
|
function handleFiles(files) {
|
|
try {
|
|
if (files.length > 0) {
|
|
const file = files[0];
|
|
if (file.type.startsWith('video/')) {
|
|
videoUpload.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){
|
|
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");
|
|
}
|
|
|
|
}
|
|
|
|
//function to load ai options to the drop down list
|
|
function loadAiOptions(options){
|
|
try {
|
|
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 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);
|
|
}
|
|
}
|
|
|
|
function activateSubmitBtn(hasFile){
|
|
submitButton.disabled = !hasFile;
|
|
}
|
|
|
|
videoUpload.addEventListener("change", () => {
|
|
activateSubmitBtn(videoUpload.files.length > 0);
|
|
});
|
|
|
|
uploadContainer.addEventListener("drop", (e) => {
|
|
e.preventDefault();
|
|
const file = e.dataTransfer.files[0];
|
|
|
|
if(file){
|
|
activateSubmitBtn(true);
|
|
}
|
|
}); |