mirror of
https://github.com/caojiezi2003/live2d-widget.git
synced 2024-11-10 04:49:47 +00:00
Use vanilla javascript
This commit is contained in:
parent
57f3a76fea
commit
b2c44f4f1c
@ -49,7 +49,7 @@ function loadWidget(waifuPath, apiPath) {
|
|||||||
$("#waifu").css({ bottom: -500 });
|
$("#waifu").css({ bottom: -500 });
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
$("#waifu").hide();
|
$("#waifu").hide();
|
||||||
$("#waifu-toggle").addClass("waifu-toggle-active");
|
document.getElementById("waifu-toggle").classList.add("waifu-toggle-active");
|
||||||
}, 3000);
|
}, 3000);
|
||||||
});
|
});
|
||||||
var devtools = () => {};
|
var devtools = () => {};
|
||||||
@ -223,20 +223,21 @@ function initWidget(waifuPath = "/waifu-tips.json", apiPath = "") {
|
|||||||
document.body.insertAdjacentHTML("beforeend", `<div id="waifu-toggle">
|
document.body.insertAdjacentHTML("beforeend", `<div id="waifu-toggle">
|
||||||
<span>看板娘</span>
|
<span>看板娘</span>
|
||||||
</div>`);
|
</div>`);
|
||||||
$("#waifu-toggle").click(() => {
|
var toggle = document.getElementById("waifu-toggle");
|
||||||
$("#waifu-toggle").removeClass("waifu-toggle-active");
|
toggle.addEventListener("click", () => {
|
||||||
if ($("#waifu-toggle").attr("first-time")) {
|
toggle.classList.remove("waifu-toggle-active");
|
||||||
|
if (toggle.getAttribute("first-time")) {
|
||||||
loadWidget(waifuPath, apiPath);
|
loadWidget(waifuPath, apiPath);
|
||||||
$("#waifu-toggle").attr("first-time", false);
|
toggle.removeAttribute("first-time");
|
||||||
} else {
|
} else {
|
||||||
localStorage.removeItem("waifu-display");
|
localStorage.removeItem("waifu-display");
|
||||||
$("#waifu").show().css({ bottom: 0 });
|
$("#waifu").show().css({ bottom: 0 });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (localStorage.getItem("waifu-display") && Date.now() - localStorage.getItem("waifu-display") <= 86400000) {
|
if (localStorage.getItem("waifu-display") && Date.now() - localStorage.getItem("waifu-display") <= 86400000) {
|
||||||
$("#waifu-toggle").attr("first-time", true);
|
toggle.setAttribute("first-time", true);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
$("#waifu-toggle").addClass("waifu-toggle-active");
|
toggle.classList.add("waifu-toggle-active");
|
||||||
}, 0);
|
}, 0);
|
||||||
} else {
|
} else {
|
||||||
loadWidget(waifuPath, apiPath);
|
loadWidget(waifuPath, apiPath);
|
||||||
|
Loading…
Reference in New Issue
Block a user