From 9fbfd38311265f52e1559505e030a64f94be8e67 Mon Sep 17 00:00:00 2001 From: Niko Date: Mon, 14 Mar 2022 21:59:47 +0100 Subject: [PATCH] Allow a custom ts specification of waitUntil base.js --- web/src/app/js/base.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/web/src/app/js/base.js b/web/src/app/js/base.js index f6e0cd5..12ae317 100644 --- a/web/src/app/js/base.js +++ b/web/src/app/js/base.js @@ -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++; } }