Skip to content

Instantly share code, notes, and snippets.

@JWally
Last active December 20, 2015 13:18
Show Gist options
  • Save JWally/6137282 to your computer and use it in GitHub Desktop.
Save JWally/6137282 to your computer and use it in GitHub Desktop.
Ugly Timer object
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