Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. let opoznienie=setInterval(funkcja,10);
  2. let ms=0, h=0, m=0, s=0;
  3. let uchwyt=""
  4. document.addEventListener("DOMContentLoaded" , przyciski , false)
  5. function przyciski()
  6. {
  7. a=document.getElementById("start");
  8. b=document.getElementById("stop");
  9. c=document.getElementById("reset");
  10. c.addEventListener("click",function(){reset()},false)
  11. b.addEventListener("click",function(){stop()},false)
  12. a.addEventListener("click",function(){start()},false)
  13. }
  14. function stop()
  15. {
  16. clearInterval(opoznienie);
  17. }
  18. function start()
  19. {
  20. opoznienie=setInterval(funkcja,10);
  21. }
  22. function reset()
  23. {
  24. ms=0;h=0;m=0;s=0;
  25. document.getElementById("stoper").innerHTML="00:00:00:00";
  26. }
  27. function funkcja()
  28. {
  29. uchwyt=""
  30. ms++
  31. if(ms>=100)
  32. {
  33. s++;
  34. ms=0;
  35. if(s>=60)
  36. {
  37. m++;
  38. s=0;
  39. if(m>=60)
  40. {
  41. h++;
  42. }
  43. }
  44. }
  45. if(h<10)
  46. {
  47. uchwyt+="0";
  48. }
  49. uchwyt+=h+":";
  50. if(m<10)
  51. {
  52. uchwyt+="0";
  53. }
  54. uchwyt+=m+":";
  55. if(s<10)
  56. {
  57. uchwyt+="0";
  58. }
  59. uchwyt+=s+":";
  60. if(ms<10)
  61. {
  62. uchwyt+="0";
  63. }
  64. uchwyt+=ms;
  65. document.getElementById("stoper").innerHTML=uchwyt;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement