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

From Girls' Frontline Wiki
Jump to navigation Jump to search
(Initial setup)
 
(Added Logging)
Line 11: Line 11:
 
    }
 
    }
 
   
 
   
    window.animations.PIXILoader.init().then(function() {
+
    window.animations.Live2dLoader.init().then(function() {
 
    $.ajax({
 
    $.ajax({
 
    cache: true,
 
    cache: true,
Line 17: Line 17:
 
    dataType: "script"
 
    dataType: "script"
 
}).done(function() {
 
}).done(function() {
 +
console.log("Request L2D Framework successfull.");
 
window.animations.Live2dLoader.initialized = true;
 
window.animations.Live2dLoader.initialized = true;
 
    resolve(null);
 
    resolve(null);
 
}).fail(function() {
 
}).fail(function() {
        console.error("Loading PIXI framework failed");
+
        console.error("Loading L2D framework failed");
        var reason = new Error('PIXI framework failed loading');
+
        var reason = new Error('L2D framework failed loading');
 
        reject(reason);
 
        reject(reason);
 
    });
 
    });
Line 29: Line 30:
 
};
 
};
 
}
 
}
 +
 +
console.log("Loaded L2D Framework Loader.");

Revision as of 16:06, 11 October 2019

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

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

console.log("Loaded L2D Framework Loader.");