Advertisement
tirabytes

HTML: Timer with Java Refresh

Apr 1st, 2019
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.21 KB | None | 0 0
  1. <html style="display:block; height:100%; margin:0; padding:0"
  2. <head>
  3. <style type="text/css">
  4.     html {
  5.         background: #000000;
  6.         }
  7.         #timer {
  8.         padding: 100px;
  9.         font-family: sans-serif;
  10.         font-weight: bold;
  11.         color: #FFFFFF;
  12.         }
  13. </style>
  14. <meta http-equiv="refresh" content="1800">
  15. </head>
  16. <body style="display:table; width:100%; height:100%; margin:0; padding:0">
  17.  
  18. <div style="display:table-cell; width:100%; height:100%; text-align:center; vertical-align:middle">
  19.     <span id="timer" style="font-size:400pt; font-kerning:none"></span>
  20. </div>
  21. <script type="text/javascript">
  22. function checklength(i) {
  23.     'use strict';
  24.     if (i < 10) {
  25.        i = "0" + i;
  26.    }
  27.    return i;
  28. }
  29.  
  30. var minutes, seconds, count, counter, timer;
  31. count = 1801; //seconds
  32. counter = setInterval(timer, 1000);
  33.  
  34. function timer() {
  35.    'use strict';
  36.    count = count - 1;
  37.    minutes = checklength(Math.floor(count / 60));
  38.    seconds = checklength(count - minutes * 60);
  39.    if (count < 0) {
  40.        clearInterval(counter);
  41.        return;
  42.    }
  43.    document.getElementById("timer").innerHTML = '' + minutes + ':' + seconds + ' ';
  44.    if (count === 0) {
  45.        location.reload();
  46.    }
  47. }
  48. </script>
  49. </body>
  50. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement