Last active
December 20, 2015 13:18
-
-
Save JWally/6137282 to your computer and use it in GitHub Desktop.
Ugly Timer object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function simpleTimer(){ | |
var that = this; | |
this.obj = { | |
open_time: 0 | |
,close_time: 0 | |
,total_time: 0 | |
}; | |
this.intTimer = {}; | |
this.meth = function(fx){ | |
var current = new Date().getTime(); | |
that.obj.total_time = (current - that.obj.open_time); | |
fx(that.obj); | |
}; | |
this.start = function(fx){ | |
this.obj.open_time = new Date().getTime(); | |
this.intTimer = setInterval(function(){that.meth(fx);},100); | |
}; | |
this.stop = function(){ | |
clearInterval(this.intTimer); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment