1
0
Fork 0
forked from Simnation/Main
Main/resources/[carscripts]/jg-textui/web/main.js
2025-08-04 20:32:58 +02:00

19 lines
528 B
JavaScript

(function () {
const textUI = document.querySelector(".text-ui");
window.addEventListener("message", (evt) => {
const { data } = evt;
if (!data) return false;
if (data.type === "show") {
// If the string contains a key in square brackets (like [E]), then style it differently!
let str = data.text.replaceAll(/\[(.*?)\]/g, "<kbd>$1</kbd>");
textUI.style.left = "20px";
textUI.innerHTML = str;
} else if (data.type === "hide") {
textUI.style.left = "-100%";
}
});
})();