« MediaWiki:Gadget-inline-js-loader.js » : différence entre les versions

De Wikimedica
mAucun résumé des modifications
(Déplacement du message du gadget à la fin)
Ligne 1 : Ligne 1 :
console.log("Loaded inline-js-loader");
var eJS = function()  
 
eJS = function()  
{
{
/* It sometimes happens that gadgets are called before the inlineJS is delcared, making the loading
/* It sometimes happens that gadgets are called before the inlineJS is delcared, making the loading
Ligne 19 : Ligne 17 :
}
}
eJS();
eJS();
console.log("Loaded inline-js-loader");

Version du 4 septembre 2020 à 13:21

var 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);
		console.log("Loading inline-js-loader failed, trying again in 500ms");
		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();

console.log("Loaded inline-js-loader");