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){ ...@@ -13,6 +13,8 @@ function MyTimer(render, duration, callback, pressure, pressuriser, onStart){
this.render = render; this.render = render;
this.timer = {}; this.timer = {};
this.running = false; this.running = false;
this.startTime = 0;
this.endTime = 0;
if(isNaN(pressure)){ if(isNaN(pressure)){
this.pressure = 0; this.pressure = 0;
...@@ -70,6 +72,7 @@ function MyTimer(render, duration, callback, pressure, pressuriser, onStart){ ...@@ -70,6 +72,7 @@ function MyTimer(render, duration, callback, pressure, pressuriser, onStart){
} }
self.nextClick = false; self.nextClick = false;
self.running = true ; self.running = true ;
self.startTime = Date.now();
if( self.clickDuration % self.clickUnderPressureDuration === 0){ if( self.clickDuration % self.clickUnderPressureDuration === 0){
self.secondPassed(); self.secondPassed();
} }
...@@ -79,8 +82,18 @@ function MyTimer(render, duration, callback, pressure, pressuriser, onStart){ ...@@ -79,8 +82,18 @@ function MyTimer(render, duration, callback, pressure, pressuriser, onStart){
}; };
this.stop = function(){ this.stop = function(){
self.endTime = Date.now();
self.running = false; self.running = false;
window.clearTimeout(self.timer); window.clearTimeout(self.timer);
self.callback(); self.callback();
}; };
this.getElapsedTime = function(){
if(!self.running){
return self.endTime - self.startTime;
}
else{
return Date.now() - self.startTime;
}
}
} }
...@@ -21,13 +21,13 @@ include('./views/page.header.html'); ...@@ -21,13 +21,13 @@ include('./views/page.header.html');
<?php } ?> <?php } ?>
<fieldset> <fieldset>
<legend class="form-jr-heading"><?php echo $lang['card_creation']; ?></legend> <legend class="form-jr-heading"><?php echo $lang['card_creation']; ?></legend>
<dl> <dl>
<dt><label for="mot"><?php echo $lang['word_to_find']; ?></label></dt> <dt><label for="mot"><?php echo $lang['word_to_find']; ?></label></dt>
<dd><input type="text" id="mot" name="mot" required="required" readonly value="<?php echo $this->res['mot']; ?>" /></dd> <dd><input type="text" id="mot" name="mot" required="required" readonly value="<?php echo $this->res['mot']; ?>" /></dd>
<h3><span id="countdown" class="timer"></span></h3> <h3><span id="countdown" class="timer"></span></h3>
</br><select id="nivcarte" name="nivcarte" > </br><select id="nivcarte" name="nivcarte" >
<option value ="A1">A1</option> <option value ="A1">A1</option>
<option value ="A2">A2</option> <option value ="A2">A2</option>
...@@ -36,19 +36,19 @@ include('./views/page.header.html'); ...@@ -36,19 +36,19 @@ include('./views/page.header.html');
<option value ="C1">C1</option> <option value ="C1">C1</option>
<option value ="C2">C2</option> <option value ="C2">C2</option>
</select> </select>
</br><dt><label for="tabou1"><?php echo $lang['taboo_1']; ?></label></dt> </br><dt><label for="tabou1"><?php echo $lang['taboo_1']; ?></label></dt>
<dd><input type="text" id="tabou1" name="tabou1" required="required" readonly value="<?php echo $this->res['tabou1']; ?>" /></dd> <dd><input type="text" id="tabou1" name="tabou1" required="required" readonly value="<?php echo $this->res['tabou1']; ?>" /></dd>
</br><dt><label for="tabou2"><?php echo $lang['taboo_2']; ?></label></dt> </br><dt><label for="tabou2"><?php echo $lang['taboo_2']; ?></label></dt>
<dd><input type="text" id="tabou2" name="tabou2" required="required" readonly value="<?php echo $this->res['tabou2']; ?>" /></dd> <dd><input type="text" id="tabou2" name="tabou2" required="required" readonly value="<?php echo $this->res['tabou2']; ?>" /></dd>
</br><dt><label for="tabou3"><?php echo $lang['taboo_3']; ?></label></dt> </br><dt><label for="tabou3"><?php echo $lang['taboo_3']; ?></label></dt>
<dd><input type="text" id="tabou3" name="tabou3" required="required" readonly value="<?php echo $this->res['tabou3']; ?>" /></dd> <dd><input type="text" id="tabou3" name="tabou3" required="required" readonly value="<?php echo $this->res['tabou3']; ?>" /></dd>
</br><dt><label for="tabou4"><?php echo $lang['taboo_4']; ?></label></dt> </br><dt><label for="tabou4"><?php echo $lang['taboo_4']; ?></label></dt>
<dd><input type="text" id="tabou4" name="tabou4" required="required" readonly value="<?php echo $this->res['tabou4']; ?>" /></dd> <dd><input type="text" id="tabou4" name="tabou4" required="required" readonly value="<?php echo $this->res['tabou4']; ?>" /></dd>
</br><dt><label for="tabou5"><?php echo $lang['taboo_5']; ?></label></dt> </br><dt><label for="tabou5"><?php echo $lang['taboo_5']; ?></label></dt>
<dd><input type="text" id="tabou5" name="tabou5" required="required" readonly value="<?php echo $this->res['tabou5']; ?>" /></dd> <dd><input type="text" id="tabou5" name="tabou5" required="required" readonly value="<?php echo $this->res['tabou5']; ?>" /></dd>
...@@ -56,10 +56,10 @@ include('./views/page.header.html'); ...@@ -56,10 +56,10 @@ include('./views/page.header.html');
<div id="form-cmd"> <div id="form-cmd">
<input class="btn btn-primary" type="button" id="random" name="random" onclick="document.location.reload(false)" value="<?php echo $lang['random']; ?>"/><br/><br/> <input class="btn btn-primary" type="button" id="random" name="random" onclick="document.location.reload(false)" value="<?php echo $lang['random']; ?>"/><br/><br/>
<input class="btn btn-lg btn-primary btn-block" type="submit" id="submit_form" name="submit_form" value="<?php echo $lang['validate']; ?>" class="submit_buttons" /> <input class="btn btn-lg btn-primary btn-block" type="submit" id="submit_form" name="submit_form" value="<?php echo $lang['validate']; ?>" class="submit_buttons" />
<input type="hidden" name="mode" value="<?php echo $this->mode; ?>"/> <input type="hidden" name="mode" value="<?php echo $this->mode; ?>"/>
<!-- Informations cachées pour l'enregistrement dans la BDD <!-- Informations cachées pour l'enregistrement dans la BDD
<input type="hidden" name="userlang" value="<?php// echo $this->userlang; ?>"/> <input type="hidden" name="userlang" value="<?php// echo $this->userlang; ?>"/>
<input type="hidden" name="userid" value="<?php// echo $this->userid; ?>"/> <input type="hidden" name="userid" value="<?php// echo $this->userid; ?>"/>
<input type="hidden" name="niveau" value="<?php// echo $this->niveau; ?>"/> --> <input type="hidden" name="niveau" value="<?php// echo $this->niveau; ?>"/> -->
...@@ -77,7 +77,7 @@ include('./views/page.header.html'); ...@@ -77,7 +77,7 @@ include('./views/page.header.html');
function renders(minutes, seconds){ function renders(minutes, seconds){
if(seconds == Math.floor(seconds)){ if(seconds == Math.floor(seconds)){
if (seconds < 10){ if (seconds < 10){
seconds = "0" + seconds; seconds = "0" + seconds;
} }
$('#countdown').html(minutes + ":" + seconds); $('#countdown').html(minutes + ":" + seconds);
} }
...@@ -99,40 +99,40 @@ var monChrono = new MyTimer(renders,<?php echo $this->time; ?>, finChrono, 10,pr ...@@ -99,40 +99,40 @@ var monChrono = new MyTimer(renders,<?php echo $this->time; ?>, finChrono, 10,pr
monChrono.start(); monChrono.start();
</script> </script>
<script language="Javascript"> <script language="Javascript">
// fonction pour n'afficher que les champs de 3 mots tabous (facile) // fonction pour n'afficher que les champs de 3 mots tabous (facile)
function basculef(elem) function basculef(elem)
{ {
document.getElementById('facile').style.visibility="visible"; document.getElementById('facile').style.visibility="visible";
document.getElementById('moyen').style.visibility="hidden"; document.getElementById('moyen').style.visibility="hidden";
document.getElementById('difficile').style.visibility="hidden"; document.getElementById('difficile').style.visibility="hidden";
document.getElementById('tabou4').value=""; document.getElementById('tabou4').value="";
document.getElementById('tabou5').value=""; document.getElementById('tabou5').value="";
document.getElementById('tabou4').required=""; document.getElementById('tabou4').required="";
document.getElementById('tabou5').required=""; document.getElementById('tabou5').required="";
} }
// fonction pour n'afficher que les champs de 4 mots tabous (facile+moyen) // fonction pour n'afficher que les champs de 4 mots tabous (facile+moyen)
function basculem(elem) function basculem(elem)
{ {
document.getElementById('facile').style.visibility="visible"; document.getElementById('facile').style.visibility="visible";
document.getElementById('moyen').style.visibility="visible"; document.getElementById('moyen').style.visibility="visible";
document.getElementById('difficile').style.visibility="hidden"; document.getElementById('difficile').style.visibility="hidden";
document.getElementById('tabou5').value=""; document.getElementById('tabou5').value="";
document.getElementById('tabou4').required="required"; document.getElementById('tabou4').required="required";
document.getElementById('tabou5').required=""; document.getElementById('tabou5').required="";
} }
// fonction pour afficher les champs de 5 mots tabous (facile+moyen+difficile) // fonction pour afficher les champs de 5 mots tabous (facile+moyen+difficile)
function basculed(elem) function basculed(elem)
{ {
document.getElementById('facile').style.visibility="visible"; document.getElementById('facile').style.visibility="visible";
document.getElementById('moyen').style.visibility="visible"; document.getElementById('moyen').style.visibility="visible";
document.getElementById('difficile').style.visibility="visible"; document.getElementById('difficile').style.visibility="visible";
document.getElementById('tabou4').required="required"; document.getElementById('tabou4').required="required";
document.getElementById('tabou5').required="required"; document.getElementById('tabou5').required="required";
} }
</script> </script>
<?php <?php
include('./views/page.footer.html'); include('./views/page.footer.html');
?> ?>
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