1 <!-- Thank you to Toby Pitman for posting this really cool article (and
2 javascript / css / image) explaining how to make a running analog
3 clock webpage. See: http://css-tricks.com/css3-clock for more info. -->
5 <script type="text/javascript" src="jquery-1.2.6.min.js"></script>
6 <style type="text/css">
12 background-color: #222222;
24 border-collapse:collapse;
42 margin: 20px auto 0 auto;
44 // background-image: url("clockimg/smallface.gif");
71 background: url("clockimg/sechand.png");
75 background: url("clockimg/minhand.png");
83 background: url("clockimg/hourhand.png");
90 <script type="text/javascript">
93 $.fn.preload = function() {
94 this.each(function() {
95 $('<img/>')[0].src = this;
99 var face = new Image();
100 face.onload = function() {
101 $("#clock").css("background", "url(clockimg/smallface.gif)");
103 face.src = "clockimg/smallface.gif";
143 $(digit_images).preload();
145 // Rotate second hand and set seconds.
148 var date = new Date();
149 var ms = date.getMilliseconds();
150 var seconds = date.getSeconds();
151 var sdegree = seconds * 6 + (ms / 166);
152 var srotate = "rotate(" + sdegree + "deg)";
153 $("#sec").css({"-moz-transform" : srotate,
154 "-webkit-transform" : srotate});
155 var s1 = Math.floor(seconds / 10);
156 var s2 = seconds % 10;
157 $("#s1").css({"content" : "url(" + digit_images[s1] + ")"});
158 $("#s2").css({"content" : "url(" + digit_images[s2] + ")"});
161 // Rotate minute hand and set minutes.
162 function updateMinutes() {
163 var date = new Date();
164 var mins = date.getMinutes();
165 var seconds = date.getSeconds();
166 var mdegree = mins * 6 + (seconds / 10);
167 var mrotate = "rotate(" + mdegree + "deg)";
168 $("#min").css({"-moz-transform" : mrotate,
169 "-webkit-transform" : mrotate});
170 var m1 = Math.floor(mins / 10);
172 $("#m1").css({"content" : "url(" + digit_images[m1] + ")"});
173 $("#m2").css({"content" : "url(" + digit_images[m2] + ")"});
176 setInterval(function(){updateMinutes();}, 3000);
178 // Rotate hour hand and set hours.
179 function updateHours() {
180 var date = new Date();
181 var hours = date.getHours();
182 var mins = date.getMinutes();
183 var hdegree = hours * 30 + (mins / 2);
184 var hrotate = "rotate(" + hdegree + "deg)";
185 $("#hour").css({"-moz-transform" : hrotate,
186 "-webkit-transform" : hrotate});
193 var h1 = Math.floor(hours / 10);
195 $("#h1").css({"content" : "url(" + digit_images[h1] + ")"});
196 $("#h2").css({"content" : "url(" + digit_images[h2] + ")"});
199 setInterval(function(){updateHours();}, 10000);
201 function updateDate() {
202 var date = new Date();
203 var day = date.getDate();
204 var d1 = Math.floor(day / 10);
206 $("#d1").css({"content" : "url(" + digit_images[d1] + ")"});
207 $("#d2").css({"content" : "url(" + digit_images[d2] + ")"});
208 $("#dd1").css({"content" : "url(" + digit_images[d1] + ")"});
209 $("#dd2").css({"content" : "url(" + digit_images[d2] + ")"});
210 var dow = date.getDay();
211 $("#dow").css({"content" : "url(" + day_images[dow] + ")"});
212 var month = date.getMonth();
213 $("#mm").css({"content" : "url(" + month_images[month] + ")"});
216 setInterval(function(){updateDate();}, 10000);
221 <div style="height:775px; float:none">
224 <table style="background-color:#999999" border>
225 <td><img src="0.png" height=26 id="d1" class="digit"></td>
226 <td><img src="1.png" height=26 id="d2" class="digit"></td>
232 <li><div id="analog">
234 <table style="background-color:#999999;height:80px;" border>
236 <td><img src="clockimg/2.png" id="h1" class="digit"></td>
237 <td><img src="clockimg/3.png" id="h2" class="digit"></td>
238 <td style="border: none"> </td>
239 <td><img src="clockimg/4.png" id="m1" class="digit"></td>
240 <td><img src="clockimg/5.png" id="m2" class="digit"></td>
241 <td style="border: none"> </td>
242 <td><img src="clockimg/6.png" id="s1" class="digit"></td>
243 <td><img src="clockimg/7.png" id="s2" class="digit"></td>
247 <table style="background-color:#999999;height:80px;" border>
249 <td><img src="clockimg/sun.png" id="dow" class="digit"></td>
250 <td style="border: none"> </td>
251 <td><img src="clockimg/8.png" id="dd1" class="digit"></td>
252 <td><img src="clockimg/9.png" id="dd2" class="digit"></td>
253 <td style="border: none"> </td>
254 <td><img src="clockimg/jan.png" id="mm" class="digit"></td>