1/* Copyright (c) 2009 José JoaquÃn Núñez ([email protected]) http://joaquinnunez.cl/blog/ 2 * Licensed under GPL (http://www.opensource.org/licenses/gpl-2.0.php) 3 * Use only for non-commercial usage. 4 * 5 * Version : 0.1 6 * 7 * Requires: jQuery 1.2+ 8 */ 9 10(function(jQuery) 11{ 12 jQuery.fn.clock = function(options) 13 { 14 var defaults = { 15 offset: '+0', 16 type: 'analog' 17 }; 18 var _this = this; 19 var opts = jQuery.extend(defaults, options); 20 21 setInterval( function() { 22 var seconds = jQuery.calcTime(opts.offset).getSeconds(); 23 24 if(opts.type=='analog') 25 { 26 var sdegree = seconds * 6; 27 var srotate = "rotate(" + sdegree + "deg)"; 28 jQuery(_this).find(".sec").css({"-moz-transform" : srotate, "-webkit-transform" : srotate}); 29 } else { 30 if(seconds < 10){ 31 seconds = "0" + seconds; 32 } 33 34 jQuery(_this).find(".sec").html(seconds); 35 } 36 }, 1000 ); 37 38 setInterval( function() { 39 var hours = jQuery.calcTime(opts.offset).getHours(); 40 var mins = jQuery.calcTime(opts.offset).getMinutes(); 41 if(opts.type=='analog') 42 { 43 var hdegree = hours * 30 + (mins / 2); 44 var hrotate = "rotate(" + hdegree + "deg)"; 45 jQuery(_this).find(".hour").css({"-moz-transform" : hrotate, "-webkit-transform" : hrotate}); 46 } 47 else 48 { 49 jQuery(_this).find(".hour").html(hours+':'); 50 } 51 var meridiem = hours<12?'AM':'PM'; 52 jQuery(_this).find('.meridiem').html(meridiem); 53 }, 1000 ); 54 55 setInterval( function() { 56 var mins = jQuery.calcTime(opts.offset).getMinutes(); 57 if(opts.type=='analog') 58 { 59 var mdegree = mins * 6; 60 var mrotate = "rotate(" + mdegree + "deg)"; 61 jQuery(_this).find(".min").css({"-moz-transform" : mrotate, "-webkit-transform" : mrotate}); 62 } 63 else 64 { 65 if(mins < 10){ 66 mins = "0" + mins; 67 } 68 jQuery(_this).find(".min").html(mins+':'); 69 } 70 }, 1000 ); 71 } 72})(jQuery); 73 74 75jQuery.calcTime = function(offset) { 76 // create Date object for current location 77 d = new Date(); 78 79 // convert to msec 80 // add local time zone offset 81 // get UTC time in msec 82 utc = d.getTime() + (d.getTimezoneOffset() * 60000); 83 // create new Date object for different city 84 // using supplied offset 85 86 nd = new Date(utc + (3600000*offset)); 87 88 // return time as a string 89 return nd; 90};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.