Este curioso código te enseña un formulario que calcula el tiempo que llevas vivido y te enseña un reloj que da vueltas alrededor del cursor:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <META http-equiv=Content-Language content=es> <META http-equiv=Content-Type content="text/html; charset=windows-1252"> <META content="lb, default" name="Microsoft Border"> <META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD> <BODY text=#8f6030 vLink=#ae0000 aLink=#3333ff link=#cc6600 bgColor=#c0c0c0> <STYLE type=text/css></STYLE>
<META content="MSHTML 6.00.2800.1141" name=GENERATOR><TD valign="top"> <DIV> <P align=center><FONT face=Tahoma color=white> <FONT size=2><B><FONT size=6>Cálculo del tiempo vivido</FONT></B></FONT></FONT></P> <P align=center><FONT face=Tahoma color=green size=4><B>¿Quieres comprobar cuánto tiempo has vivido hasta ahora?</B></FONT></P> <P align=center><FONT face=Tahoma color=green size=4><B>Es divertido... y hace pensar</B></FONT></P> <P align=center> </P> <P align=center><FONT face=Tahoma color=yellow size=4><B>Ingresa la fecha de tu nacimiento...</B></FONT></P></DIV> <DIV><FONT color=#0000ff size=2> <CENTER><FONT face=Tahoma color=#8f6030><EM> <SCRIPT language=Javascript>
function start() { document.forms[0].day.value="" document.forms[0].month.value="" document.forms[0].year.value="" document.forms[0].age.value="" document.forms[0].months.value="" document.forms[0].weeks.value="" document.forms[0].answer.value="" document.forms[0].hours.value="" document.forms[0].min.value="" document.forms[0].sec.value="" document.forms[0].bday.value="" document.forms[0].milli.value="" }
function run() {
var ap; dd=document.forms[0].day.value mm=document.forms[0].month.value yy=document.forms[0].year.value
with(document.forms[0]) {
ap=parseInt(ampm.selectedIndex); hr=parseInt(hrs.value);
if(hr<=0 && hr>=13) { ap=null;alert("asdf") } }
main="válida"
if ((mm<1) || (mm>12) || (dd<1) || (dd>31) || (yy<1) ||(mm=="") || (dd=="") || (yy=="")) main="inválida" else if (((mm==4) || (mm==6) || (mm==9) || (mm==11)) && (dd>30)) main="inválida" else if (mm==2) { if (dd>29)main="inválida" else if((dd>28) && (!lyear(yy))) main="inválida" } else if((yy>9999)||(yy<0)) main="inválida" else main=main
if(main=="válida") {
function leapyear(a) { if(((a%4==0)&&(a%100!=0))||(a%400==0)) return true else return false }
days = new Date() gdate = days.getDate() gmonth = days.getMonth() gyear = days.getFullYear()
age=gyear-yy;
if((mm==(gmonth+1))&&(dd<=parseInt(gdate))) { age=age } else { if(mm<=(gmonth)) { age=age } else { age=age-1 } }
if(age==0) age=age
document.forms[0].age.value=" Tienes " + age + " años y"
if(mm<=(gmonth+1)) age=age-1 if((mm==(gmonth+1))&&(dd>parseInt(gdate))) age=age+1
var m=0; var n=0;
if (mm==12) { n=31-dd; } if (mm==11) { n=61-dd;} if (mm==10) { n=92-dd; } if (mm==9) { n=122-dd; } if (mm==8) { n=153-dd;} if (mm==7) { n=184-dd;} if (mm==6) { n=214-dd; } if (mm==5) { n=245-dd; } if (mm==4) { n=275-dd; } if (mm==3) { n=306-dd; } if (mm==2) { n=334-dd; if(leapyear(yy)) n=n+1 } if (mm==1) { n=365-dd; if (leapyear(yy)) n=n+1 }
if (gmonth==1) m=31 if (gmonth==2) { m=59 if (leapyear(gyear)) m=m+1; }
if (gmonth==3) { m=90; if (leapyear(gyear)) m=m+1; } if (gmonth==4) { m=120; if (leapyear(gyear)) m=m+1; } if (gmonth==5) { m=151 ; if (leapyear(gyear)) m=m+1; } if (gmonth==6) { m=181; if (leapyear(gyear)) m=m+1; } if (gmonth==7) { m=212 ; if (leapyear(gyear)) m=m+1; } if (gmonth==8) { m=243 ;if (leapyear(gyear)) m=m+1; } if (gmonth==9) { m=273; if (leapyear(gyear)) m=m+1; } if (gmonth==10) { m=304; if (leapyear(gyear)) m=m+1; } if (gmonth==11) { m=334; if (leapyear(gyear)) m=m+1; } if (gmonth==12) { m=365; if (leapyear(gyear)) m=m+1; }
totdays=(parseInt(age)*365) totdays+=age/4 totdays=parseInt(totdays)+gdate+m+n document.forms[0].answer.value="" + totdays +" dias "
// month
months=age*12 months+=12-parseInt(mm) months+=gmonth document.forms[0].months.value=months+" meses"
var p=0; //weeks if (gmonth==1) p=31+gdate
if (gmonth==2) { p=59+gdate if (leapyear(gyear)) m=m+1; }
if (gmonth==3) { p=90+gdate; if (leapyear(gyear)) p=p+1; } if (gmonth==4) { p=120+gdate; if (leapyear(gyear)) p=p+1; } if (gmonth==5) { p=151+gdate ; if (leapyear(gyear)) p=p+1; } if (gmonth==6) { p=181+gdate; if (leapyear(gyear)) p=p+1; } if (gmonth==7) { p=212+gdate ; if (leapyear(gyear)) p=p+1; } if (gmonth==8) { p=243+gdate ;if (leapyear(gyear)) p=p+1; } if (gmonth==9) { p=273+gdate; if (leapyear(gyear)) p=p+1; } if (gmonth==10) { p=304+gdate; if (leapyear(gyear)) p=p+1; } if (gmonth==11) { p=334+gdate; if (leapyear(gyear)) p=p+1; } if (gmonth==12) { p=365+gdate; if (leapyear(gyear)) p=p+1; }
weeks=totdays/7 weeks+=" semanas" weeks=parseInt(weeks); document.forms[0].weeks.value=weeks+" semanas"
// hours var time=new Date() ghour=time.getHours() gmin=time.getMinutes() gsec=time.getSeconds()
hour=((age*365)+n+p)*24 hour+=(parseInt(age/4)*24)
if(ap==0){ hour=hour-hr }else{ if(ap==1){ hour=hour-(11+hr) } }
document.forms[0].hours.value=hour+" horas"
var min //minutes min=(hour*60)+gmin document.forms[0].min.value=min+" minutos" sec=(min*60)+gsec document.forms[0].sec.value=sec+" segundos" var millisec; var gmil;
gmil = days.getMilliseconds(); millisec=(sec*1000)+gmil; document.forms[0].milli.value=millisec+" milisegundos"; mm=mm-1 var r
if(mm==0) r=1 if (mm==1) r=31 if (mm==2) { r=59 if (leapyear(gyear)) m=m+1; }
if (mm==3) { r=90; if (leapyear(gyear)) r=r+1; } if (mm==4) { r=120; if (leapyear(gyear)) r=r+1; } if (mm==5) { r=151 ; if (leapyear(gyear)) r=r+1; } if (mm==6) { r=181; if (leapyear(gyear)) r=r+1; } if (mm==7) { r=212 ; if (leapyear(gyear)) r=r+1; } if (mm==8) { r=243 ;if (leapyear(gyear)) r=r+1; } if (mm==9) { r=273; if (leapyear(gyear)) r=r+1; } if (mm==10) { r=304; if (leapyear(gyear)) r=r+1; } if (mm==11) { r=334; if (leapyear(gyear)) r=r+1; } if (mm==12) { r=365; if (leapyear(gyear)) r=r+1; }
mm=mm+1; r=parseInt(r)+parseInt(dd);
if(mm>(gmonth+1)){ bday=r-m-gdate } else { if(mm==(gmonth+1)&&(gdate<dd)){ bday=(r-m-gdate) } else { if((leapyear(gyear))&&((mm>2)&&(dd<29))) { a=366 } else { a=365 } bday=a+(r-m-gdate) } }
nhour=24-parseInt(ghour) nmin=60-parseInt(gmin) nsec=60-parseInt(gsec)
function lyear(a) { if(((a%4==0) && (a%100!=0)) || (a%400==0)) return true; else return false; }
mm=parseInt(mm) dd=parseInt(dd) yy=parseInt(yy)
if ((mm<1) || (mm>12) || (dd<1) || (dd>31) || (yy<1) ||(mm==" ") || (dd==" ") || (yy==" ")) main="inválida" else if (((mm==4) || (mm==6) || (mm==9) || (mm==11)) && (dd>30)) main="inválida" else if (mm==2) { if (dd>29) main="inválida" else if((dd>28) && (!lyear(yy))) main="inválida" } else main=main
if(main=="válida") { var m if (mm==1) n=31+1 if (mm==2) n=59+1 if (mm==3) n=90+1 if (mm==4) n=120+1 if (mm==5) n=151+1 if (mm==6) n=181+1 if (mm==7) n=212+1 if (mm==8) n=243+1 if (mm==9) n=273+1 if (mm==10) n=304+1 if (mm==11) n=334+1 if (mm==12) n=365+1
if((mm==1)||(mm==3)||(mm==5)||(mm==7)||(mm==8)||(mm==10)||(mm==12)) n+=31+dd else if((mm==4)||(mm==6)||(mm==9)||(mm==11)) n+=31+dd+1 else if(mm==2) { if(lyear(yy)) n+=29+dd-3 else if(!lyear(yy)) n+=28+dd-1 }
fours = yy/4 hunds = yy/100 fhunds = yy/400 var iDay
iDay=(yy + n + fours - hunds + fhunds) % 7; iDay=parseInt(iDay)
switch(iDay) { case 1 : document.forms[0].age.value +=" naciste un domingo" ; break case 2 : document.forms[0].age.value +=" naciste en lunes" ; break case 3 : document.forms[0].age.value +=" naciste en martes" ; break case 4 : document.forms[0].age.value +=" naciste en miércoles" ; break case 5 : document.forms[0].age.value +=" naciste en jueves" ; break case 6 : document.forms[0].age.value +=" naciste en viernes" ; break case 7 : document.forms[0].age.value +=" naciste en sábado" ; break case 0 : document.forms[0].age.value +=" naciste en sábado" ; break }
} else {
document.forms[0].age.value +="Fecha "+main }
if(((bday==366)&&(leapyear(yy)))||((bday==365)&&(!leapyear(yy)))) { document.forms[0].bday.value="¡Hoy es tu cumpleaños!" alert("Feliz Aniversario!") } else { document.forms[0].bday.value=bday+" días "+ nhour+" horas "+nmin+" minutos "+nsec+" segundos" setTimeout("run()",1) }
} else {
document.forms[0].age.value="Fecha "+main document.forms[0].months.value="" document.forms[0].weeks.value="" document.forms[0].answer.value="" document.forms[0].hours.value="" document.forms[0].min.value="" document.forms[0].sec.value="" document.forms[0].bday.value="" document.forms[0].milli.value="" }
}
</SCRIPT> </EM></FONT><EM><FONT face=Tahoma></FONT></EM> <FORM> <H1><EM><FONT face=Tahoma><FONT color=#8f6030 size=3><FONT color=#8f6030>Día: <INPUT size=3 name=day> <FONT color=#8f6030>Mes: <INPUT size=3 name=month> <FONT color=#8f6030>Año: <INPUT size=6 name=year> <FONT color=#8f6030>Hora: <INPUT size=6 value=00 name=hrs> <SELECT size=1 name=ampm> <OPTION selected>AM</OPTION> <OPTION>PM</OPTION></SELECT> </FONT></FONT></FONT></FONT></FONT></FONT></EM></H1><FONT color=#8f6030 size=3><FONT color=#8f6030><FONT color=#8f6030><FONT color=#8f6030><FONT color=#8f6030> <P><EM><FONT face=Tahoma><INPUT onclick=run() type=button value="Calcular " name=start> </FONT></EM></P></FONT> <P><EM><FONT face=Tahoma color=#8f6030><INPUT style="WIDTH: 339px; HEIGHT: 21px" size=55 value="tu edad va a aparecer aquí" name=age> </FONT></EM></P> <CENTER> <H1><EM><FONT face=Tahoma color=#8f6030 size=4>Llevas vivido todo este tiempo...</FONT></EM></H1></CENTER> <H1><EM><FONT face=Tahoma color=#8f6030 size=4>En meses: <INPUT size=30 name=months> </FONT></EM></H1> <H1> <P> <CENTER><EM><FONT face=Tahoma color=#8f6030 size=4>En semanas: <INPUT size=30 name=weeks> </FONT></EM></CENTER> <P> <CENTER><EM><FONT face=Tahoma color=#8f6030 size=4>En días: <INPUT size=30 name=answer> </FONT></EM></CENTER> <P> <CENTER><EM><FONT face=Tahoma color=#8f6030 size=4>En horas: <INPUT size=30 name=hours> </FONT></EM></CENTER> <P> <CENTER><EM><FONT face=Tahoma color=#8f6030 size=4>En minutos: <INPUT size=30 name=min> </FONT></EM></CENTER> <P> <CENTER><EM><FONT face=Tahoma color=#8f6030 size=4>En segundos: <INPUT size=30 name=sec> </FONT></EM></CENTER> <P> <CENTER><EM><FONT face=Tahoma color=#8f6030 size=4>En milisegundos: <INPUT size=30 name=milli> </FONT></EM></CENTER> <P> <CENTER><EM><FONT face=Tahoma color=red size=4>¡¡Esto es lo que te queda de vida!!</FONT> </EM></CENTER><EM><FONT face=Tahoma><INPUT style="LEFT: 227px; WIDTH: 253px; TOP: 378px; HEIGHT: 22px" size=35 name=bday> </FONT></EM></H1></FONT></FONT></FONT></FONT> <BLOCKQUOTE><EM><FONT face=Tahoma><FONT color=#8f6030 size=3><FONT color=#8f6030><FONT color=#8f6030><FONT color=#8f6030></FONT></FONT></FONT></FONT></FONT></EM></FORM><EM><FONT face=Tahoma color=#8f6030 size=3></BLOCKQUOTE></FONT></EM></CENTER></FONT></DIV> <CENTER><EM><FONT face=Tahoma color=yellow size=4>Ja, ja, ja, ......................era una broma, es lo que falta para tu cumpleaños!!!! <DIV align=center><BR><BR> <P><FONT face=Tahoma> </FONT><FONT face="Tahoma black" color=green size=3><B><FONT size=3>Amigos y amigas, aprovechen cada segundo de vida como si fuese el último: amando, siendo solidarios, compartiendo afectos y emociones con los demás, construyendo hacia dentro y hacia fuera de nosotros mismos.<BR><BR>Nuestra vida vale lo que <I>pesan</I> nuestras conductas, pero se mide por el reloj que marca el ritmo y el paso de nuestros días... que espero y deseo que sean muchos, provechosos y felices.<BR><BR> <CENTER><EM><FONT face="Courier black" color=red size=3>"Quien mata el tiempo no es un asesino, es un suicida"</FONT></B></FONT> <P></P><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR> <CENTER><EM><FONT face="Tahoma black" color=yellow size=4>Modificado por cheo5857 <P> </P></DIV> <DIV></DIV></TD></TR></TABLE> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD></SCRIPT></TD></TR></TBODY></TABLE><!-- saved from url=(0022)http://internet.e-mail --><!-- saved from url=(0087)file://C:\WINDOWS\Archivos%20temporales%20de%20Internet\Content.IE5\WP2RO5MV\Clock.html --><!-- saved from url=(0022)http://internet.e-mail --><!-- saved from url=(0022)http://internet.e-mail --> <META content="MSHTML 6.00.2600.0" name=GENERATOR> <SCRIPT language=JavaScript>
dCol='yellow';//date colour. fCol='red';//face colour. sCol='black';//seconds colour. mCol='blue';//minutes colour. hCol='white';//hours colour. ClockHeight=100; ClockWidth=100; ClockFromMouseY=105; ClockFromMouseX=0;
//Alter nothing below! Alignments will be lost!
d=new Array(". Domingo",". Lunes",". Martes",". Miércoles",". Jueves",". Viernes",". Sábado"); m=new Array("de Enero del","de Febrero del","de Marzo del","de Abril del","de Mayo del","de Junio del","de Julio","de Agosto del","de Septiembre del","de Octubre del","de Noviembre del","de Diciembre del"); 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=2; speed=0.2; 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=3; HandX=0; scrll=0; step=0.04; currStep=0; y=new Array();x=new Array();Y=new Array();X=new Array(); for (i=0; i < n; i++){y=0;x=0;Y=0;X=0} Dy=new Array();Dx=new Array();DY=new Array();DX=new Array(); for (i=0; i < D.length; i++){Dy=0;Dx=0;DY=0;DX=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+'</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+'</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=Arial size=3 color='+sCol+'><center><b>'+S+'</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=Arial size=3 color='+mCol+'><center><b>'+M+'</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=Arial size=3 color='+hCol+'><center><b>'+H+'</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+'</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+'</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:Arial;font-size:16px;color:'+hCol+';text-align:center;font-weight:bold">'+H+'</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:Arial;font-size:16px;color:'+mCol+';text-align:center;font-weight:bold">'+M+'</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:Arial;font-size:16px;color:'+sCol+';text-align:center;font-weight:bold">'+S+'</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.style; F.top=y + ClockHeight*Math.sin(-1.0471 + i*Split*Math.PI/180)+scrll; F.left=x + 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.style; HL.top=y+HandY+(i*HandHeight)*Math.sin(hrs)+scrll; HL.left=x+HandX+(i*HandWidth)*Math.cos(hrs); } for (i=0; i < M.length; i++){ var ML=(ns)?document.layers['nsMinutes'+i]:ieMinutes.style; ML.top=y+HandY+(i*HandHeight)*Math.sin(min)+scrll; ML.left=x+HandX+(i*HandWidth)*Math.cos(min); } for (i=0; i < S.length; i++){ var SL=(ns)?document.layers['nsSeconds'+i]:ieSeconds.style; SL.top=y+HandY+(i*HandHeight)*Math.sin(sec)+scrll; SL.left=x+HandX+(i*HandWidth)*Math.cos(sec); } for (i=0; i < D.length; i++){ var DL=(ns)?document.layers['nsDate'+i]:ieDate.style; DL.top=Dy + ClockHeight*1.5*Math.sin(currStep+i*Dsplit*Math.PI/180)+scrll; DL.left=Dx + 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=Math.round(DY+=(Dy[i-1]-DY)*speed); Dx=Math.round(DX+=(Dx[i-1]-DX)*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=Math.round(Y+=(y[i-1]-Y)*speed); x=Math.round(X+=(x[i-1]-X)*speed); } ClockAndAssign(); setTimeout('Delay()',20); } if (ns||ie)window.onload=Delay; </SCRIPT> ................... </FONT></EM></CENTER></EM></CENTER></FONT></FONT></EM></CENTER></BODY></HTML>
|