2015-06-29 22:51:29 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular.module('forms').service('timeCounter', [
|
|
|
|
function(){
|
|
|
|
var _startTime, _endTime, that=this;
|
|
|
|
|
2015-06-30 02:14:43 +00:00
|
|
|
this.timeSpent = 0;
|
2015-06-29 22:51:29 +00:00
|
|
|
|
|
|
|
this.startClock = function(){
|
|
|
|
_startTime = Date.now();
|
2015-07-02 03:50:57 +00:00
|
|
|
// console.log('Clock Started');
|
2015-06-29 22:51:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
this.stopClock = function(){
|
|
|
|
_endTime = Date.now();
|
|
|
|
that.timeSpent = Math.abs(_endTime.valueOf() - _startTime.valueOf())/1000;
|
2015-07-02 03:50:57 +00:00
|
|
|
// console.log('Clock Ended');
|
2015-06-29 22:51:29 +00:00
|
|
|
return that.timeSpent;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
]);
|