From deb92cd787426bb4b9db50713dfa4d2f592c4ed5 Mon Sep 17 00:00:00 2001 From: iton0 Date: Wed, 21 Feb 2024 19:23:55 -0500 Subject: [PATCH] refactor: Improve button styling and simplify code structure - Updated button styles for better visual consistency. - Added comments to provide better insight to the code. - Removed unnecessary click event listener used for testing/debugging. --- index.html | 22 +++++----------------- index.js | 13 +++++-------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/index.html b/index.html index a8d713e..f386283 100644 --- a/index.html +++ b/index.html @@ -44,30 +44,18 @@ aria-controls="collapseExample" > -
- -
-
+
-
+
diff --git a/index.js b/index.js index 03f7100..ca187c2 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,7 @@ document.addEventListener("DOMContentLoaded", () => { const dragContainer = document.getElementById("drag-container"); const trashContainer = document.querySelector(".trash"); + // Function to create an HTML element with class and attributes function createElementWithClassAndAttribute( elementType, className, @@ -15,7 +16,9 @@ document.addEventListener("DOMContentLoaded", () => { return newElement; } + // Function to create a container element function createContainer(type) { + // Create child elements for the container const newContainer = createElementWithClassAndAttribute("span", type, { "data-nesting-level": 0, draggable: true, @@ -90,6 +93,7 @@ document.addEventListener("DOMContentLoaded", () => { ); }); + // If sibling with same name exists returns to default name if (hasDuplicateSibling) { alert(`A ${type} with the same name already exists`); nameInput.name = `new_${type}`; @@ -103,6 +107,7 @@ document.addEventListener("DOMContentLoaded", () => { containerContent.appendChild(dragHandle); containerContent.appendChild(nameInput); newContainer.appendChild(containerContent); + // Files cannot have elements nested in them if (type === "folder") { newContainer.appendChild(nestItems); } @@ -181,14 +186,6 @@ document.addEventListener("DOMContentLoaded", () => { } } - // For testing/debugging - newContainer.addEventListener("click", (e) => { - e.stopPropagation(); - e.preventDefault(); - console.log("current target:", e.currentTarget); - console.log("nesting level :", e.currentTarget.dataset.nestingLevel); - }); - // New container event listeners newContainer.addEventListener("dragstart", (e) => { e.stopPropagation();