打开主菜单

少前百科GFwiki β

MediaWiki:Gadget-live2dLoader.js

注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:前往菜单 → 设置(Mac为Opera → Preferences),然后隐私和安全 → 清除浏览数据 → 缓存的图片和文件
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);
		    		return;
		    	}
		    	
		    	// Make sure PIXI.JS is available first
		    	window.animations.PIXILoader.init().then(function() {
		    		// Now we can initialize Live2D
		    		$.ajax({
					    cache: true,
					    async: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.");