V
vierailija
Vieras
<script type="text/javascript">
var ClockAnalog = {
aSecond: [], dtDate: new Date(),
iCurrSecond: -1, iHourRotation: -1, iMinuteRotation: -1, iStepSize: 10,
iTimerAnimate: setInterval("ClockAnalog.fAnimate()", 20),
iTimerUpdate: setInterval("ClockAnalog.fUpdate()", 1000),
fAnimate: function() {if (this.aSecond.length > 0) {this.fRotate("clock_arrow_second", this.aSecond[0]);this.aSecond = this.aSecond.slice(1);}},
fGetHour: function() { var iHours = this.dtDate.getHours();if (iHours > 11) { iHours -= 12; }return Math.round((this.dtDate.getHours() * 30) + (this.dtDate.getMinutes() / 2) + (this.dtDate.getSeconds() / 120));},
fGetMinute: function() { return Math.round((this.dtDate.getMinutes() * 6) + (this.dtDate.getSeconds() / 10));},
fInit: function() { this.iHourRotation = this.fGetHour(); this.fRotate("clock_arrow_hour", this.iHourRotation); this.iMinuteRotation = this.fGetMinute(); this.fRotate("clock_arrow_minute", this.iMinuteRotation); this.iCurrSecond = this.dtDate.getSeconds(); this.fRotate("clock_arrow_second", (6 * this.iCurrSecond));},
fRotate: function(sID, iDeg) { var sCSS = ("rotate(" + iDeg + "deg)"); $("#" + sID).css({ '-moz-transform': sCSS, '-o-transform': sCSS, '-webkit-transform': sCSS });},
fStepSize: function(iTo, iFrom) { var iAnimDiff = (iFrom - iTo); if (iAnimDiff > 0) { iAnimDiff -= 360; } return iAnimDiff / this.iStepSize; },
fUpdate: function() { this.dtDate = new Date(); var iTemp = this.fGetHour(); if (this.iHourRotation != iTemp) { this.iHourRotation = iTemp; this.fRotate("clock_arrow_hour", iTemp); }iTemp = this.fGetMinute();if (this.iMinuteRotation != iTemp) { this.iMinuteRotation = iTemp; this.fRotate("clock_arrow_minute", iTemp); }if (this.iCurrSecond != this.dtDate.getSeconds()) { var iRotateFrom = (6 * this.iCurrSecond); this.iCurrSecond = this.dtDate.getSeconds(); var iRotateTo = (6 * this.iCurrSecond); var iDiff = this.fStepSize(iRotateTo, iRotateFrom); for (var i = 0; i < this.iStepSize; i++) { iRotateFrom -= iDiff; this.aSecond.push(Math.round(iRotateFrom));}}}
};
</script>
var ClockAnalog = {
aSecond: [], dtDate: new Date(),
iCurrSecond: -1, iHourRotation: -1, iMinuteRotation: -1, iStepSize: 10,
iTimerAnimate: setInterval("ClockAnalog.fAnimate()", 20),
iTimerUpdate: setInterval("ClockAnalog.fUpdate()", 1000),
fAnimate: function() {if (this.aSecond.length > 0) {this.fRotate("clock_arrow_second", this.aSecond[0]);this.aSecond = this.aSecond.slice(1);}},
fGetHour: function() { var iHours = this.dtDate.getHours();if (iHours > 11) { iHours -= 12; }return Math.round((this.dtDate.getHours() * 30) + (this.dtDate.getMinutes() / 2) + (this.dtDate.getSeconds() / 120));},
fGetMinute: function() { return Math.round((this.dtDate.getMinutes() * 6) + (this.dtDate.getSeconds() / 10));},
fInit: function() { this.iHourRotation = this.fGetHour(); this.fRotate("clock_arrow_hour", this.iHourRotation); this.iMinuteRotation = this.fGetMinute(); this.fRotate("clock_arrow_minute", this.iMinuteRotation); this.iCurrSecond = this.dtDate.getSeconds(); this.fRotate("clock_arrow_second", (6 * this.iCurrSecond));},
fRotate: function(sID, iDeg) { var sCSS = ("rotate(" + iDeg + "deg)"); $("#" + sID).css({ '-moz-transform': sCSS, '-o-transform': sCSS, '-webkit-transform': sCSS });},
fStepSize: function(iTo, iFrom) { var iAnimDiff = (iFrom - iTo); if (iAnimDiff > 0) { iAnimDiff -= 360; } return iAnimDiff / this.iStepSize; },
fUpdate: function() { this.dtDate = new Date(); var iTemp = this.fGetHour(); if (this.iHourRotation != iTemp) { this.iHourRotation = iTemp; this.fRotate("clock_arrow_hour", iTemp); }iTemp = this.fGetMinute();if (this.iMinuteRotation != iTemp) { this.iMinuteRotation = iTemp; this.fRotate("clock_arrow_minute", iTemp); }if (this.iCurrSecond != this.dtDate.getSeconds()) { var iRotateFrom = (6 * this.iCurrSecond); this.iCurrSecond = this.dtDate.getSeconds(); var iRotateTo = (6 * this.iCurrSecond); var iDiff = this.fStepSize(iRotateTo, iRotateFrom); for (var i = 0; i < this.iStepSize; i++) { iRotateFrom -= iDiff; this.aSecond.push(Math.round(iRotateFrom));}}}
};
</script>