From ce3e98e240f8c86478f8541ae2b82e5207d4c0f4 Mon Sep 17 00:00:00 2001 From: ge64qev Date: Tue, 14 May 2024 09:13:39 +0200 Subject: [PATCH] Deleted Console logs and adjusted some comments. --- src/main/resources/static/js/fileInput.js | 3 --- src/main/resources/static/js/merge.js | 5 +++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/resources/static/js/fileInput.js b/src/main/resources/static/js/fileInput.js index cf1b9896..f3ae7504 100644 --- a/src/main/resources/static/js/fileInput.js +++ b/src/main/resources/static/js/fileInput.js @@ -109,10 +109,7 @@ function setupFileInput(chooser) { // Listen for event of file being removed and then filter it out of the allFiles array document.addEventListener("fileRemoved", function (e) { const fileId = e.detail; - console.log('File to be removed:', fileId); // Log the uniqueId of the file to be removed - console.log('All files before removal:', allFiles); // Log all files before removal allFiles = allFiles.filter(fileObj => fileObj.uniqueId !== fileId); // Remove the file from the allFiles array using the unique identifier - console.log('All files after removal:', allFiles); // Log all files after removal // Dispatch a custom event with the allFiles array var filesUpdated = new CustomEvent("filesUpdated", { detail: allFiles }); document.dispatchEvent(filesUpdated); diff --git a/src/main/resources/static/js/merge.js b/src/main/resources/static/js/merge.js index 1b3599d6..a434e045 100644 --- a/src/main/resources/static/js/merge.js +++ b/src/main/resources/static/js/merge.js @@ -2,6 +2,7 @@ let currentSort = { field: null, descending: false, }; +//New Array to keep track of unique id let filesWithUniqueId = []; let processedFiles = []; @@ -15,6 +16,7 @@ document.getElementById("fileInput-input").addEventListener("change", function ( filesWithUniqueId = files; displayFiles(files); }); +//Get Files Updated Event from FileInput document.addEventListener("filesUpdated", function (e) { filesWithUniqueId = e.detail; displayFiles(filesWithUniqueId); @@ -39,7 +41,7 @@ function displayFiles(files) { fileNameDiv.className = "filename"; fileNameDiv.textContent = files[i].file.name; - // Check for duplicates + // Check for duplicates and add a warning if necessary const duplicateFiles = files.filter(file => file.file.name === files[i].file.name); if (duplicateFiles.length > 1) { const warning = document.createElement("span"); @@ -151,7 +153,6 @@ function updateFiles() { for (var i = 0; i < liElements.length; i++) { var fileIdFromList = liElements[i].dataset.id; // Get the unique identifier from the list item - var fileFromFiles; for (var j = 0; j < filesWithUniqueId.length; j++) { var fileObj = filesWithUniqueId[j]; if (fileObj.uniqueId === fileIdFromList) {