Class-based Javascript analog clock

var analogClock = function (divElem, index) { this.mainElem = divElem; this.index = index; var numStyles = Array(); numStyles["1"] = Array("1","2","3","4","5","6","7","8","9","10","11","12"); numStyles["i"] = Array("i","ii","iii","iv","v","vi","vii","viii","ix","x","xi","xii"); numStyles["I"] = Array("I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII"); numStyles["."] = Array("�","�","�","�","�","|","�","�","�","�","�","||"); this.position = analogClock.prototypes.position; numstyle = String(this.mainElem.getAttribute('numstyle')); if ("1I.".indexOf(numstyle.toUpperCase())==-1) numstyle="1"; var numstyle=numStyles[numstyle]; var radius = Math.floor(parseInt(this.mainElem.getAttribute('size'))/2); if (isNaN(radius)) radius=50; this.mainElem.style.width=radius*2; this.mainElem.style.height=radius*2; this.mainElem.style.position='relative'; this.mainElem.style.overflow='hidden'; this.mainElem.style.margin='0px'; this.mainElem.style.padding='0px'; //Create Hour labels this.hourLabels = Array(); for (var i=0; i=24) Hour-=12; while (Hour=12)?"PM":"AM"; this.AmPm.style.bottom=1.333*radius; this.AmPm.style.left=radius-parseInt(this.AmPm.offsetWidth)/2; this.AmPm.style.zIndex=-1; this.DoW.innerHTML=Week[Today.getDay()]; this.DoW.style.top=0.666*radius; this.DoW.style.left=radius-parseInt(this.DoW.offsetWidth)/2; this.DoW.style.zIndex=-1; this.City.innerHTML=this.mainElem.getAttribute('city'); this.City.style.bottom=0.666*radius; this.City.style.left=radius-parseInt(this.City.offsetWidth)/2; this.City.style.zIndex=-1; this.Country.innerHTML=this.mainElem.getAttribute('country'); this.Country.style.top=1.333*radius; this.Country.style.left=radius-parseInt(this.Country.offsetWidth)/2; this.Country.style.zIndex=-1; } analogClock.arClocks = new Array(); analogClock.replace = function () { var Divs = document.getElementsByTagName('div'); for (var i=0; i<divs i if analogclock settimeout function for var interval="Math.floor(50*Math.pow(analogClock.arClocks.length,1.5));" day today="new" date gmtadjust="-Today.getTimezoneOffset()/60;" lsm="new" lso="new">= lso) gmtAdjust -= 1; return gmtAdjust; } analogClock.needDST = function (a) { if ((a-5)) return 0; var day; var Today = new Date(); var dst=0; var lsm = new Date; var lso = new Date; lsm.setMonth(2); lsm.setDate(31); day = lsm.getDay(); lsm.setDate(31-day); lso.setMonth(9); lso.setDate(31); day = lso.getDay(); lso.setDate(31-day); if (Today &gt;= lsm || Today </divs>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值