As the title says, I am trying to get the following Javascript working in IE 8 to no avail.. Could anyone point me in the right direction please?
The script is for two animated clocks which works all fine and and dandy in EI9, Firefox and Chrome. EI8 the hands remain unmoved but there are no indicated errors in the browser.. (Safe to assume anything under IE8 will not be working)
(function(jQuery)
{
jQuery.fn.clock = function(options)
{
var defaults = {
offset: '+0',
type: 'analog'
};
var _this = this;
var opts = jQuery.extend(defaults, options);
setInterval( function() {
var seconds = jQuery.calcTime(opts.offset).getSeconds();
if(opts.type=='analog')
{
var sdegree = seconds * 6;
var srotate = "rotate(" + sdegree + "deg)";
var rad = Math.PI/180 * sdegree,
cos = Math.cos(rad),
sin = Math.sin(sin);
jQuery(_this).find(".sec").css({"-moz-transform" : srotate, "-webkit-transform" : srotate, "-ms-transform" : srotate, "-sand-transform" : srotate,
'-ms-filter': "progid:DXImageTransform.Microsoft.Matrix(M11="+cos+", M12="+(-sin)+", M21="+sin+", M22="+cos+", SizingMethod='auto expand')"});
}
else
{
jQuery(_this).find(".sec").html(seconds);
}
}, 1000 );
setInterval( function() {
var hours = jQuery.calcTime(opts.offset).getHours();
var mins = jQuery.calcTime(opts.offset).getMinutes();
if(opts.type=='analog')
{
var hdegree = hours * 30 + (mins / 2);
var hrotate = "rotate(" + hdegree + "deg)";
var rad = Math.PI/180 * hdegree,
cos = Math.cos(rad),
sin = Math.sin(sin);
jQuery(_this).find(".hour").css({"-moz-transform" : hrotate, "-webkit-transform" : hrotate, "-ms-transform" : hrotate, "-sand-transform" : hrotate,
'-ms-filter': "progid:DXImageTransform.Microsoft.Matrix(M11="+cos+", M12="+(-sin)+", M21="+sin+", M22="+cos+", SizingMethod='auto expand')"});
}
else
{
jQuery(_this).find(".hour").html(hours+':');
}
var meridiem = hours<12?'AM':'PM';
jQuery(_this).find('.meridiem').html(meridiem);
}, 1000 );
setInterval( function() {
var mins = jQuery.calcTime(opts.offset).getMinutes();
if(opts.type=='analog')
{
var mdegree = mins * 6;
var mrotate = "rotate(" + mdegree + "deg)";
var rad = Math.PI/180 * mdegree,
cos = Math.cos(rad),
sin = Math.sin(sin);
jQuery(_this).find(".min").css({"-moz-transform" : mrotate, "-webkit-transform" : mrotate, "-ms-transform" : mrotate, "-sand-transform" : mrotate,
'-ms-filter': "progid:DXImageTransform.Microsoft.Matrix(M11="+cos+", M12="+(-sin)+", M21="+sin+", M22="+cos+", SizingMethod='auto expand')"});
}
else
{
jQuery(_this).find(".min").html(mins+':');
}
}, 1000 );
}
})(jQuery);
jQuery.calcTime = function(offset) {
d = new Date();
utc = d.getTime() + (d.getTimezoneOffset() * 60000);
nd = new Date(utc + (3600000*offset));
return nd;
};
-ms-filteris specific to IE9. In IE8 and below, the property was justfilter.IE9 supports transforms under
-ms-transform, so you could alter your code to set-ms-transformfor IE9 andfilterfor IE<=8.