Guest User

Untitled

a guest
Feb 17th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. var sessionLength=25;
  2. var breakLength=5;
  3. var sound = document.getElementById("audio");
  4. var timer=10;
  5. var count=breakLength*60;
  6.  
  7. $(document).ready(function(){
  8. function checkCount(){
  9. count=count-1;
  10. if (count <= 0){
  11. $("#counterShow").html("00:00");
  12. clearInterval(counter);
  13. console.log("hey");
  14.  
  15. console.log("Check if timer returned and play sound");
  16. sound.play()
  17. }
  18.  
  19. $("#counterShow").html(Math.floor(count/60)+":"+count%60);
  20. }
  21.  
  22. $(".img").click(function(){
  23. 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.
  24. count=sessionLength*60;
  25. timer=10;
  26. });
  27. });
Add Comment
Please, Sign In to add comment