refactor: replace fmg.modules with local vars

This commit is contained in:
Azgaar 2022-07-09 00:40:12 +03:00
parent 80bf0ef688
commit a97e7f44f6
31 changed files with 141 additions and 95 deletions

View file

@ -30,7 +30,7 @@ function clicked() {
const p = d3.mouse(this);
const i = findCell(p[0], p[1]);
if (grand.id === "emblems") editEmblem();
if (grand.id === "emblems") openDialog("emblemEditor", null, defineEmblemData(+el.dataset.i, parent));
else if (parent.id === "rivers") editRiver(el.id);
else if (grand.id === "routes") editRoute();
else if (el.tagName === "tspan" && grand.parentNode.parentNode.id === "labels") editLabel();
@ -45,6 +45,16 @@ function clicked() {
} else if (grand.id === "lakes") editLake();
}
function defineEmblemData(i, parent) {
const [g, type] =
parent.id === "burgEmblems"
? [pack.burgs, "burg"]
: parent.id === "provinceEmblems"
? [pack.provinces, "province"]
: [pack.states, "state"];
return {type, id: type + "COA" + i, el: g[i]};
}
const onMouseMove = debounce(handleMouseMove, 100);
function handleMouseMove() {
const point = d3.mouse(this);