I am working on a football live score website.
I need a suggestion in creating a timer for it. A timer that counts for 45 minutes then shows half time for 15 minutes then counts from 46 to 90. It is actually a hell of an herculean task.
I could only create a count up timer which counts up to 90 minutes straight. I can neither pause it nor do anything to it.
Here is my code:
Js:
<script type="text/javascript">
function startTimer(duration, display) {
var timer = 0;
var saved_countdown = localStorage.getItem('saved_countdown');
setInterval(function () {
minutes = parseInt(timer / 60);
seconds = parseInt(timer % 60);
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
if (timer++ > duration) {
return;
}
else {
display.textContent = minutes + ":" + seconds;
}
}, 1000);
}
window.onload = function () {
var fiveMinutes = 60 * 90,
display = document.querySelector('#time');
startTimer(fiveMinutes, display);
};
</script>
Any suggestion will be helpful
question from:
https://stackoverflow.com/questions/65626339/html-football-timer 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…