Allow a custom ts specification of waitUntil base.js

This commit is contained in:
Niko 2022-03-14 21:59:47 +01:00
parent a3dfbbdde4
commit 9fbfd38311
1 changed files with 4 additions and 3 deletions

View File

@ -236,12 +236,13 @@ function getNormalizedURI() { return window.location.pathname.replace(/\/+?$/, '
function capitalize(s) { return s.charAt(0).toUpperCase() + s.substr(1) }
function randomNum(min, max) { return Math.floor(Math.random() * (max - min) + min) }
function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)) }
async function waitUntil(cback, secs) {
async function waitUntil(cback, ticks, ts) {
ts = ts || 1000;
var i = 0;
while (i < secs) {
while (i < ticks) {
if (cback())
return;
await sleep(1000);
await sleep(ts);
i++;
}
}