ďťż

JavaScript: Zegar

       

Podstrony


telcocafe

Dało by się ten skrypt jakoś tak przerobić, żeby nie latał za myszą, tylko stał w jednym określonym miejscu
dCol='#454545';//date colour. fCol='#006633';//face colour. sCol='#660099';//seconds colour. mCol='#DF0000';//minutes colour. hCol='#3371EE';//hours colour. ClockHeight=30; ClockWidth=30; ClockFromMouseY=0; ClockFromMouseX=140; //Alter nothing below! Alignments will be lost! d=new Array("Niedziela","Poniedziałek","Wtorek","Środa","Czwartek" ,"Piątek","Sobota"); m=new Array("Stycznia","Lutego","Marca","Kwietnia","Maja" ,"Czerwca","Lipca","Sierpnia","Wrzesinia","Października" ,"Listopada","Grudnia"); date=new Date(); day=date.getDate(); year=date.getYear(); if (year< 2000) year=year+1900; TodaysDate=" "+d[date.getDay()]+" "+day+" "+m[date.getMonth()]+" "+year; D=TodaysDate.split(''); H='...'; H=H.split(''); M='....'; M=M.split(''); S='.....'; S=S.split(''); Face='1 2 3 4 5 6 7 8 9 10 11 12'; font='Tahoma'; size=1; speed=0.6; ns=(document.layers); ie=(document.all); Face=Face.split(' '); n=Face.length; a=size*10; ymouse=0; xmouse=0; scrll=0; props="<font face="+font+" size="+size+" color="+fCol+"><B>"; props2="<font face="+font+" size="+size+" color="+dCol+"><B>"; Split=360/n; Dsplit=360/D.length; HandHeight=ClockHeight/4.5 HandWidth=ClockWidth/4.5 HandY=-7; HandX=-2.5; scrll=0; step=0.06; currStep=0; y=new Array();x=new Array();Y=new Array();X=new Array(); for (i=0; i< n; i++){y[i]=0;x[i]=0;Y[i]=0;X[i]=0} Dy=new Array();Dx=new Array();DY=new Array();DX=new Array(); for (i=0; i< D.length; i++){Dy[i]=0;Dx[i]=0;DY[i]=0;DX[i]=0} if (ns){ for (i=0; i< D.length; i++) document.write('<layer name="nsDate'+i+'" top= 0 left=0 height='+a+' width='+a+'><center>'+props2+D[i]+'</font></center></ layer>'); for (i=0; i< n; i++) document.write('<layer name="nsFace'+i+'" top=0 left=0 height='+a+' width='+a+'><center>'+props+Face[i]+'</font></center>< /layer>'); for (i=0; i< S.length; i++) document.write('<layer name=nsSeconds'+i+' top=0 left=0 width=15 height=15><font face=Verdana size=3 color='+sCol+'><center><b>'+S[i]+'</b></center>< /font></layer>'); for (i=0; i< M.length; i++) document.write('<layer name=nsMinutes'+i+' top=0 left=0 width=15 height=15><font face=Verdana size=3 color='+mCol+'><center><b>'+M[i]+'</b></center>< /font></layer>'); for (i=0; i< H.length; i++) document.write('<layer name=nsHours'+i+' top=0 left=0 width=15 height=15><font face=Verdana size=3 color='+hCol+'><center><b>'+H[i]+'</b></center>< /font></layer>'); } if (ie){ document.write('<div id="Od" style="position:absolute;top:0px;left:0px"><div style="position:relative">'); for (i=0; i< D.length; i++) document.write('<div id="ieDate" style="position:absolute;top:0px;left:0;height:'+a+';width:'+a+';text-align:center" >'+props2+D[i]+'</B></font></div>'); document.write('</div></div>'); document.write('<div id="Of" style="position:absolute;top:0px;left:0px"><div style="position:relative">'); for (i=0; i< n; i++) document.write('<div id="ieFace" style="position:absolute;top:0px;left:0;height:'+a+';width:'+a+';text-align:center" >'+props+Face[i]+'</B></font></div>'); document.write('</div></div>'); document.write('<div id="Oh" style="position:absolute;top:0px;left:0px"><div style="position:relative">'); for (i=0; i< H.length; i++) document.write('<div id="ieHours" style="position:absolute;width:16px;height:16px;font-family:Verdana;font-size:16px;color:'+hCol+' ;text-align:center;font-weight:bold">'+H[i]+'</div>'); document.write('</div></div>'); document.write('<div id="Om" style="position:absolute;top:0px;left:0px"><div style="position:relative">'); for (i=0; i< M.length; i++) document.write('<div id="ieMinutes" style="position:absolute;width:16px;height:16px;font-family:Verdana;font-size:16px;color:'+mCol+' ;text-align:center;font-weight:bold">'+M[i]+'</div>'); document.write('</div></div>') document.write('<div id="Os" style="position:absolute;top:0px;left:0px"><div style="position:relative">'); for (i=0; i< S.length; i++) document.write('<div id="ieSeconds" style="position:absolute;width:16px;height:16px;font-family:Verdana;font-size:16px;color:'+sCol+' ;text-align:center;font-weight:bold">'+S[i]+'</div>'); document.write('</div></div>') } (ns)?window.captureEvents(Event.MOUSEMOVE):0; function Mouse(evnt){ ymouse = (ns)?evnt.pageY+ClockFromMouseY-(window.pageYOffset):event.y+ClockFromMouseY; xmouse = (ns)?evnt.pageX+ClockFromMouseX:event.x+ClockFromMouseX; } (ns)?window.onmousemove=Mouse:document.onmousemove=Mouse; function ClockAndAssign(){ time = new Date (); secs = time.getSeconds(); sec = -1.57 + Math.PI * secs/30; mins = time.getMinutes(); min = -1.57 + Math.PI * mins/30; hr = time.getHours(); hrs = -1.575 + Math.PI * hr/6+Math.PI*parseInt(time.getMinutes())/360; if (ie){ Od.style.top=window.document.body.scrollTop; Of.style.top=window.document.body.scrollTop; Oh.style.top=window.document.body.scrollTop; Om.style.top=window.document.body.scrollTop; Os.style.top=window.document.body.scrollTop; } for (i=0; i< n; i++){ var F=(ns)?document.layers['nsFace'+i]:ieFace[i].style; F.top=y[i] + ClockHeight*Math.sin(-1.0471 + i*Split*Math.PI/180)+scrll; F.left=x[i] + ClockWidth*Math.cos(-1.0471 + i*Split*Math.PI/180); } for (i=0; i< H.length; i++){ var HL=(ns)?document.layers['nsHours'+i]:ieHours[i].style; HL.top=y[i]+HandY+(i*HandHeight)*Math.sin(hrs)+scrll; HL.left=x[i]+HandX+(i*HandWidth)*Math.cos(hrs); } for (i=0; i< M.length; i++){ var ML=(ns)?document.layers['nsMinutes'+i]:ieMinutes[i].style; ML.top=y[i]+HandY+(i*HandHeight)*Math.sin(min)+scrll; ML.left=x[i]+HandX+(i*HandWidth)*Math.cos(min); } for (i=0; i< S.length; i++){ var SL=(ns)?document.layers['nsSeconds'+i]:ieSeconds[i].style; SL.top=y[i]+HandY+(i*HandHeight)*Math.sin(sec)+scrll; SL.left=x[i]+HandX+(i*HandWidth)*Math.cos(sec); } for (i=0; i< D.length; i++){ var DL=(ns)?document.layers['nsDate'+i]:ieDate[i].style; DL.top=Dy[i] + ClockHeight*1.5*Math.sin(currStep+i*Dsplit*Math.PI/180)+scrll; DL.left=Dx[i] + ClockWidth*1.5*Math.cos(currStep+i*Dsplit*Math.PI/180); } currStep-=step; } function Delay(){ scrll=(ns)?window.pageYOffset:0;Dy[0]=Math.round(DY[0]+=((ymouse)-DY[0])*speed); Dx[0]=Math.round(DX[0]+=((xmouse)-DX[0])*speed); for (i=1; i< D.length; i++){ Dy[i]=Math.round(DY[i]+=(Dy[i-1]-DY[i])*speed); Dx[i]=Math.round(DX[i]+=(Dx[i-1]-DX[i])*speed); } y[0]=Math.round(Y[0]+=((ymouse)-Y[0])*speed); x[0]=Math.round(X[0]+=((xmouse)-X[0])*speed); for (i=1; i< n; i++){ y[i]=Math.round(Y[i]+=(y[i-1]-Y[i])*speed); x[i]=Math.round(X[i]+=(x[i-1]-X[i])*speed); } ClockAndAssign(); setTimeout('Delay()',20); } if (ns||ie)window.onload=Delay;

