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 >
Text File  |  1998-08-25  |  5KB  |  354 lines

  1.  
  2. <!-- TWO STEPS TO INSTALL AGECOUNTER:
  3.  
  4.  
  5.  
  6.    1.  Paste the coding into the HEAD of your HTML document
  7.  
  8.    2.  Put the last coding into the BODY of your HTML document  -->
  9.  
  10.  
  11.  
  12. <!-- STEP ONE: Copy this code into the HEAD of your HTML document  -->
  13.  
  14.  
  15.  
  16. <SCRIPT LANGUAGE="JavaScript">
  17.  
  18.  
  19.  
  20. <!-- This script and many more are available online from -->
  21.  
  22. <!-- The JavaScript Source!! http://javascriptsource.com -->
  23.  
  24.  
  25.  
  26. <!-- Begin
  27.  
  28. var acc=0
  29.  
  30. var show_time=false;
  31.  
  32. var timerID=null;
  33.  
  34. var blank=":";
  35.  
  36. function stop() {
  37.  
  38. if (show_time)
  39.  
  40. clearTimeout(timerID);
  41.  
  42. show_time=false;
  43.  
  44. }
  45.  
  46. function start(form) {
  47.  
  48. var today=new Date();
  49.  
  50. var acc1=acc;
  51.  
  52. var display_value =" Time:  " + today.getHours() 
  53.  
  54. if (today.getMinutes() < 10) {
  55.  
  56. display_value+=":0" + today.getMinutes();
  57.  
  58. }
  59.  
  60. else {
  61.  
  62. display_value+=":" + today.getMinutes();
  63.  
  64. }
  65.  
  66. if (today.getSeconds() < 10){
  67.  
  68. display_value+=":0" + today.getSeconds();
  69.  
  70. }
  71.  
  72. else {
  73.  
  74. display_value+=":" + today.getSeconds();
  75.  
  76. }
  77.  
  78. if
  79.  
  80. (today.getHours()>=12) {
  81.  
  82. display_value+=" P.M.  "
  83.  
  84. }
  85.  
  86. else {
  87.  
  88. display_value+=" A.M.  "
  89.  
  90. }
  91.  
  92. display_value += " Date:  " 
  93.  
  94. + (today.getMonth()+1) + "/"  
  95.  
  96. + today.getDate() + "/" + today.getYear();
  97.  
  98. window.status=display_value;
  99.  
  100. writeyourAge(acc1)
  101.  
  102. timerID=setTimeout("start()",100);
  103.  
  104. show_time=true;
  105.  
  106. }
  107.  
  108. function writeyourAge(onval) {
  109.  
  110. if (onval == 0) {
  111.  
  112. normal()
  113.  
  114. } else {
  115.  
  116. accurate()
  117.  
  118.    }
  119.  
  120. }
  121.  
  122. function normal() {                             
  123.  
  124. TheDate = new Date();                     
  125.  
  126. Month = TheDate.getMonth();              
  127.  
  128. Day = TheDate.getDate();                 
  129.  
  130. Year = TheDate.getYear();
  131.  
  132. Hour = TheDate.getHours();
  133.  
  134. Minute = TheDate.getMinutes();
  135.  
  136. Second = TheDate.getSeconds();   
  137.  
  138. by = (document.my_age.birthy.value);
  139.  
  140. bm = (document.my_age.birthm.value);
  141.  
  142. bd = (document.my_age.birthd.value);
  143.  
  144. bh = (document.my_age.birthh.value);
  145.  
  146. bmn = (document.my_age.birthmin.value);
  147.  
  148. bs = (document.my_age.births.value);
  149.  
  150. BDate = Date.UTC(by,bm,bd,bh,bmn,bs);
  151.  
  152. if (Year<2000) {              
  153.  
  154. CDate = Date.UTC(Year,Month,Day,Hour,Minute,Second);
  155.  
  156. } else {
  157.  
  158. CDate = Date.UTC(Year,Month,Day,Hour,Minute,Second);
  159.  
  160. }
  161.  
  162. Age = CDate-BDate;
  163.  
  164. document.my_age.yrs.value = parseInt(((((Age/1000)/60)/60)/24)/365.25,10);
  165.  
  166. document.my_age.dys.value = parseInt((((Age/1000)/60)/60)/24,10);
  167.  
  168. document.my_age.hrs.value = parseInt(((Age/1000)/60)/60,10);
  169.  
  170. document.my_age.mins.value = parseInt((Age/1000)/60,10);
  171.  
  172. document.my_age.secs.value = parseInt(Age/1000,10);
  173.  
  174. }
  175.  
  176. function accurate() {
  177.  
  178. TheDate = new Date();                     
  179.  
  180. Month = TheDate.getMonth();                
  181.  
  182. Day = TheDate.getDate();                  
  183.  
  184. Year = TheDate.getYear();
  185.  
  186. Hour = TheDate.getHours();
  187.  
  188. Minute = TheDate.getMinutes();
  189.  
  190. Second = TheDate.getSeconds();           
  191.  
  192. by = (document.my_age.birthy.value);
  193.  
  194. bm = (document.my_age.birthm.value);
  195.  
  196. bd = (document.my_age.birthd.value);
  197.  
  198. bh = (document.my_age.birthh.value);
  199.  
  200. bmn = (document.my_age.birthmin.value);
  201.  
  202. bs = (document.my_age.births.value);
  203.  
  204. BDate = Date.UTC(by,bm,bd,bh,bmn,bs);
  205.  
  206. if (Year<2000) {              
  207.  
  208. CDate = Date.UTC(Year,Month,Day,Hour,Minute,Second);
  209.  
  210. } else {
  211.  
  212. CDate = Date.UTC(Year,Month,Day,Hour,Minute,Second);
  213.  
  214. }
  215.  
  216. Age = CDate-BDate;
  217.  
  218. document.my_age.yrs.value = ((((Age/1000)/60)/60)/24)/365.25;
  219.  
  220. document.my_age.dys.value = (((Age/1000)/60)/60)/24;
  221.  
  222. document.my_age.hrs.value = ((Age/1000)/60)/60;
  223.  
  224. document.my_age.mins.value = (Age/1000)/60;
  225.  
  226. document.my_age.secs.value = Age/1000;
  227.  
  228. }
  229.  
  230. // End -->
  231.  
  232. </SCRIPT>
  233.  
  234.  
  235.  
  236.  
  237.  
  238. <!-- STEP TWO: Copy this code into the BODY of your HTML document  -->
  239.  
  240.  
  241.  
  242. <BODY>
  243.  
  244.  
  245.  
  246. <form name="my_age">
  247.  
  248. <table width=460 border=0 cellspacing=0 cellpadding=2>
  249.  
  250. <tr>
  251.  
  252. <td align=center colspan=5>D.O.Báá
  253.  
  254. Yr<input name="birthy" type="text" size=2>áá
  255.  
  256. Mon<input name="birthm" type="text" size=2>áá
  257.  
  258. Day<input name="birthd" type="text" size=2>áá
  259.  
  260. Hr<input name="birthh" type="text" size=2>áá
  261.  
  262. Min<input name="birthmin" type="text" size=2>áá
  263.  
  264. Sec<input name="births" type="text" size=2>áá
  265.  
  266. </td>
  267.  
  268. </tr>
  269.  
  270. <tr>
  271.  
  272. <td align=center colspan=5>
  273.  
  274. Accurate<input type="radio" name="accurate" value="ON" onClick="if (this.checked) {acc=1}">
  275.  
  276. Normal<input type="radio" name="accurate" Value="OFF" onClick="if (this.checked) {acc=0}" checked>
  277.  
  278. <input type="button" name="norm" value=" Start " onclick="start()">
  279.  
  280. <input type="button" name="norm" value=" Stop " onclick="stop()">
  281.  
  282. </td></tr>
  283.  
  284.  
  285.  
  286. <tr>                       
  287.  
  288. <td width=10><li><font color="#FFFFFF">.</td>
  289.  
  290. <td width=50>I Am...</td>
  291.  
  292. <td width=300 align=center><input type="text" name="yrs" size=20></td>
  293.  
  294. <td width=100 align=left>  ...Years Old</td>
  295.  
  296. </tr>
  297.  
  298. <tr>
  299.  
  300. <td><li><font color="#FFFFFF">.</td>
  301.  
  302. <td>Or...</td>
  303.  
  304. <td align=center><input type="text" name="dys" size=20></td>
  305.  
  306. <td align=left>  ...Days Old</td>
  307.  
  308. </tr>
  309.  
  310. <tr>
  311.  
  312. <td><li><font color="#FFFFFF">.</td>
  313.  
  314. <td>Or...</td>
  315.  
  316. <td align=center><input type="text" name="hrs" size=20></td>
  317.  
  318. <td align=left>  ...Hours Old</td>
  319.  
  320. </tr>
  321.  
  322. <tr>
  323.  
  324. <td><li><font color="#FFFFFF">.</td>
  325.  
  326. <td>Or...</td>
  327.  
  328. <td align=center><input type="text" name="mins" size=20></td>
  329.  
  330. <td align=left>  ...Minutes Old</td>
  331.  
  332. </tr>
  333.  
  334. <tr>
  335.  
  336. <td><li><font color="#FFFFFF">.</td>
  337.  
  338. <td>Or...</td>
  339.  
  340. <td align=center><input type="text" name="secs" size=20></td>
  341.  
  342. <td align=left>  ...Seconds Old</td>
  343.  
  344. </tr>
  345.  
  346. </table>
  347.  
  348. </form>
  349.  
  350.  
  351.  
  352. <!-- Script Size:  5.12 KB  -->
  353.  
  354.