|
function StopWatch(){
var startTime = null;
var stopTime = null;
var running = false;
this.start = function(){
if (running == true)
return;
else if (startTime != null)
stopTime = null;
running = true;
startTime = getTime();
}
this.stop = function(){
if (running == false)
return;
stopTime = getTime();
running = false;
}
this.duration = function(){
if (startTime == null || stopTime == null)
return 'Undefined';
else
return (stopTime - startTime) / 1000;
}
this.isRunning = function() { return running; }
function getTime(){
var day = new Date();
return day.getTime();
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.