Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var sessionLength=25;
- var breakLength=5;
- var sound = document.getElementById("audio");
- var timer=10;
- var count=breakLength*60;
- $(document).ready(function(){
- function checkCount(){
- count=count-1;
- if (count <= 0){
- $("#counterShow").html("00:00");
- clearInterval(counter);
- console.log("hey");
- console.log("Check if timer returned and play sound");
- sound.play()
- }
- $("#counterShow").html(Math.floor(count/60)+":"+count%60);
- }
- $(".img").click(function(){
- counter=setInterval(checkCount, 1000); //setInterval is an async function. It returns immediately, and your program continues running from the next line. The function checkCount is called everyone 1000ms.
- count=sessionLength*60;
- timer=10;
- });
- });
Add Comment
Please, Sign In to add comment