home *** CD-ROM | disk | FTP | other *** search
/ PC User 2005 May / CD / PCU0505CD.iso / software / full / coffecup / files / html2005.exe / %MAINDIR% / Javascript / Clock.xml < prev    next >
Encoding:
Text File  |  2005-02-16  |  2.2 KB  |  109 lines

  1. <ccResource>
  2.   <ccTitle>
  3. Clock
  4.   </ccTitle>
  5.   <ccCategory>
  6. Clocks
  7.   </ccCategory>
  8.   <ccDescription>
  9. This is a clock that shows the system time.
  10.   </ccDescription>
  11.   <ccInstructions>
  12.  
  13.   </ccInstructions>
  14.   <ccHeadContent>
  15.  <SCRIPT LANGUAGE="JavaScript">
  16.  
  17. var timerID = null;
  18. var timerRunning = false;
  19.  
  20. function stopclock ()
  21. {
  22.   if(timerRunning)
  23.   clearTimeout(timerID);
  24.   timerRunning = false;
  25. }
  26.  
  27. function showtime () 
  28. {
  29.   var now = new Date();
  30.   var hours = now.getHours();
  31.   var minutes = now.getMinutes();
  32.   var seconds = now.getSeconds()
  33.  
  34.   var timeValue = "" + ((hours >12) ? hours -12 :hours)
  35.   timeValue += ((minutes < 10) ? ":0" : ":") + minutes
  36.   timeValue += ((seconds < 10) ? ":0" : ":") + seconds
  37.   timeValue += (hours >= 12) ? " P.M." : " A.M."
  38.   document.clock.face.value = timeValue;
  39.  
  40. // you could replace the above with this
  41. // and have a clock on the status bar:
  42. // window.status = timeValue;
  43.  
  44.   timerID = setTimeout("showtime()",1000);
  45.   timerRunning = true;
  46. }
  47.  
  48. function startclock () 
  49. {
  50. // Make sure the clock is stopped
  51.   stopclock();
  52.   showtime();
  53. }
  54.  
  55. </SCRIPT>
  56.   </ccHeadContent>
  57.   <ccBodyContent>
  58. <SCRIPT LANGUAGE="JavaScript">
  59.  
  60. var timerID = null;
  61. var timerRunning = false;
  62.  
  63. function stopclock ()
  64. {
  65.   if(timerRunning)
  66.   clearTimeout(timerID);
  67.   timerRunning = false;
  68. }
  69.  
  70. function showtime () 
  71. {
  72.   var now = new Date();
  73.   var hours = now.getHours();
  74.   var minutes = now.getMinutes();
  75.   var seconds = now.getSeconds()
  76.  
  77.   var timeValue = "" + ((hours >12) ? hours -12 :hours)
  78.   timeValue += ((minutes < 10) ? ":0" : ":") + minutes
  79.   timeValue += ((seconds < 10) ? ":0" : ":") + seconds
  80.   timeValue += (hours >= 12) ? " P.M." : " A.M."
  81.   document.clock.face.value = timeValue;
  82.  
  83. // you could replace the above with this
  84. // and have a clock on the status bar:
  85. // window.status = timeValue;
  86.  
  87.   timerID = setTimeout("showtime()",1000);
  88.   timerRunning = true;
  89. }
  90.  
  91. function startclock () 
  92. {
  93. // Make sure the clock is stopped
  94.   stopclock();
  95.   showtime();
  96. }
  97.  
  98. </SCRIPT>
  99.   </ccBodyContent>
  100.   <ccElementContent>
  101.   
  102.    <ccElementName></ccElementName>
  103.    <ccElementAction></ccElementAction>
  104.    
  105.   </ccElementContent>
  106.   <ccExtraData>
  107.  
  108.   </ccExtraData>
  109. </ccResource>