diff --git a/api/js/login.js b/api/js/login.js index ed42029160..fd28fc8c9d 100644 --- a/api/js/login.js +++ b/api/js/login.js @@ -20,9 +20,7 @@ catch (exception){ alert('Your browser is not up-to-date (JavaScript ES2020 compatible), you may experience some of the features not working.'); } -// listen to egw-is-created object to make sure egw object is ready -//document.addEventListener('egw-is-created', function(){ -window.setTimeout(() => { +const login_on_ready = () => { egw_ready.then(function() { jQuery(document).ready(function() @@ -105,4 +103,18 @@ window.setTimeout(() => { console.log('Service worker registration failed, error:', error); }); } -}, 500); \ No newline at end of file +}; + +// run login_on_ready, once egw_ready is available, currently it is already available, as login.js is included in the body +if (typeof egw_ready !== "undefined") +{ + login_on_ready(); +} +else +{ + const wait4egw_ready = window.setInterval(() => { + if (typeof egw_ready === "undefined") return; + window.clearInterval(wait4egw_ready); + login_on_ready(); + }, 100); +} \ No newline at end of file