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
359d4c9942
commit
d8a1d6afd4
@ -160,16 +160,18 @@ function loadWidget(waifuPath, apiPath) {
|
|||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(result => {
|
.then(result => {
|
||||||
result.mouseover.forEach(tips => {
|
result.mouseover.forEach(tips => {
|
||||||
$(document).on("mouseover", tips.selector, function() {
|
window.addEventListener("mouseover", event => {
|
||||||
|
if (!event.target.matches(tips.selector)) return;
|
||||||
var text = Array.isArray(tips.text) ? tips.text[Math.floor(Math.random() * tips.text.length)] : tips.text;
|
var text = Array.isArray(tips.text) ? tips.text[Math.floor(Math.random() * tips.text.length)] : tips.text;
|
||||||
text = text.replace("{text}", $(this).text());
|
text = text.replace("{text}", event.target.innerText);
|
||||||
showMessage(text, 4000, 8);
|
showMessage(text, 4000, 8);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
result.click.forEach(tips => {
|
result.click.forEach(tips => {
|
||||||
$(document).on("click", tips.selector, function() {
|
window.addEventListener("click", event => {
|
||||||
|
if (!event.target.matches(tips.selector)) return;
|
||||||
var text = Array.isArray(tips.text) ? tips.text[Math.floor(Math.random() * tips.text.length)] : tips.text;
|
var text = Array.isArray(tips.text) ? tips.text[Math.floor(Math.random() * tips.text.length)] : tips.text;
|
||||||
text = text.replace("{text}", $(this).text());
|
text = text.replace("{text}", event.target.innerText);
|
||||||
showMessage(text, 4000, 8);
|
showMessage(text, 4000, 8);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user