Skip to content

Instantly share code, notes, and snippets.

@ingria
Forked from refoerofekr/.js
Created June 22, 2023 21:23
Show Gist options
  • Save ingria/65420bdbad2026f55b691f309c021736 to your computer and use it in GitHub Desktop.
Save ingria/65420bdbad2026f55b691f309c021736 to your computer and use it in GitHub Desktop.
testGithubGist
<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