• User

    orologio analogico in javascript

    ciao a tutti,
    ho scaricato uno script di un orologio analogico in javascript,
    Ho sostituito l'immagine di sfondo con un'immagine + grande però ovviamnte ora le lacencette non sono centrate.
    L'immaggine precedente era di dimensioni 93x93 pixel quelloa che ho inserito io è di 160x160.
    Quali valori devo cambiare per modificare la centratura delle lacette?
    Grazie mille...a presto.

    var clipTop=0
    var clipBottom=clipTop+90
    var clipLeft
    var clipRight
    var isNS
    
    if (document.layers) { (isNS=true) }
    var HIDDEN = (isNS) ? 'hide' : 'hidden';
    var VISIBLE = (isNS) ? 'show' : 'visible';
    
    var imgSeconds
    var imgMinutes
    var imgHours
    var imgClock
    
    var clipHours=""
    var clipMinutes=""
    var clipSeconds=""
    
    var startLeft
    var startTop
    
    var tunePosHour=-2
    
    var plusHours=0
    
    var heute= new Date()
    
    function initObjects() {
    	if (document.all) {
    		imgSeconds = document.all.imgSeconds.style
    		imgMinutes = document.all.imgMinutes.style
    		imgHours = document.all.imgHours.style
    		imgClock = document.all.imgClock.style
    		
    		imgClock.posLeft=clockposLeft
    		imgClock.posTop=clockposTop
    		
    		startLeft=clockposLeft+2
    		startTop=clockposTop
    		
    		imgHours.posTop=startTop
    		imgMinutes.posTop=startTop
    		imgSeconds.posTop=startTop
    	
    		imgSeconds.visibility=VISIBLE
    		imgMinutes.visibility=VISIBLE
    		imgHours.visibility=VISIBLE
    		imgClock.visibility=VISIBLE
    	
    		tickIE()
    	}
    	
    	if (document.layers) {
    		imgSeconds = document.imgSeconds
    		imgMinutes = document.imgMinutes
    		imgHours = document.imgHours
    		imgClock = document.imgClock
    		document.textDate.document.write(datumzahl)
    		document.textDate.document.close()
    		
    		imgClock.left=clockposLeft
    		imgClock.top=clockposTop
    		
    		startLeft=clockposLeft+2
    		startTop=clockposTop
    		
    		imgHours.top=startTop
    		imgMinutes.top=startTop
    		imgSeconds.top=startTop
    	
    		document.textDate.top=clockposTop+40
    		document.textDate.left=clockposLeft+61
    		
    		imgSeconds.visibility=VISIBLE
    		imgMinutes.visibility=VISIBLE
    		imgHours.visibility=VISIBLE
    		imgClock.visibility=VISIBLE
    	
    		tickNS()
    	}
    }
    
    function tickIE() {
    	var now=new Date()
    	var nowHours=now.getHours()
    	var nowMinutes=now.getMinutes()
    	var nowSeconds=now.getSeconds()
    	if (nowHours>=12) {nowHours=nowHours-12}
    	if (nowMinutes<12) {plusHours=0}
    	if (nowMinutes>=12 && nowMinutes<24) {plusHours=90}
    	if (nowMinutes>=24 && nowMinutes<36) {plusHours=180}
    	if (nowMinutes>=36 && nowMinutes<48) {plusHours=270}
    	if (nowMinutes>=48) {var plusHours=360}
    	imgHours.posLeft=startLeft-(nowHours*90*5+plusHours)
    	clipLeft=nowHours*90*5+plusHours
    	clipRight=clipLeft+90
    	clipHours="rect("+clipTop+" "+clipRight+" "+clipBottom+" "+clipLeft+")"
    	imgHours.clip=clipHours	
    	if (nowSeconds!=0) {
    		imgMinutes.posLeft=startLeft-(nowMinutes*90)
    		clipLeft=nowMinutes*90
    		clipRight=clipLeft+90
    		clipMinutes="rect("+clipTop+" "+clipRight+" "+clipBottom+" "+clipLeft+")"
    		imgMinutes.clip=clipMinutes
    	}
    	imgSeconds.posLeft=startLeft-(nowSeconds*90)
    	clipLeft=nowSeconds*90
    	clipRight=clipLeft+90
    	clipSeconds="rect("+clipTop+" "+clipRight+" "+clipBottom+" "+clipLeft+")"
    	imgSeconds.clip=clipSeconds
    	var runClock=setTimeout("tickIE()", 100);
    }
    
    function tickNS() {
    	var now=new Date()
    	var nowHours=now.getHours()
    	var nowMinutes=now.getMinutes()
    	var nowSeconds=now.getSeconds()
    	if (nowHours >= 12) {nowHours=nowHours-12}
    	if (nowMinutes<12) {plusHours=0}
    	if (nowMinutes>=12 && nowMinutes<24) {plusHours=90}
    	if (nowMinutes>=24 && nowMinutes<36) {plusHours=180}
    	if (nowMinutes>=36 && nowMinutes<48) {plusHours=270}
    	if (nowMinutes>=48) {var plusHours=360}
    	imgHours.left=startLeft-(nowHours*90*5+plusHours)
    	clipLeft=nowHours*90*5+plusHours
    	clipRight=clipLeft+90
    	imgHours.clip.left=clipLeft
    	imgHours.clip.right=clipRight
    	imgHours.clip.top=clipTop
    	imgHours.clip.bottom=clipBottom
    	if (nowSeconds!=0) {
    		imgMinutes.left=startLeft-(nowMinutes*90)
    		clipLeft=nowMinutes*90
    		clipRight=clipLeft+90
    		imgMinutes.clip.left=clipLeft
    		imgMinutes.clip.right=clipRight
    		imgMinutes.clip.top=clipTop
    		imgMinutes.clip.bottom=clipBottom
    	}
    	imgSeconds.left=startLeft-(nowSeconds*90)
    	clipLeft=nowSeconds*90
    	clipRight=clipLeft+90
    	imgSeconds.clip.left=clipLeft
    	imgSeconds.clip.right=clipRight
    	imgSeconds.clip.top=clipTop
    	imgSeconds.clip.bottom=clipBottom
    
    	var runClock = setTimeout("tickNS()", 100);
    }
    
    if (document.all) {
    	document.write("<DIV ID='imgClock' STYLE='position:absolute;visibility:hidden'><img src='"+whichwatch+".bmp'></DIV>")
    	document.write("<DIV ID='imgSeconds' STYLE='position:absolute;visibility:hidden'><img src='secondi.gif'></DIV>")
    	document.write("<DIV ID='imgHours' STYLE='position:absolute;visibility:hidden'><img src='ore.gif'></DIV>")
    	document.write("<DIV ID='imgMinutes' STYLE='position:absolute;visibility:hidden'><img src='minuti.gif'></DIV>")
    	document.write("<DIV>&nbsp;</DIV>")
    	document.close()
    }
    
    if (document.all) {
    	window.onload=initObjects
    }