-
-
Save ingria/65420bdbad2026f55b691f309c021736 to your computer and use it in GitHub Desktop.
testGithubGist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
let timer; | |
const timerDisplay = document.getElementById('seconds'); | |
document.getElementById('timerButton').addEventListener('click', startTimer); | |
function startTimer() { | |
let seconds = 1000; | |
let bar_width = 85; | |
timerDisplay.textContent = seconds; | |
timer = setInterval(() => { | |
timerDisplay.style.color = '#fff'; | |
document.getElementById('bar').style.display = 'block'; | |
seconds--; | |
bar_width = bar_width-0.085; | |
document.getElementById('bar').style.width = bar_width + '%'; | |
players.innerHTML = '1'; | |
timerDisplay.textContent = (seconds/100).toFixed(2) + 's'; | |
timerButton.setAttribute('disabled', ''); | |
timerButton.style.opacity = '75%'; | |
if (seconds === 0) { | |
let gameCoef = Math.random()*5; | |
timerDisplay.innerHTML = 'x1.00'; | |
timerDisplay.style.color = '#8F7DE1'; | |
clearInterval(timer); | |
let test = setInterval(function coefCounter(){ | |
let actualCoef = 1; | |
document.getElementById('bar').style.display = 'none'; | |
actualCoef += 0.01; | |
if (actualCoef === gameCoef){ | |
clearInterval(test); | |
timerDisplay.innerHTML = actualCoef; | |
timerDisplay.style.color = '#FF004D'; | |
timerButton.removeAttribute('disabled'); | |
timerButton.style.opacity = '100%';} | |
if (gameCoef<1.01){ | |
timerDisplay.innerHTML = 'x1.00'; | |
timerDisplay.style.color = '#FF004D'; | |
timerButton.removeAttribute('disabled'); | |
timerButton.style.opacity = '100%';}}, 1000);}}, 10);} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment