diff --git a/script.js b/script.js index f72b475..f47e8ae 100644 --- a/script.js +++ b/script.js @@ -2,7 +2,8 @@ var cur; let ftime; let interval; let isPaused = false; -let pausedTime = 0 +let pausedTime = 0 ; +let isStopped = false; const dif = function(){ ftime = Date.now(); @@ -13,11 +14,13 @@ const dif = function(){ document.getElementById('start').addEventListener('click', function(){ cur = Date.now(); interval = setInterval(dif, 1000); + isStopped = true; }); document.getElementById('stop').addEventListener('click', function(){ clearInterval(interval); + isStopped = false; }); document.getElementById('reset').addEventListener('click', function(){ clearInterval(interval); @@ -29,7 +32,7 @@ document.getElementById('reset').addEventListener('click', function(){ }); document.getElementById('lapse').addEventListener('click', function(){ - if (!isPaused){ + if (!isPaused || !isPaused){ const element1 = document.createElement('div'); element1.innerHTML = (Date.now() - cur) / 1000; document.getElementById('display').appendChild(element1); @@ -51,13 +54,3 @@ document.getElementById('continue').addEventListener('click', function(){ pausedTime = 0; } }) - - - - - - - - - -