fix: year and era - unlock both on lock icon click

This commit is contained in:
Azgaar 2024-09-02 12:16:51 +02:00
parent 23e2484526
commit d42fd5cf92
3 changed files with 13 additions and 9 deletions

View file

@ -429,17 +429,19 @@ function highlightEmblemElement(type, el) {
// assign lock behavior
document.querySelectorAll("[data-locked]").forEach(function (e) {
e.addEventListener("mouseover", function (event) {
e.addEventListener("mouseover", e => {
e.stopPropagation();
if (this.className === "icon-lock")
tip("Click to unlock the option and allow it to be randomized on new map generation");
else tip("Click to lock the option and always use the current value on new map generation");
event.stopPropagation();
});
e.addEventListener("click", function () {
const id = this.id.slice(5);
if (this.className === "icon-lock") unlock(id);
else lock(id);
const fn = this.className === "icon-lock" ? unlock : lock;
const ids = this.dataset.ids.split(",");
if (ids.length) ids.forEach(fn);
else fn(this.id.slice(5));
});
});