Skip to content

Commit

Permalink
abi: made timer go, and stop when canceled
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyHubert committed Aug 1, 2024
1 parent 3c6dae4 commit 3db6309
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions abi/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,30 @@ const WORKOUT_OPTIONS = {
},
]
}

let workoutTimer = undefined
let startWorkoutFunction = () => {
document.querySelector('#screen-buttons').classList.add('hide')
document.querySelector('#screen-workout').classList.remove('hide')
document.querySelector('#screen-workout').classList.remove('hide')
let numSecondsLeft = 15 * 60
document.querySelector('#clock').innerHTML = "15:00"
setTimeout(
() => {
workoutTimer = setInterval(
() => {
numSecondsLeft--
clockTimer = `${Math.floor(numSecondsLeft / 60)}:${numSecondsLeft % 60}`
let seconds = numSecondsLeft % 60
if(seconds <= 9){
clockTimer = `${Math.floor(numSecondsLeft / 60)}:0${numSecondsLeft % 60}`
}
document.querySelector('#clock').innerHTML = clockTimer
},
1000 * 1
)
},
100
)

}

document.querySelector('#do-legs').addEventListener('click',
Expand All @@ -181,6 +201,7 @@ document.querySelector('#cancel').addEventListener('click',
() => {
document.querySelector('#screen-workout').classList.add('hide')
document.querySelector('#screen-buttons').classList.remove('hide')
clearInterval(workoutTimer)
}
)
document.querySelector('#view-log').addEventListener('click',
Expand Down Expand Up @@ -210,7 +231,9 @@ document.querySelector('#stick-figure').innerHTML = `
/ \\
/ \\
`







Expand Down

0 comments on commit 3db6309

Please sign in to comment.