« MediaWiki:Gadget-inline-js-loader.js » : différence entre les versions
Aucun résumé des modifications |
(Ajouté un mécanisme de vérification de la définition de inlineJS) |
||
Ligne 1 : | Ligne 1 : | ||
console.log("Loaded inline-js-loader"); | console.log("Loaded inline-js-loader"); | ||
eJS = function() | |||
{ | { | ||
f = inlineJS[n]; | /* It sometimes happens that gadgets are called before the inlineJS is delcared, making the loading | ||
fail. In this case, give it another 500ms and do a recursive call to try again. */ | |||
if(typeof inlineJS == 'undefined') | |||
{ | |||
setTimeout(eJS, 500); | |||
return; | |||
} | |||
for(var n in inlineJS) // Each function to be executed is added to the inlineJS object. | |||
{ | |||
f = inlineJS[n]; | |||
if(typeof f === 'function' ) { f(); } | |||
} | |||
} | } | ||
eJS(); |
Version du 8 avril 2020 à 21:52
console.log("Loaded inline-js-loader");
eJS = function()
{
/* It sometimes happens that gadgets are called before the inlineJS is delcared, making the loading
fail. In this case, give it another 500ms and do a recursive call to try again. */
if(typeof inlineJS == 'undefined')
{
setTimeout(eJS, 500);
return;
}
for(var n in inlineJS) // Each function to be executed is added to the inlineJS object.
{
f = inlineJS[n];
if(typeof f === 'function' ) { f(); }
}
}
eJS();