home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 August / Chip_1999-08_cd.bin / sharewar / htmltool / _SETUP.1 / Clock.scp < prev    next >
Text File  |  1998-04-12  |  1KB  |  52 lines

  1. <HTMLtool>Clock that shows the system time</HTMLtool>
  2. <!-- This is a clock that shows the system time -->
  3. <SCRIPT LANGUAGE="JavaScript">
  4.  
  5. var timerID = null;
  6. var timerRunning = false;
  7.  
  8. function stopclock ()
  9. {
  10.   if(timerRunning)
  11.   clearTimeout(timerID);
  12.   timerRunning = false;
  13. }
  14.  
  15. function showtime () 
  16. {
  17.   var now = new Date();
  18.   var hours = now.getHours();
  19.   var minutes = now.getMinutes();
  20.   var seconds = now.getSeconds();
  21.  
  22.   var timeValue = "" + ((hours >12) ? hours -12 :hours);
  23.   timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
  24.   timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
  25.   timeValue += (hours >= 12) ? " P.M." : " A.M.";
  26.   document.clock.face.value = timeValue;
  27.  
  28. // you could replace the above with this
  29. // and have a clock on the status bar:
  30. // window.status = timeValue;
  31.  
  32.   timerID = setTimeout("showtime()",1000);
  33.   timerRunning = true;
  34. }
  35.  
  36. function startclock () 
  37. {
  38. // Make sure the clock is stopped
  39.   stopclock();
  40.   showtime();
  41. }
  42.  
  43. </SCRIPT>
  44.  
  45. <BODY ONLOAD="startclock(); timerONE=window.setTimeout">
  46. <FORM NAME="clock">
  47. <INPUT TYPE="text" NAME="face" SIZE=13 VALUE="">
  48. </BODY>
  49. </HTML>
  50.  
  51.  
  52.