Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 6e55fefc authored by Mathieu Loiseau's avatar Mathieu Loiseau
Browse files

can time stuff as well as count down

parent 4f8fc93c
......@@ -13,6 +13,8 @@ function MyTimer(render, duration, callback, pressure, pressuriser, onStart){
this.render = render;
this.timer = {};
this.running = false;
this.startTime = 0;
this.endTime = 0;
if(isNaN(pressure)){
this.pressure = 0;
......@@ -70,6 +72,7 @@ function MyTimer(render, duration, callback, pressure, pressuriser, onStart){
}
self.nextClick = false;
self.running = true ;
self.startTime = Date.now();
if( self.clickDuration % self.clickUnderPressureDuration === 0){
self.secondPassed();
}
......@@ -79,8 +82,18 @@ function MyTimer(render, duration, callback, pressure, pressuriser, onStart){
};
this.stop = function(){
self.endTime = Date.now();
self.running = false;
window.clearTimeout(self.timer);
self.callback();
};
this.getElapsedTime = function(){
if(!self.running){
return self.endTime - self.startTime;
}
else{
return Date.now() - self.startTime;
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment