Guest User

Untitled

a guest
Oct 23rd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="no">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>Tid</title>
  7. </head>
  8. <body>
  9.  
  10. <button id="btn">TAPP HER</button>
  11. <button id="btnReset">RESET</button>
  12.  
  13. <script>
  14.  
  15. var btn = document.getElementById("btn");
  16. var btnReset = document.getElementById("btnReset");
  17. var antall = 0;
  18.  
  19. var tidenflyr = false;
  20.  
  21. function stoppKlokka() {
  22. tidenflyr = false;
  23. btn.disabled = true;
  24. console.log("Stopper klokka");
  25. // TODO - Registrer antall klikk
  26. antall = 0; // Reset antall
  27. }
  28.  
  29. function startKlokka() {
  30. tidenflyr = true;
  31. // Stopper klokka etter 10 sekunder
  32. console.log("Starter klokka");
  33. setTimeout(stoppKlokka, 10000);
  34. }
  35.  
  36. function tell() {
  37. if(tidenflyr){
  38. antall++;
  39. } else {
  40. startKlokka();
  41. antall++;
  42. }
  43. }
  44.  
  45. btn.onclick = tell;
  46.  
  47.  
  48.  
  49. </script>
  50.  
  51.  
  52. </body>
  53. </html>
Add Comment
Please, Sign In to add comment