home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magazyn WWW 1999 July
/
www_07_1999.iso
/
prez
/
amiga
/
KidHTML1_25.lha
/
KidHTML1.25
/
Script
/
agecounter.js
next >
Wrap
Text File
|
1998-08-25
|
5KB
|
354 lines
<!-- TWO STEPS TO INSTALL AGECOUNTER:
1. Paste the coding into the HEAD of your HTML document
2. Put the last coding into the BODY of your HTML document -->
<!-- STEP ONE: Copy this code into the HEAD of your HTML document -->
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available online from -->
<!-- The JavaScript Source!! http://javascriptsource.com -->
<!-- Begin
var acc=0
var show_time=false;
var timerID=null;
var blank=":";
function stop() {
if (show_time)
clearTimeout(timerID);
show_time=false;
}
function start(form) {
var today=new Date();
var acc1=acc;
var display_value =" Time: " + today.getHours()
if (today.getMinutes() < 10) {
display_value+=":0" + today.getMinutes();
}
else {
display_value+=":" + today.getMinutes();
}
if (today.getSeconds() < 10){
display_value+=":0" + today.getSeconds();
}
else {
display_value+=":" + today.getSeconds();
}
if
(today.getHours()>=12) {
display_value+=" P.M. "
}
else {
display_value+=" A.M. "
}
display_value += " Date: "
+ (today.getMonth()+1) + "/"
+ today.getDate() + "/" + today.getYear();
window.status=display_value;
writeyourAge(acc1)
timerID=setTimeout("start()",100);
show_time=true;
}
function writeyourAge(onval) {
if (onval == 0) {
normal()
} else {
accurate()
}
}
function normal() {
TheDate = new Date();
Month = TheDate.getMonth();
Day = TheDate.getDate();
Year = TheDate.getYear();
Hour = TheDate.getHours();
Minute = TheDate.getMinutes();
Second = TheDate.getSeconds();
by = (document.my_age.birthy.value);
bm = (document.my_age.birthm.value);
bd = (document.my_age.birthd.value);
bh = (document.my_age.birthh.value);
bmn = (document.my_age.birthmin.value);
bs = (document.my_age.births.value);
BDate = Date.UTC(by,bm,bd,bh,bmn,bs);
if (Year<2000) {
CDate = Date.UTC(Year,Month,Day,Hour,Minute,Second);
} else {
CDate = Date.UTC(Year,Month,Day,Hour,Minute,Second);
}
Age = CDate-BDate;
document.my_age.yrs.value = parseInt(((((Age/1000)/60)/60)/24)/365.25,10);
document.my_age.dys.value = parseInt((((Age/1000)/60)/60)/24,10);
document.my_age.hrs.value = parseInt(((Age/1000)/60)/60,10);
document.my_age.mins.value = parseInt((Age/1000)/60,10);
document.my_age.secs.value = parseInt(Age/1000,10);
}
function accurate() {
TheDate = new Date();
Month = TheDate.getMonth();
Day = TheDate.getDate();
Year = TheDate.getYear();
Hour = TheDate.getHours();
Minute = TheDate.getMinutes();
Second = TheDate.getSeconds();
by = (document.my_age.birthy.value);
bm = (document.my_age.birthm.value);
bd = (document.my_age.birthd.value);
bh = (document.my_age.birthh.value);
bmn = (document.my_age.birthmin.value);
bs = (document.my_age.births.value);
BDate = Date.UTC(by,bm,bd,bh,bmn,bs);
if (Year<2000) {
CDate = Date.UTC(Year,Month,Day,Hour,Minute,Second);
} else {
CDate = Date.UTC(Year,Month,Day,Hour,Minute,Second);
}
Age = CDate-BDate;
document.my_age.yrs.value = ((((Age/1000)/60)/60)/24)/365.25;
document.my_age.dys.value = (((Age/1000)/60)/60)/24;
document.my_age.hrs.value = ((Age/1000)/60)/60;
document.my_age.mins.value = (Age/1000)/60;
document.my_age.secs.value = Age/1000;
}
// End -->
</SCRIPT>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<BODY>
<form name="my_age">
<table width=460 border=0 cellspacing=0 cellpadding=2>
<tr>
<td align=center colspan=5>D.O.Báá
Yr<input name="birthy" type="text" size=2>áá
Mon<input name="birthm" type="text" size=2>áá
Day<input name="birthd" type="text" size=2>áá
Hr<input name="birthh" type="text" size=2>áá
Min<input name="birthmin" type="text" size=2>áá
Sec<input name="births" type="text" size=2>áá
</td>
</tr>
<tr>
<td align=center colspan=5>
Accurate<input type="radio" name="accurate" value="ON" onClick="if (this.checked) {acc=1}">
Normal<input type="radio" name="accurate" Value="OFF" onClick="if (this.checked) {acc=0}" checked>
<input type="button" name="norm" value=" Start " onclick="start()">
<input type="button" name="norm" value=" Stop " onclick="stop()">
</td></tr>
<tr>
<td width=10><li><font color="#FFFFFF">.</td>
<td width=50>I Am...</td>
<td width=300 align=center><input type="text" name="yrs" size=20></td>
<td width=100 align=left> ...Years Old</td>
</tr>
<tr>
<td><li><font color="#FFFFFF">.</td>
<td>Or...</td>
<td align=center><input type="text" name="dys" size=20></td>
<td align=left> ...Days Old</td>
</tr>
<tr>
<td><li><font color="#FFFFFF">.</td>
<td>Or...</td>
<td align=center><input type="text" name="hrs" size=20></td>
<td align=left> ...Hours Old</td>
</tr>
<tr>
<td><li><font color="#FFFFFF">.</td>
<td>Or...</td>
<td align=center><input type="text" name="mins" size=20></td>
<td align=left> ...Minutes Old</td>
</tr>
<tr>
<td><li><font color="#FFFFFF">.</td>
<td>Or...</td>
<td align=center><input type="text" name="secs" size=20></td>
<td align=left> ...Seconds Old</td>
</tr>
</table>
</form>
<!-- Script Size: 5.12 KB -->