J'essaie de faire un compte à rebours basé sur la technique Pomodoro où vous travaillez pendant 25 minutes, puis faites une pause. J'écris la page en Javascript et jQuery en utilisant les plugins jQuery.countdown et moment.js. Je l'ai pour que quand un utilisateur frappe le bouton de démarrage, il compte 25 minutes, mais après que la minuterie est terminée, je veux qu'il y ait deux options de pause redémarrer la minuterie. Puis il va juste dans un cycle 25mins-> break-> 25 mins-> break-> etc en fonction du bouton que l'utilisateur pousse à la fin du compte à rebours.jQuery.countdown à la fin de la minuterie démarrer une nouvelle minuterie avec le bouton
Comment c'est maintenant les boutons après que le compte à rebours est terminé ne rien faire. Je me sens comme j'ai besoin de réinitialiser la minuterie, mais la documentation est un peu difficile à travers pour jQuery.countdown.
<div class="container-fluid">
<p>start timer and then get to work</p>
<div class="container-fluid">
<div class="container-fluid">
<span id="timer"></span>
</div>
</br>
<div class="containter-fluid" id="timer-buttons">
<span><button type="button" class="btn btn-secondary btn-sm" id="btn-start-timer">start timer</button></span>
</div>
</div>
<script type="text/javascript">
var $timer = $('#timer');
var $timerButtons = $('#timer-buttons');
$('#btn-start-timer').click(function(event) {
// get the current time when button clicked
var currentTime = moment();
// add 25 minutes for interval
var timerInterval = moment(currentTime).add(25.0, 'm');
// format interval
var timerIntervalFormatted = moment(timerInterval).format('YYYY/MM/DD HH:mm:ss');
// start the 25 minute timer and at the end popup two buttons for breaks
$timer.countdown(timerIntervalFormatted, function(event) {
$(this).html(event.strftime('%M:%S'));
}).on('finish.countdown', function() {
$timerButtons.html('<span><button type="button" class="btn btn-secondary btn-sm" id="btn-short-break">short break</button></span> <span><button type="button" class="btn btn-secondary btn-sm" id="btn-long-break">long break</button></span>');
});
});
$('#btn-short-break').click(function(event) {
var currentTime = moment();
var shortBreak = moment(currentTime).add(1.0, 'm');
var shortBreakFormatted = moment(shortBreak).format('YYYY/MM/DD HH:mm:ss');
$timer.countdown(shortBreakFormatted, function(event) {
$(this).html(event.strftime('%-M:%S'));
}).on('finish.countdown', function() {
$timerButtons.html('<span><button type ="button" class="btn btn-secondary btn-sm" id="btn-start-timer">start timer</button></span>');
});
});
$('#btn-long-break').click(function(event) {
var currentTime = moment();
var longBreak = moment(currentTime).add(2.0, 'm');
var longBreakFormatted = moment(longBreak).format('YYYY/MM/DD HH:mm:ss');
$timer.countdown(longBreakFormatted, function(event) {
$(this).html(event.strftime('%-M:%S'));
}).on('finish.countdown', function() {
$timerButtons.html('<span><button type ="button" class="btn btn-secondary btn-sm" id="btn-start-timer">start timer</button></span>');
});
});
</script>
merci. Je vais maintenant devoir faire quelques recherches sur certaines fonctionnalités et css pour bien comprendre comment tout cela fonctionne. – kekethetabbycat