Difference between revisions of "MediaWiki:Gadget-pixiLoader.js"

From Girls' Frontline Wiki
Jump to navigation Jump to search
(Introduced a loader for the pixi framework)
 
(Added Logging)
Line 16: Line 16:
 
    dataType: "script"
 
    dataType: "script"
 
}).done(function() {
 
}).done(function() {
 +
console.log("Request PIXI JS Framework successfull");
 
window.animations.PIXILoader.initialized = true;
 
window.animations.PIXILoader.initialized = true;
 
    resolve(null);
 
    resolve(null);
Line 27: Line 28:
 
};
 
};
 
}
 
}
 +
 +
console.log("Loaded PIXI JS Gadget");

Revision as of 16:08, 11 October 2019

window.animations = window.animations || {};

if (!window.animations.PIXILoader) {
	window.animations.PIXILoader = {};
	window.animations.PIXILoader.initialized = false;
	window.animations.PIXILoader.init = function() {
		return new Promise(
		    function (resolve, reject) {
		    	if (window.animations.PIXILoader.initialized) {
		    		resolve(null);
		    	}
		    	
		    	$.ajax({
				    cache: true,
				    url: "/index.php?title=MediaWiki:Gadget-pixiJsWithSpine.js&action=raw",
				    dataType: "script"
				}).done(function() {
					console.log("Request PIXI JS Framework successfull");
					window.animations.PIXILoader.initialized = true;
				    resolve(null);
				}).fail(function() {
			        console.error("Loading PIXI framework failed");
			        var reason = new Error('PIXI framework failed loading');
			        reject(reason);
			    });
		    }
		);
	};
}

console.log("Loaded PIXI JS Gadget");