Use === operator

This commit is contained in:
Mimi 2020-02-10 22:19:28 +08:00
parent eb8cfab425
commit 3c91843d60
2 changed files with 11 additions and 11 deletions

View File

@ -161,7 +161,7 @@ window.addEventListener("load", () => {
var apiPath = "https://live2d.fghrsh.net/api", state = 0,
modelId = localStorage.getItem("modelId"),
modelTexturesId = localStorage.getItem("modelTexturesId");
if (modelId == null) {
if (modelId === null) {
modelId = 1;
modelTexturesId = 53;
}
@ -223,24 +223,24 @@ window.addEventListener("load", () => {
}
document.getElementById("handle").addEventListener("click", () => {
if (state == 1) {
if (state === 1) {
state = 2;
coverPosition("80%");
}
else if (state == 2) {
else if (state === 2) {
state = 1;
coverPosition("20%");
}
});
document.querySelector("input[type=password]").addEventListener("focus", () => {
if (state == 2) {
if (state === 2) {
state = 1;
coverPosition("20%");
}
});
document.querySelector("input[type=password]").addEventListener("blur", () => {
if (state == 1) {
if (state === 1) {
state = 2;
coverPosition("80%");
}

View File

@ -90,10 +90,10 @@ function loadWidget(config) {
} else if (document.referrer !== "") {
var referrer = new URL(document.referrer),
domain = referrer.hostname.split(".")[1];
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 == "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>`;
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 === "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 text = `Hello来自 <span>${referrer.hostname}</span> 的朋友`;
} else {
text = `欢迎阅读<span>「${document.title.split(" - ")[0]}」</span>`;
@ -157,7 +157,7 @@ function loadWidget(config) {
(function initModel() {
var modelId = localStorage.getItem("modelId"),
modelTexturesId = localStorage.getItem("modelTexturesId");
if (modelId == null) {
if (modelId === null) {
// 首次访问加载 指定模型 的 指定材质
var modelId = 1, // 模型 ID
modelTexturesId = 53; // 材质 ID
@ -229,7 +229,7 @@ function loadWidget(config) {
fetch(`${apiPath}rand_textures/?id=${modelId}-${modelTexturesId}`)
.then(response => response.json())
.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, "我的新衣服好看嘛?");
});
}