// Używaj [ code ] (ew. [ codebox] )
Użytkownik _Herkules_ edytował ten post 13 czerwiec 2005, 18:35


Bo jeżeli tak to ten skrypt powinien być:
<script language="javascript"> <!--W3e Javascript Preset var timerID = null; var timerRunning = false; function stopclock() { if(timerRunning) clearTimeout(timerID) timerRunning = false; } function startclock() { stopclock(); showtime(); } function showtime() { var now = new Date(); var hours = now.getHours(); var minutes = now.getMinutes(); var seconds = now.getSeconds(); var timeValue = "" + ((hours > 12) ? hours - 12 : hours); timeValue += ((minutes < 10) ? ":0" : ":") + minutes; timeValue += ((seconds < 10) ? ":0" : ":") + seconds; timeValue += (hours >= 12) ? " P.M." : " A.M."; document.clock.face.value = timeValue; timerID = setTimeout("showtime()",1000); timerRunning = true; } //--> </script> <form name="clock" onsubmit="0"> <input type="text" name="face" size="24"> </form> <script>startclock();</script>

// Używaj [ code ] (ew. [ codebox] )
Użytkownik _Herkules_ edytował ten post 13 czerwiec 2005, 18:35
Boże człowieku, taki skrypt to i ja sam potrafię zrobić ew. ściągnąć. Chodzi mi o to, żeby przerobić aby nie latał za kursorem, tylko był w jednym miejscu. Czy to takie trudne do zrozumienia?
Użytkownik dodek edytował ten post 14 czerwiec 2005, 11:57

