Skip to content

Commit

Permalink
Deleted Console logs and adjusted some comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
t71rs committed May 14, 2024
1 parent 36192ba commit ce3e98e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 0 additions & 3 deletions src/main/resources/static/js/fileInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/static/js/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ let currentSort = {
field: null,
descending: false,
};
//New Array to keep track of unique id
let filesWithUniqueId = [];
let processedFiles = [];

Expand All @@ -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);
Expand All @@ -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");
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit ce3e98e

Please sign in to comment.