tellform/public/modules/forms/services/time-counter.client.service.js
2015-07-01 20:50:57 -07:00

22 lines
449 B
JavaScript

'use strict';
angular.module('forms').service('timeCounter', [
function(){
var _startTime, _endTime, that=this;
this.timeSpent = 0;
this.startClock = function(){
_startTime = Date.now();
// console.log('Clock Started');
};
this.stopClock = function(){
_endTime = Date.now();
that.timeSpent = Math.abs(_endTime.valueOf() - _startTime.valueOf())/1000;
// console.log('Clock Ended');
return that.timeSpent;
};
}
]);