Boże człowieku, taki skrypt to i ja sam potrafię zrobić ew. ściągnąć. Chodzi mi o to, żeby przerobić aby nie latał za kursorem, tylko był w jednym miejscu. Czy to takie trudne do zrozumienia?



Przerobić tego kodu nie umiem, ale daję Ci inny kod na zegar.
Może Ci się spodoba.

HEAD
<script LANGUAGE="VBScript"> Dim a Dim min1 Dim hr1 Dim sec1 'Initializes clock and tells it how to behave, when to start animation, etc Sub window_onload a = time theTimeDate.innerText = now sec1 = second(a) min1 = minute(a) hr1 = hour(a) if hr1 > 12 then hr1 = hr1 - 12 end if call sgSecondHand.Rotate(0,0,sec1*6 - 90) call sgMinuteHand.Rotate(0,0,min1*6 - 90) call sgHourHand.Rotate(0,0,hr1*360/12 - 90) call sgHourHand.Rotate(0,0,int(min1/2)) call seq("Time").Play end Sub 'Sequencer initilization Sub Seq_OnInit Call seq("Time").at(1.000, "SecRot", -1,1.000, 1) End Sub 'rotates second hand of clock Sub SecRot theTimeDate.innerText = now a = time sec1 = second(a) min1 = minute(a) hr1 = hour(a) if hr1 > 12 then hr1 = hr1 - 12 end if Call sgSecondHand.Rotate(0,0,6) if sec1 = 0 then Call sgMinuteHand.Rotate(0,0,6) if min1 mod 2 = 0 then call sgHourHand.Rotate(0,0,1) end if end if End Sub </SCRIPT>

