mirror of
https://github.com/caojiezi2003/live2d-widget.git
synced 2024-11-10 04:49:47 +00:00
Use ===
operator
This commit is contained in:
parent
eb8cfab425
commit
3c91843d60
@ -161,7 +161,7 @@ window.addEventListener("load", () => {
|
|||||||
var apiPath = "https://live2d.fghrsh.net/api", state = 0,
|
var apiPath = "https://live2d.fghrsh.net/api", state = 0,
|
||||||
modelId = localStorage.getItem("modelId"),
|
modelId = localStorage.getItem("modelId"),
|
||||||
modelTexturesId = localStorage.getItem("modelTexturesId");
|
modelTexturesId = localStorage.getItem("modelTexturesId");
|
||||||
if (modelId == null) {
|
if (modelId === null) {
|
||||||
modelId = 1;
|
modelId = 1;
|
||||||
modelTexturesId = 53;
|
modelTexturesId = 53;
|
||||||
}
|
}
|
||||||
@ -223,24 +223,24 @@ window.addEventListener("load", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById("handle").addEventListener("click", () => {
|
document.getElementById("handle").addEventListener("click", () => {
|
||||||
if (state == 1) {
|
if (state === 1) {
|
||||||
state = 2;
|
state = 2;
|
||||||
coverPosition("80%");
|
coverPosition("80%");
|
||||||
}
|
}
|
||||||
else if (state == 2) {
|
else if (state === 2) {
|
||||||
state = 1;
|
state = 1;
|
||||||
coverPosition("20%");
|
coverPosition("20%");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelector("input[type=password]").addEventListener("focus", () => {
|
document.querySelector("input[type=password]").addEventListener("focus", () => {
|
||||||
if (state == 2) {
|
if (state === 2) {
|
||||||
state = 1;
|
state = 1;
|
||||||
coverPosition("20%");
|
coverPosition("20%");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
document.querySelector("input[type=password]").addEventListener("blur", () => {
|
document.querySelector("input[type=password]").addEventListener("blur", () => {
|
||||||
if (state == 1) {
|
if (state === 1) {
|
||||||
state = 2;
|
state = 2;
|
||||||
coverPosition("80%");
|
coverPosition("80%");
|
||||||
}
|
}
|
||||||
|
@ -90,10 +90,10 @@ function loadWidget(config) {
|
|||||||
} else if (document.referrer !== "") {
|
} else if (document.referrer !== "") {
|
||||||
var referrer = new URL(document.referrer),
|
var referrer = new URL(document.referrer),
|
||||||
domain = referrer.hostname.split(".")[1];
|
domain = referrer.hostname.split(".")[1];
|
||||||
if (location.hostname == referrer.hostname) text = `欢迎阅读<span>「${document.title.split(" - ")[0]}」</span>`;
|
if (location.hostname === referrer.hostname) text = `欢迎阅读<span>「${document.title.split(" - ")[0]}」</span>`;
|
||||||
else if (domain == "baidu") text = `Hello!来自 百度搜索 的朋友<br>你是搜索 <span>${referrer.search.split("&wd=")[1].split("&")[0]}</span> 找到的我吗?`;
|
else if (domain === "baidu") text = `Hello!来自 百度搜索 的朋友<br>你是搜索 <span>${referrer.search.split("&wd=")[1].split("&")[0]}</span> 找到的我吗?`;
|
||||||
else if (domain == "so") text = `Hello!来自 360搜索 的朋友<br>你是搜索 <span>${referrer.search.split("&q=")[1].split("&")[0]}</span> 找到的我吗?`;
|
else if (domain === "so") text = `Hello!来自 360搜索 的朋友<br>你是搜索 <span>${referrer.search.split("&q=")[1].split("&")[0]}</span> 找到的我吗?`;
|
||||||
else if (domain == "google") text = `Hello!来自 谷歌搜索 的朋友<br>欢迎阅读<span>「${document.title.split(" - ")[0]}」</span>`;
|
else if (domain === "google") text = `Hello!来自 谷歌搜索 的朋友<br>欢迎阅读<span>「${document.title.split(" - ")[0]}」</span>`;
|
||||||
else text = `Hello!来自 <span>${referrer.hostname}</span> 的朋友`;
|
else text = `Hello!来自 <span>${referrer.hostname}</span> 的朋友`;
|
||||||
} else {
|
} else {
|
||||||
text = `欢迎阅读<span>「${document.title.split(" - ")[0]}」</span>`;
|
text = `欢迎阅读<span>「${document.title.split(" - ")[0]}」</span>`;
|
||||||
@ -157,7 +157,7 @@ function loadWidget(config) {
|
|||||||
(function initModel() {
|
(function initModel() {
|
||||||
var modelId = localStorage.getItem("modelId"),
|
var modelId = localStorage.getItem("modelId"),
|
||||||
modelTexturesId = localStorage.getItem("modelTexturesId");
|
modelTexturesId = localStorage.getItem("modelTexturesId");
|
||||||
if (modelId == null) {
|
if (modelId === null) {
|
||||||
// 首次访问加载 指定模型 的 指定材质
|
// 首次访问加载 指定模型 的 指定材质
|
||||||
var modelId = 1, // 模型 ID
|
var modelId = 1, // 模型 ID
|
||||||
modelTexturesId = 53; // 材质 ID
|
modelTexturesId = 53; // 材质 ID
|
||||||
@ -229,7 +229,7 @@ function loadWidget(config) {
|
|||||||
fetch(`${apiPath}rand_textures/?id=${modelId}-${modelTexturesId}`)
|
fetch(`${apiPath}rand_textures/?id=${modelId}-${modelTexturesId}`)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if (result.textures.id == 1 && (modelTexturesId == 1 || modelTexturesId == 0)) showMessage("我还没有其他衣服呢!", 4000, 10);
|
if (result.textures.id === 1 && (modelTexturesId === 1 || modelTexturesId === 0)) showMessage("我还没有其他衣服呢!", 4000, 10);
|
||||||
else loadModel(modelId, result.textures.id, "我的新衣服好看嘛?");
|
else loadModel(modelId, result.textures.id, "我的新衣服好看嘛?");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user