From f2b9110ef67f6f47d32c34b4e7b3d0fa7e5c41ca Mon Sep 17 00:00:00 2001 From: Bayyana-kiran <99533113+Bayyana-kiran@users.noreply.github.com> Date: Fri, 12 Jan 2024 01:12:00 +0530 Subject: [PATCH 1/2] MODIFIED "Clear all the tasks should only appear when there is atleast on task present" #331 --- index.js | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/index.js b/index.js index eeb05d6..efbafa3 100644 --- a/index.js +++ b/index.js @@ -21,7 +21,6 @@ const priorityColors = { Completed: "task-completed", }; - const priorityValues = { High: 3, Medium: 2, @@ -726,37 +725,43 @@ function toggleMode() { // Function to clear all tasks function clearAllTasks() { + const taskList = document.getElementById("taskList"); // Replace with your actual task list ID const confirmationBoxAll = document.getElementById("custom-confirm-all"); const alertTitle = document.getElementById("confirm-msg-all"); const confirmYesButtonAll = document.getElementById("confirm-yes-all"); const confirmNoButtonAll = document.getElementById("confirm-no-all"); const confirmCancelButtonAll = document.getElementById("confirm-cancel-all"); - alertTitle.innerHTML = "⚠ Are you sure you want to delete all tasks?"; - alertTitle.className = "alert alert-danger"; - alertTitle.role = "alert"; + if (taskList.children.length > 0) { + alertTitle.innerHTML = "⚠ Are you sure you want to delete all tasks?"; + alertTitle.className = "alert alert-danger"; + alertTitle.role = "alert"; - confirmYesButtonAll.addEventListener("click", () => { - confirmationBoxAll.style.display = "none"; - while (taskList.firstChild) { - taskList.removeChild(taskList.firstChild); - } - document.querySelector(".clear-btn").style.display = "none"; - document.querySelector(".dropdown").style.display = "none"; - tasksHeading.classList.add("hidden"); - searchBar.classList.add("hidden"); - saveTasksToLocalStorage(); - }); + confirmYesButtonAll.addEventListener("click", () => { + confirmationBoxAll.style.display = "none"; + while (taskList.firstChild) { + taskList.removeChild(taskList.firstChild); + } + document.querySelector(".clear-btn").style.display = "none"; + document.querySelector(".dropdown").style.display = "none"; + tasksHeading.classList.add("hidden"); + searchBar.classList.add("hidden"); + saveTasksToLocalStorage(); + }); - confirmNoButtonAll.addEventListener("click", () => { - confirmationBoxAll.style.display = "none"; - }); + confirmNoButtonAll.addEventListener("click", () => { + confirmationBoxAll.style.display = "none"; + }); - confirmCancelButtonAll.addEventListener("click", () => { - confirmationBoxAll.style.display = "none"; - }); + confirmCancelButtonAll.addEventListener("click", () => { + confirmationBoxAll.style.display = "none"; + }); - confirmationBoxAll.style.display = "flex"; + confirmationBoxAll.style.display = "flex"; + } else { + // If there are no tasks, you may choose to show a message or take alternative action + // alert("No tasks to clear"); + } } // Function to sort task list by due date From 32439c9fd59213f38aa213edb7842efe7e3425af Mon Sep 17 00:00:00 2001 From: Bayyana-kiran <99533113+Bayyana-kiran@users.noreply.github.com> Date: Fri, 12 Jan 2024 21:48:27 +0530 Subject: [PATCH 2/2] ADDED "#331" --- index.html | 51 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index c8a89fe..2fc83e8 100644 --- a/index.html +++ b/index.html @@ -158,25 +158,30 @@

Add your tasks below :

+ + +
@@ -188,6 +193,7 @@

Tasks

+
@@ -235,6 +241,39 @@