Use vanilla javascript

This commit is contained in:
Mimi 2019-12-04 23:56:02 +08:00
parent 359d4c9942
commit d8a1d6afd4

View File

@ -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);
}); });
}); });