Optimize the loading of Asteroids

This commit is contained in:
StevenJoeZhang 2019-08-07 01:12:42 +08:00
parent 2da4c8661c
commit aab6246545

View File

@ -24,9 +24,16 @@ function loadWidget(waifuPath, apiPath) {
function registerEventListener() { function registerEventListener() {
$("#waifu-tool .fa-comment").click(showHitokoto); $("#waifu-tool .fa-comment").click(showHitokoto);
$("#waifu-tool .fa-paper-plane").click(function() { $("#waifu-tool .fa-paper-plane").click(function() {
var s = document.createElement("script"); if (window.Asteroids) {
document.body.appendChild(s); if (!window.ASTEROIDSPLAYERS) window.ASTEROIDSPLAYERS = [];
s.src = "https://cdn.jsdelivr.net/gh/GalaxyMimi/CDN/asteroids.js"; window.ASTEROIDSPLAYERS.push(new Asteroids());
} else {
$.ajax({
url: "https://cdn.jsdelivr.net/gh/GalaxyMimi/CDN/asteroids.js",
dataType: "script",
cache: true
});
}
}); });
$("#waifu-tool .fa-user-circle").click(loadOtherModel); $("#waifu-tool .fa-user-circle").click(loadOtherModel);
$("#waifu-tool .fa-street-view").click(loadRandModel); $("#waifu-tool .fa-street-view").click(loadRandModel);