41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
export function init() {
|
|
const enemies = document.querySelectorAll(".enemy");
|
|
|
|
for (const enemyWrapper of enemies) {
|
|
toggleWorldDisplay(enemyWrapper);
|
|
enemyWrapper.addEventListener("click", function () {
|
|
toggleWorldDisplay(this);
|
|
});
|
|
}
|
|
}
|
|
|
|
function toggleWorldDisplay(display) {
|
|
const showWorlds = display.dataset["showWorlds"] === "true";
|
|
|
|
const enemyWorlds = display.querySelector(".worlds");
|
|
const worldsWrapper = display.querySelectorAll(".worlds > div");
|
|
const worldsIcons = display.querySelectorAll(".worlds > div > img");
|
|
|
|
if (!showWorlds) {
|
|
enemyWorlds.style.width = "32px";
|
|
for (const wrapper of worldsWrapper) {
|
|
wrapper.style.height = "32px";
|
|
}
|
|
for (const icon of worldsIcons) {
|
|
icon.width = "32";
|
|
icon.height = "32";
|
|
}
|
|
} else {
|
|
enemyWorlds.style.width = "256px";
|
|
for (const wrapper of worldsWrapper) {
|
|
wrapper.style.height = "auto";
|
|
}
|
|
for (const icon of worldsIcons) {
|
|
icon.width = "64";
|
|
icon.height = "64";
|
|
}
|
|
}
|
|
|
|
display.dataset["showWorlds"] = !showWorlds;
|
|
}
|