Skip to content

Commit

Permalink
added isStopped
Browse files Browse the repository at this point in the history
  • Loading branch information
amoghar29 committed Jun 16, 2024
1 parent 78a5a53 commit 7125847
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -51,13 +54,3 @@ document.getElementById('continue').addEventListener('click', function(){
pausedTime = 0;
}
})










0 comments on commit 7125847

Please sign in to comment.