BODY
<DIV ID = "MASTERLAYOUT" STYLE="POSITION:relative;WIDTH:300; HEIGHT:260;TOP:0;LEFT:10"> <DIV STYLE="POSITION:ABSOLUTE; HEIGHT:60; WIDTH:200; TOP:230; left:50"> <CENTER><P id=theTimeDate></P></CENTER></DIV> <DIV ID="divTimeText" STYLE="POSITION:ABSOLUTE; WIDTH:202; HEIGHT:202; TOP:0; LEFT:0;z-index:2"> <OBJECT ID="SgNumbers" CLASSID = "CLSID:369303C2-D7AC-11D0-89D5-00A0C90833E6" STYLE= "POSITION:ABSOLUTE; WIDTH:200; HEIGHT:200; TOP:10; LEFT:50; Z-INDEX:5"> <PARAM NAME="Line0001" VALUE="SetLineColor(0,80,0)"> <PARAM NAME="Line0002" VALUE="SetLineStyle(1)"> <PARAM NAME="Line0003" VALUE="SetFillStyle(1)"> <PARAM NAME="Line0004" VALUE="SetFillColor(0,80,0)"> <PARAM NAME="Line0005" VALUE="SetFont('ARIAL',24,650,0,0,0)"> <PARAM NAME="Line0006" VALUE="Text('.',40,-72,0"> <PARAM NAME="Line0007" VALUE="Text('.',70,-42,0"> <PARAM NAME="Line0008" VALUE="Text('3',80,7,0"> <PARAM NAME="Line0009" VALUE="Text('.',70,45,0"> <PARAM NAME="Line0010" VALUE="Text('.',40,76,0"> <PARAM NAME="Line0011" VALUE="Text('6',-8,90,0"> <PARAM NAME="Line0012" VALUE="Text('.',-47,76,0"> <PARAM NAME="Line0013" VALUE="Text('.',-77,45,0"> <PARAM NAME="Line0014" VALUE="Text('9',-92,7,0"> <PARAM NAME="Line0015" VALUE="Text('.',-77,-42,0"> <PARAM NAME="Line0016" VALUE="Text('.',-47,-72,0"> <PARAM NAME="Line0017" VALUE="Text('12',-14,-76,0"> </OBJECT></DIV> <OBJECT ID="sgBackground" CLASSID = "CLSID:369303C2-D7AC-11D0-89D5-00A0C90833E6" STYLE="POSITION:absolute; TOP:10; LEFT:50; WIDTH:200; HEIGHT:200"> <PARAM NAME="Line0001" VALUE="SetLineColor(100,100,100)"> <PARAM NAME="Line0001" VALUE="SetLineStyle(5)"> <PARAM NAME="Line0002" VALUE="SetFillStyle(1)"> <PARAM NAME="Line0003" VALUE="SetFillColor(0,0,0)"> <PARAM NAME="Line0004" VALUE="SetGradientFill(0,0,-100,-100,0)"> <PARAM NAME="Line0005" VALUE="Oval(-100,-100,199,199,0)"> </OBJECT> <DIV ID="divClock" STYLE="POSITION:ABSOLUTE; WIDTH:200; HEIGHT:200; TOP:0; LEFT:0;"> <OBJECT ID="sgSecondHand" CLASSID = "CLSID:369303C2-D7AC-11D0-89D5-00A0C90833E6" STYLE="POSITION:absolute; TOP:10; LEFT:50; WIDTH:200; HEIGHT:200; Z-INDEX:5"> <PARAM NAME="Line0001" VALUE="SetLineColor(18, 178, 4)"> <PARAM NAME="Line0002" VALUE="SetLineStyle(1)"> <PARAM NAME="Line0003" VALUE="SetFillColor(0,0,0)"> <PARAM NAME="Line0004" VALUE="SetFillStyle(1)"> <PARAM NAME="Line0005" VALUE="Rect(0,0,95,0,0)"> </OBJECT> <OBJECT ID="sgMinuteHand" CLASSID = "CLSID:369303C2-D7AC-11D0-89D5-00A0C90833E6" STYLE="POSITION:absolute; TOP:10; LEFT:50; WIDTH:200; HEIGHT:200; Z-INDEX:5"> <PARAM NAME="Line0001" VALUE="SetLineColor(0,90,0)"> <PARAM NAME="Line0002" VALUE="SetLineStyle(1)"> <PARAM NAME="Line0003" VALUE="SetFillColor(0,90,0)"> <PARAM NAME="Line0004" VALUE="SetFillStyle(1)"> <PARAM NAME="Line0005" VALUE="Rect(0,-1,85,1,0)"> </OBJECT> <OBJECT ID="sgHourHand" CLASSID = "CLSID:369303C2-D7AC-11D0-89D5-00A0C90833E6" STYLE="POSITION:ABSOLUTE; TOP:10; LEFT:50; WIDTH:200; HEIGHT:200; Z-INDEX:5"> <PARAM NAME="Line0001" VALUE="SetLineColor(0,90,0)"> <PARAM NAME="Line0002" VALUE="SetLineStyle(1)"> <PARAM NAME="Line0003" VALUE="SetFillColor(0,90,0)"> <PARAM NAME="Line0004" VALUE="SetFillStyle(1)"> <PARAM NAME="Line0005" VALUE="Rect(0,-2,70,2,0)"> </OBJECT></DIV></DIV> <OBJECT ID="Seq" CLASSID="CLSID:B0A6BAE2-AAF0-11d0-A152-00A0C908DB96"> </OBJECT>

sauron, po co mi taki zegarek v vbscripcie, skoro opera i firefox mają wyłączoną obsługę vbscriptu, a ten skrypt, który znalazłem działa na wszystkich.

No to sobie ściągnij zegarek który ci ie będzie latał za myszką. Proste Nie
Skoro tak mówisz, to znajdź mi równie ładny zegarek, który nie będzie latał za myszką. Nie sądzę... B)
Użytkownik dodek edytował ten post 15 czerwiec 2005, 07:53
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • nvm.keep.pl

  • Sitedesign by AltusUmbrae.