Advertisement
Guest User

Untitled

a guest
Nov 11th, 2016
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.89 KB | None | 0 0
  1. <html>
  2.  
  3. <head>
  4. <meta charset=”utf-8? />
  5. <meta name=”format-detection” content=”telephone=no” />
  6. <meta name=”msapplication-tap-highlight” content=”no” />
  7. <meta name=”viewport” content=”user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width/>
  8. <meta http-equiv=”Content-Security-Policy” content=”default-src * ‘unsafe-inline’; style-src ‘self’ ‘unsafe-inline’; media-src *” />
  9. <link rel="icon" href="icon.png">
  10. <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.css">
  11. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  12. <script src="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.js"></script>
  13. <title>Interactive Page</title>
  14.  
  15. </head>
  16. <style>
  17.     body{
  18.         font-size: 200%;
  19.     }
  20.     img {
  21.         max-width:100%;
  22.         height:auto;
  23.     }  
  24.     .ui-btn{
  25.         font-size: 200%;
  26.     }
  27.    
  28. </style>
  29.  
  30. <body>
  31.     <center>
  32.         <h3>Time in seconds: <text id="seconds">0</text></h3>
  33.         <button id="startBtn">Start timer</button>
  34.         <button id="resetBtn">Reset timer</button>
  35.     </center>
  36. </body>
  37.  
  38. <script>
  39.     var timerStarted = false;
  40.     var seconds = 0;
  41.     var timer;
  42.    
  43.     function updateTime(){
  44.         $("#seconds").html(seconds);
  45.     }
  46.    
  47.     function resetTime(){
  48.         seconds = 0;
  49.         updateTime();
  50.     }
  51.  
  52.     function changeTime(){
  53.         seconds += 1;
  54.         updateTime();
  55.     }
  56.    
  57.     $("#startBtn").click(
  58.         function(){
  59.             if(!timerStarted){
  60.                 timerStarted = true;
  61.                 $("#startBtn").html("End timer!");
  62.                 timer = setInterval(changeTime, 1000);
  63.             }else{
  64.                 timerStarted = false;
  65.                 $("#startBtn").html("Start timer!");
  66.                 clearInterval(timer);
  67.             }
  68.            
  69.         }
  70.     );
  71.    
  72.     $("#resetBtn").click(
  73.         function(){
  74.             timerStarted = false;
  75.             $("#startBtn").html("Start timer!");
  76.             clearInterval(timer);
  77.             resetTime();
  78.         }
  79.     );
  80.    
  81.    
  82.    
  83.    
  84. </script>
  85.  
  86. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement