Guest User

Untitled

a guest
Mar 24th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.79 KB | None | 0 0
  1. <html>
  2.  
  3. <head>
  4.  
  5.     <title>thinClock</title>
  6.  
  7.     <style type="text/css">
  8.  
  9.  
  10.  
  11.         @font-face {
  12.  
  13.             font-family: 'Raleway';
  14.  
  15.             font-style: normal;
  16.  
  17.             font-weight: 100;
  18.  
  19.             src: local('Raleway Thin'), local('Raleway-Thin'), url('raleway100.woff') format('woff');
  20.  
  21.         }
  22.  
  23.  
  24.  
  25.         @font-face {
  26.  
  27.             font-family: 'Raleway';
  28.  
  29.             font-style: normal;
  30.  
  31.             font-weight: 300;
  32.  
  33.             src: local('Raleway Light'), local('Raleway-Light'), url('raleway300.woff') format('woff');
  34.  
  35.         }
  36.  
  37.  
  38.  
  39.         body {
  40.  
  41.             background: url('bg.jpg') center center no-repeat;
  42.  
  43.             background-size: 100%;
  44.  
  45.         }
  46.  
  47.  
  48.  
  49.         h1 {
  50.  
  51.             margin: 5px 0 0 0;
  52.  
  53.             text-align: left;
  54.  
  55.             color: #fff;
  56.  
  57.             font-family: 'Raleway', sans-serif;
  58.  
  59.             font-weight: 100;
  60.  
  61.             font-size: 80px;
  62.  
  63.         }
  64.  
  65.  
  66.  
  67.         p {
  68.  
  69.             margin: 1px 0 0 0;
  70.  
  71.             text-align: right;
  72.  
  73.             color: #fff;
  74.  
  75.             font-family: 'Raleway', sans-serif;
  76.  
  77.             font-weight: 300;
  78.  
  79.             font-size: 20px;
  80.  
  81.         }
  82.  
  83.  
  84.  
  85.     </style>
  86.  
  87.     <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0">
  88.  
  89. </head>
  90.  
  91. <body>
  92.  
  93.  
  94.  
  95.     <h1 id="time"></h1>
  96.  
  97.     <p id="date"></p>
  98.  
  99.  
  100.  
  101.     <script type="text/javascript">
  102.  
  103.  
  104.  
  105.         function calculateTime() {
  106.  
  107.             var Make_It_12_Hour = false;
  108.  
  109.  
  110.  
  111.             var currentTime = new Date();
  112.  
  113.             var hours = currentTime.getHours();
  114.  
  115.             var minutes = currentTime.getMinutes();
  116.  
  117.  
  118.  
  119.             if (Make_It_12_Hour) {
  120.  
  121.                 var ampm = hours >= 12 ? "pm" : "am";
  122.  
  123.                 hours = hours % 12;
  124.  
  125.                 hours = hours ? hours : 12;
  126.  
  127.                 minutes = minutes < 10 ? "0" + minutes : minutes;
  128.  
  129.             } else {
  130.  
  131.                 if (minutes < 10) { minutes = "0" + minutes; }
  132.  
  133.                 if (hours < 10) { hours = "0" + hours; }
  134.  
  135.             }
  136.  
  137.  
  138.  
  139.             document.getElementById("time").innerText = hours + ":" + minutes;
  140.  
  141.         }
  142.  
  143.  
  144.  
  145.         function calculateDate() {
  146.  
  147.             var months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
  148.  
  149.             var currentTime = new Date();
  150.  
  151.             var day = currentTime.getDate().toString();
  152.  
  153.             var month = months[currentTime.getMonth()];
  154.  
  155.             var year = currentTime.getFullYear();
  156.  
  157.  
  158.  
  159.             var dayInd = (day.length >= 2) ? day.substring(day.length - 1) : day;
  160.  
  161.             var ending = "";
  162.  
  163.  
  164.  
  165.             switch (dayInd) {
  166.  
  167.                 case "1":
  168.  
  169.                     ending = (day == "11") ? "th" : "st";
  170.  
  171.                     break;
  172.  
  173.                 case "2":
  174.  
  175.                     ending = (day == "12") ? "th" : "nd";
  176.  
  177.                     break;
  178.  
  179.                 case "3":
  180.  
  181.                     ending = (day == "13") ? "th" : "rd";
  182.  
  183.                     break;
  184.  
  185.                 default:
  186.  
  187.                     ending = "th";
  188.  
  189.                     break;
  190.  
  191.             }
  192.  
  193.  
  194.  
  195.             document.getElementById("date").innerText = day + ending + " of " + month;
  196.  
  197.         }
  198.  
  199.  
  200.  
  201.         calculateTime();
  202.  
  203.         calculateDate();
  204.  
  205.         setInterval(calculateTime, 2000);
  206.  
  207.         setInterval(calculateDate, 60000);
  208.  
  209.        
  210.  
  211.  
  212.  
  213.     </script>
  214.  
  215.  
  216.  
  217. </body>
  218.  
  219. </html>
Advertisement
Add Comment
Please, Sign In to add comment