mirror of
https://github.com/stevenjoezhang/live2d-widget.git
synced 2024-11-25 22:31:30 +08:00
Use fetch api
This commit is contained in:
parent
3f4311c0ac
commit
e452d0717d
@ -183,38 +183,33 @@ $(function() {
|
|||||||
function loadRandModel() {
|
function loadRandModel() {
|
||||||
var modelId = localStorage.getItem("modelId"),
|
var modelId = localStorage.getItem("modelId"),
|
||||||
modelTexturesId = localStorage.getItem("modelTexturesId");
|
modelTexturesId = localStorage.getItem("modelTexturesId");
|
||||||
$.ajax({
|
fetch(`${apiPath}/rand_textures/?id=${modelId}-${modelTexturesId}`)
|
||||||
cache: false,
|
.then(response => response.json())
|
||||||
url: `${apiURL}/rand_textures/?id=${modelId}-${modelTexturesId}`,
|
.then(result => {
|
||||||
dataType: "json",
|
|
||||||
success: function(result) {
|
|
||||||
loadModel(modelId, result.textures["id"]);
|
loadModel(modelId, result.textures["id"]);
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
state = 2;
|
state = 2;
|
||||||
$("#cover").css("bottom", "80%");
|
$("#cover").css("bottom", "80%");
|
||||||
$("#refresh").attr("href", "javascript:refresh()");
|
$("#refresh").attr("href", "javascript:refresh()");
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadOtherModel() {
|
function loadOtherModel() {
|
||||||
var modelId = localStorage.getItem("modelId");
|
var modelId = localStorage.getItem("modelId");
|
||||||
$.ajax({
|
fetch(`${apiPath}/switch/?id=${modelId}`)
|
||||||
cache: false,
|
.then(response => response.json())
|
||||||
url: `${apiURL}/switch/?id=${modelId}`,
|
.then(result => {
|
||||||
dataType: "json",
|
|
||||||
success: function(result) {
|
|
||||||
loadModel(result.model["id"]);
|
loadModel(result.model["id"]);
|
||||||
}
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.info = function() {
|
window.info = function() {
|
||||||
// Your code here...
|
fetch("https://v1.hitokoto.cn")
|
||||||
$.getJSON("https://v1.hitokoto.cn/", function(data) {
|
.then(response => response.json())
|
||||||
alert("「" + data.hitokoto + "」——" + data.from);
|
.then(result => {
|
||||||
});
|
alert("「" + result.hitokoto + "」——" + result.from);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
window.refresh = function() {
|
window.refresh = function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user