Advertisement
Guest User

No Seconds Box?

a guest
Feb 10th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.69 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Rolex</title>
  4. <style type="text/css">
  5.  
  6. @font-face {
  7. font-family: 'GeoSansLight';
  8. src: url('geosanslight-webfont.eot');
  9. src: url('geosanslight-webfont.woff') format('woff');
  10. font-weight: normal;
  11. font-style: normal;
  12. }
  13.  
  14. body {
  15. Margin-right:315px;
  16. font-family: 'GeoSansLight', sans-serif;
  17. font-size: 50%;
  18. background:url('bg.png');
  19. background-size: 100%;
  20. }
  21.  
  22. #clock {
  23. font-size:1em;
  24. position:relative
  25. }
  26. #frame {
  27. position:relative;
  28. width:18em;
  29. height:18em;
  30. margin:5em auto;
  31. border-radius:15em;
  32. background:url('uhr.png') center center no-repeat;
  33. background-size: 105%;
  34.  
  35. box-shadow:rgba(0,0,0,.6) 0em 0em 0.5em;
  36. }
  37.  
  38.  
  39. #clock-hour {
  40. width:.3em;
  41. height:5.5em;
  42.  
  43. background:#323232;
  44. position:absolute;
  45. bottom:50%; left:50%;
  46. margin:0 0 -.8em -.4em;
  47. -webkit-transform-origin:0.4em 4.7em;
  48. }
  49.  
  50. #clock-minute {
  51. width:.3em;
  52. height:8.5em;
  53. background:#323232;
  54. position:absolute;
  55. bottom:50%; left:50%;
  56. margin:0 0 -1.5em -.4em;
  57. -webkit-transform-origin:0.4em 7em;
  58. }
  59.  
  60. #clock-second {
  61. width:0.3em;
  62. height:8.5em;
  63.  
  64. background:#c00;
  65. position:absolute;
  66. bottom:50%; left:50%;
  67. margin:0 0 -2em -.1em;
  68. box-shadow:rgba(0,0,0,.8) 0 0 .2em;
  69. -webkit-transform-origin:0.1em 6.5em;
  70. }
  71.  
  72. #clock-second:after {
  73. content:'';
  74. width:1em;
  75. height:1.2em;
  76. background:inherit;
  77. position:absolute;
  78. left:-.5em; top:-.1em;
  79. }
  80.  
  81. <-- #clock-second:before {
  82. content:'';
  83. width:.6em;
  84. height:.6em;
  85. box-
  86. background:inherit;
  87. position:absolute;
  88. left:-.20em; bottom:1.65em;
  89. } -->
  90.  
  91.  
  92. .hidden {
  93. display: none;
  94. }
  95. div#time-container{
  96.  
  97. font-size: 30px;
  98. color: #fff;
  99. text-align: center;
  100. text-shadow: rgba(0,0,0,.3) 0 0 .1em;
  101. }
  102.  
  103. p#time-placeholder {
  104. margin: 2px 0 0 0;
  105. }
  106.  
  107. #clock-container {
  108. margin: 10px 0 0 0;
  109. }
  110.  
  111.  
  112. </style>
  113. <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0">
  114. </head>
  115. <body id="body">
  116. <div id="clock-container">
  117. <div id="clock">
  118. <div id="frame"></div>
  119. <div id="clock-hour"></div>
  120. <div id="clock-minute"></div>
  121. <div id="clock-second"></div>
  122. </div>
  123. </div>
  124. <div id="time-container" class="hidden">
  125. <p id="time-placeholder"></p>
  126. <p id="date-placeholder"></p>
  127. </div>
  128.  
  129. <script type="text/javascript">
  130. function getHourAngle() {
  131. var currentDate = new Date();
  132. return Math.round((currentDate.getHours() * 30) + (currentDate.getMinutes() / 2) + (currentDate.getSeconds() / 120));
  133. }
  134.  
  135. function getMinuteAngle() {
  136. var currentDate = new Date();
  137. return Math.round((currentDate.getMinutes() * 6) + (currentDate.getSeconds() / 10));
  138. }
  139.  
  140. function getSecondAngle() {
  141. var currentDate = new Date();
  142. return Math.round((currentDate.getSeconds() * 6));
  143. }
  144.  
  145. function updateClock() {
  146. document.getElementById("clock-hour").setAttribute("style", "-webkit-transform: rotate(" + getHourAngle() + "deg);");
  147. document.getElementById("clock-minute").setAttribute("style", "-webkit-transform: rotate(" + getMinuteAngle() + "deg);");
  148. document.getElementById("clock-second").setAttribute("style", "-webkit-transform: rotate(" + getSecondAngle() + "deg);");
  149. }
  150.  
  151. String.prototype.format = function() {
  152. var formatted = this;
  153. for (var i = 0; i < arguments.length; i++) {
  154. var regexp = new RegExp('\\{'+i+'\\}', 'gi');
  155. formatted = formatted.replace(regexp, arguments[i]);
  156. }
  157. return formatted;
  158. };
  159.  
  160. function calculateTime() {
  161. var Make_It_12_Hour = false;
  162.  
  163. var currentTime = new Date();
  164. var day = currentTime.getDate();
  165. var year = currentTime.getYear() + 1900;
  166. var month = currentTime.getMonth() + 1;
  167. var hours = currentTime.getHours();
  168. var minutes = currentTime.getMinutes();
  169. var outputTemplate = "";
  170.  
  171. if (Make_It_12_Hour) {
  172. hours = hours % 12;
  173. hours = hours ? hours : 12;
  174.  
  175. // 'murica mode. I really don't know who came up with this bullshit
  176. dateoutputTemplate = "{1}.{0}.{2}";
  177. } else {
  178. dateoutputTemplate= "{0}.{1}.{2}";
  179. }
  180. timeoutputTemplate = "{0}:{1}";
  181.  
  182. if (day < 10) { day = "0" + day; }
  183. if (month < 10) { month = "0" + month; }
  184. if (hours < 10) { hours = "0" + hours; }
  185. if (minutes < 10) { minutes = "0" + minutes; }
  186.  
  187. document.getElementById("time-placeholder").innerText = timeoutputTemplate.format(hours, minutes);
  188. document.getElementById("date-placeholder").innerText = dateoutputTemplate.format(day, month, year);
  189. }
  190.  
  191. function showTime() {
  192.  
  193. document.getElementById('time-container').setAttribute("class", "");
  194. }
  195.  
  196. function hideTime() {
  197. document.getElementById('time-container').setAttribute("class", "hidden");
  198. }
  199.  
  200. updateClock();
  201. calculateTime();
  202. setInterval(updateClock, 1000);
  203. setInterval(calculateTime, 1000);
  204. document.getElementById('clock-container').addEventListener('touchstart', showTime, false);
  205. document.getElementById('clock-container').addEventListener('touchend', hideTime, false);
  206.  
  207. </script>
  208.  
  209. </body>
  210. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement