better check/waiting for egw_ready, also coping with (current) situation that it is already existing

This commit is contained in:
ralf 2024-01-15 08:47:15 +02:00
parent 6b920ee78c
commit c256c2cde9

View File

@ -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);
};
// 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);
}