Create tooltip.js
It's a mod that adds a tooltip that shows the description of a hovered element at the bottom of the screen.
This commit is contained in:
parent
4b069a9422
commit
8ab0e2d1ca
|
|
@ -0,0 +1,21 @@
|
||||||
|
const defaultTooltip = "---";
|
||||||
|
let tooltipEle;
|
||||||
|
window.addEventListener("load", ()=>{
|
||||||
|
tooltipEle = document.createElement("p");
|
||||||
|
tooltipEle.innerHTML = defaultTooltip;
|
||||||
|
document.getElementById("extraInfo").children[1].appendChild(tooltipEle);
|
||||||
|
let buttons = document.getElementsByClassName("elementButton");
|
||||||
|
[...buttons].forEach(button=>{
|
||||||
|
let ele = button.getAttribute("element");
|
||||||
|
button.addEventListener("mouseenter", e=>{
|
||||||
|
if(elements.hasOwnProperty(ele)) {
|
||||||
|
if(elements[ele].hasOwnProperty("desc")) {
|
||||||
|
tooltipEle.innerHTML = elements[ele].desc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
button.addEventListener("mouseleave", e=>{
|
||||||
|
tooltipEle.innerHTML = defaultTooltip;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue