From ab85c5481ca6a5960d0f78f20ba408009bb063c9 Mon Sep 17 00:00:00 2001 From: Mayank Kumar Tiwari Date: Fri, 15 May 2026 23:02:54 +0530 Subject: [PATCH] Added restart button functionality --- index.html | 1 + script.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/index.html b/index.html index 0f7fb66..6568f00 100644 --- a/index.html +++ b/index.html @@ -24,6 +24,7 @@

Progress: 0% (0/0 tasks completed)

00:00:00

+ diff --git a/script.js b/script.js index ca39a81..c3f1cd3 100644 --- a/script.js +++ b/script.js @@ -97,4 +97,27 @@ function updateTime() { function pad(num) { return num < 10 ? "0" + num : num; +} +//stop timer when task is completed +function stop() { + let total = tasks.length; + if (total === 0) return; + let doneTasks = tasks.filter(task => task.done).length; + let percent = Math.round((doneTasks / total) * 100); + + if (percent === 100) { + stopTimer(); + } +} + function toggleTask(index) { + tasks[index].done = !tasks[index].done; + renderTasks(); + stop(); +} +// Restart +function Restart(){ + seconds=0; + updateTime(); + tasks = []; + renderTasks(); } \ No newline at end of file