topical media & game development

talk show tell print

lib-js-math-calculator-time.htm / htm



  
  <!-- TWO STEPS TO INSTALL ELAPSED TIME CALCULATOR:
  
    1.  Copy the coding into the HEAD of your HTML document
    2.  Add the last code into the BODY of your HTML document  -->
  
  <!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->
  
  <HEAD>
  
  <!-- This script and many more are available free online at -->
  <!-- The JavaScript Source!! http://javascript.internet.com -->
  <!-- Web Site:  http://www.ComputationalNeuralSystems.com -->
  <script language="Javascript">
  <!-- Gracefully hide from old browsers
  // Copyright c 2003 by David Tam, Ph.D.  http://www.ComputationalNeuralSystems.com/
  //   You may copy, modify and/or distribute it under the terms of the GNU General Public License.
  //   See http://www.gnu.org/licenses/gpl.html for terms and conditions
  
  // Javascript to compute elapsed time between "Start" and "Finish" button clicks
  function timestamp_class(this_current_time, this_start_time, this_end_time, this_time_difference) { 
                  this.this_current_time = this_current_time;
                  this.this_start_time = this_start_time;
                  this.this_end_time = this_end_time;
                  this.this_time_difference = this_time_difference;
                  this.GetCurrentTime = GetCurrentTime;
                  this.StartTiming = StartTiming;
                  this.EndTiming = EndTiming;
          }
  
          //Get current time from date timestamp
          function GetCurrentTime() {
          var my_current_timestamp;
                  my_current_timestamp = new Date();                //stamp current date & time
                  return my_current_timestamp.getTime();
                  }
  
          //Stamp current time as start time and reset display textbox
          function StartTiming() {
                  this.this_start_time = GetCurrentTime();        //stamp current time
                  document.TimeDisplayForm.TimeDisplayBox.value = 0;        //init textbox display to zero
                  }
  
          //Stamp current time as stop time, compute elapsed time difference and display in textbox
          function EndTiming() {
                  this.this_end_time = GetCurrentTime();                //stamp current time
                  this.this_time_difference = (this.this_end_time - this.this_start_time) / 1000;        //compute elapsed time
                  document.TimeDisplayForm.TimeDisplayBox.value = this.this_time_difference;        //set elapsed time in display box
                  }
  
  var time_object = new timestamp_class(0, 0, 0, 0);        //create new time object and initialize it
  
  
-> </script> </HEAD> <!-- STEP TWO: Copy this code into the BODY of your HTML document --> <BODY> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Web Site: http://www.ComputationalNeuralSystems.com --> <form> <input type="button" value="Start" onClick="time_object.StartTiming()"; name="StartButton"> </form> <form> <input type="button" value="Finish" onClick="time_object.EndTiming()"; name="EndButton"> </form> <form name="TimeDisplayForm"> Elapsed time: <input type="text" name="TimeDisplayBox" size="6"> seconds </form> <p><center> <font face="arial, helvetica" size"-2">Free JavaScripts provided<br> by <a href="http://javascriptsource.com">The JavaScript Source</a></font> </center><p> <!-- Script Size: 3.15 KB -->

[] readme course(s) preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthought(s) appendix reference(s) example(s) resource(s) _

(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-2780434-1"; urchinTracker(); </script>