Last active
December 18, 2021 21:39
-
-
Save atandy/aaf5bbfea723a9b914512dffd37f76ac to your computer and use it in GitHub Desktop.
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> | |
// https://stackoverflow.com/questions/64689086/infinite-counter-with-increment-at-two-decimals | |
function Incro(increment, interval, execFunc){ | |
let iv; | |
this.increment = increment; this.interval = interval; this.execFunc = execFunc; this.sum = 0; | |
this.start = ()=>{ | |
iv = setInterval(()=>{ | |
this.sum += this.increment; this.execFunc(); | |
}, this.interval); | |
return this; | |
} | |
this.stop = ()=>{ | |
clearInterval(iv); iv = undefined; | |
} | |
} | |
function wait(ms){ | |
var start = new Date().getTime(); | |
var end = start; | |
while(end < start + ms) { | |
end = new Date().getTime(); | |
} | |
} | |
const incro = new Incro(0.42111, 100, function(){ | |
var this_span = document.getElementById('number'); | |
this_span.innerHTML = (this.sum.toFixed(5)); | |
if(this.sum > 10000)this.stop(); | |
}); | |
console.log('0.0000'); | |
incro.start(); | |
setTimeout(()=>{ | |
incro.stop(); | |
setTimeout(()=>{ | |
incro.start(); | |
}, 2000); | |
}, 500150); | |
</script> | |
<div style="text-align:center; font-family:idk; padding-bottom: 20px; | |
padding-top: 20px; background-color:#171923"> | |
<img src="marinade_kiss_laser.png" style="height:94px"> | |
<span id="number" style="font-size:50px; color:white;">0.0000</span> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment