From 601a81c38b3f3eb4782ee3624fdd839aaec5d3b8 Mon Sep 17 00:00:00 2001 From: liyunze <50455574+liyunze-coding@users.noreply.github.com> Date: Tue, 15 Aug 2023 22:23:27 +0800 Subject: [PATCH] updated taskList.js, fixed no return bugs --- scripts/taskList.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/taskList.js b/scripts/taskList.js index 2bd7545..6d6efa2 100644 --- a/scripts/taskList.js +++ b/scripts/taskList.js @@ -236,12 +236,12 @@ function addTask(username, userColor, task) { // removed task: success function removeTask(username, task) { const tasks = JSON.parse(localStorage.tasks); - const incompleteTasks = tasks[username].todos.filter((t) => !t.done); - if (!tasks[username] || tasks[username].todos.length === 0) { return 0; } + const incompleteTasks = tasks[username].todos.filter((t) => !t.done); + // match regex: integers separated by space e.g. '1 2 3 4' if (task.match(/^(\d+ )*\d+$/)) { // insert commas between integers @@ -373,13 +373,14 @@ function clearOwnDoneTasks(username) { // task: succcess function markTaskDone(username, task) { const tasks = JSON.parse(localStorage.tasks); - const incompleteTasks = tasks[username].todos.filter((t) => !t.done); // user does not have any tasks if (!tasks[username] || tasks[username].todos.length === 0) { return 0; } + const incompleteTasks = tasks[username].todos.filter((t) => !t.done); + // match regex: integers separated by space e.g. '1 2 3 4' if (task.match(/^(\d+ )*\d+$/)) { // insert commas between integers @@ -782,9 +783,7 @@ function cancelAnimation() { } (function () { - // setupDB(); - resetDB(); - tests1(); + setupDB(); importStyles(); renderTaskListToDOM(); })();