diff --git a/components/fill-box.js b/components/fill-box.js
index 02912f3b..b4d075c3 100644
--- a/components/fill-box.js
+++ b/components/fill-box.js
@@ -1,7 +1,5 @@
-// fill-box cannot use Shadow DOM as it needs access to svg hatches
-// append stylesheet
{
- const style = `
+ const style = /* css */ `
fill-box:not([disabled]) {
cursor: pointer;
}
@@ -14,7 +12,8 @@
fill-box > svg > rect {
stroke: #666666;
stroke-width: 2;
- }`;
+ }
+ `;
const styleElement = document.createElement("style");
styleElement.setAttribute("type", "text/css");
@@ -24,7 +23,7 @@
{
const template = document.createElement("template");
- template.innerHTML = `
+ template.innerHTML = /* html */ `
@@ -70,5 +69,6 @@
}
}
+ // cannot use Shadow DOM here as need an access to svg hatches
customElements.define("fill-box", FillBox);
}
diff --git a/main.js b/main.js
index cdb329af..39a70d29 100644
--- a/main.js
+++ b/main.js
@@ -176,8 +176,8 @@ oceanLayers.append("rect").attr("id", "oceanBase").attr("x", 0).attr("y", 0).att
document.addEventListener("DOMContentLoaded", async () => {
if (!location.hostname) {
const wiki = "https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Run-FMG-locally";
- alertMessage.innerHTML = `Fantasy Map Generator cannot run serverless.
- Follow the instructions on how you can easily run a local web-server`;
+ alertMessage.innerHTML = /* html */ `Fantasy Map Generator cannot run serverless. Follow the instructions on how you can
+ easily run a local web-server`;
$("#alert").dialog({
resizable: false,
@@ -455,9 +455,10 @@ function showWelcomeMessage() {
const discord = link("https://discordapp.com/invite/X7E84HU", "Discord server");
const patreon = link("https://www.patreon.com/azgaar", "Patreon");
- alertMessage.innerHTML = `The Fantasy Map Generator is updated up to version ${version}.
- This version is compatible with ${changelog}, loaded .map files will be auto-updated.
-
Latest changes:
+ alertMessage.innerHTML = /* html */ `The Fantasy Map Generator is updated up to version ${version}. This version is compatible with ${changelog},
+ loaded .map files will be auto-updated.
+
+ Latest changes:
Submap tool by Goteguru
Resample tool by Goteguru
Pre-defined heightmaps
@@ -713,8 +714,7 @@ async function generate() {
const parsedError = parseError(error);
clearMainTip();
- alertMessage.innerHTML = `An error has occurred on map generation. Please retry.
- If error is critical, clear the stored data and try again.
+ alertMessage.innerHTML = /* html */ `An error has occurred on map generation. Please retry. If error is critical, clear the stored data and try again.
${parsedError}
`;
$("#alert").dialog({
resizable: false,
diff --git a/modules/burgs-and-states.js b/modules/burgs-and-states.js
index e64e3e77..f3f5164e 100644
--- a/modules/burgs-and-states.js
+++ b/modules/burgs-and-states.js
@@ -41,7 +41,7 @@ window.BurgsAndStates = (function () {
if (sorted.length < count * 10) {
count = Math.floor(sorted.length / 10);
if (!count) {
- WARN && console.warn(`There is no populated cells. Cannot generate states`);
+ WARN && console.warn("There is no populated cells. Cannot generate states");
return burgs;
} else {
WARN && console.warn(`Not enough populated cells (${sorted.length}). Will generate only ${count} states`);
@@ -883,7 +883,7 @@ window.BurgsAndStates = (function () {
dd.forEach((r, d) => {
if (r !== "Ally" || states[d].diplomacy.includes("Vassal")) return;
if (states[d].diplomacy[attacker] !== "Rival" && ap / dp > 2 * gauss(1.6, 0.8, 0, 10, 2)) {
- const reason = states[d].diplomacy.includes("Enemy") ? `Being already at war,` : `Frightened by ${an},`;
+ const reason = states[d].diplomacy.includes("Enemy") ? "Being already at war," : `Frightened by ${an},`;
war.push(`${reason} ${states[d].name} severed the defense pact with ${dn}`);
dd[d] = states[d].diplomacy[defender] = "Suspicion";
return;
diff --git a/modules/cultures-generator.js b/modules/cultures-generator.js
index b4733260..37f5bc93 100644
--- a/modules/cultures-generator.js
+++ b/modules/cultures-generator.js
@@ -15,9 +15,8 @@ window.Cultures = (function () {
if (!count) {
WARN && console.warn(`There are no populated cells. Cannot generate cultures`);
pack.cultures = [{name: "Wildlands", i: 0, base: 1, shield: "round"}];
- alertMessage.innerHTML = `
- The climate is harsh and people cannot live in this world.
- No cultures, states and burgs will be created.
+ alertMessage.innerHTML = /* html */ ` The climate is harsh and people cannot live in this world.
+ No cultures, states and burgs will be created.
Please consider changing climate settings in the World Configurator`;
$("#alert").dialog({
resizable: false,
@@ -31,9 +30,8 @@ window.Cultures = (function () {
return;
} else {
WARN && console.warn(`Not enough populated cells (${populated.length}). Will generate only ${count} cultures`);
- alertMessage.innerHTML = `
- There are only ${populated.length} populated cells and it's insufficient livable area.
- Only ${count} out of ${culturesInput.value} requested cultures will be generated.
+ alertMessage.innerHTML = /* html */ ` There are only ${populated.length} populated cells and it's insufficient livable area.
+ Only ${count} out of ${culturesInput.value} requested cultures will be generated.
Please consider changing climate settings in the World Configurator`;
$("#alert").dialog({
resizable: false,
diff --git a/modules/io/auto-update.js b/modules/io/auto-update.js
index 064af0ad..08b9c056 100644
--- a/modules/io/auto-update.js
+++ b/modules/io/auto-update.js
@@ -69,7 +69,7 @@ export function resolveVersionConflicts(version) {
labels.selectAll("textPath").each(function () {
const text = this.textContent;
const shift = this.getComputedTextLength() / -1.5;
- this.innerHTML = `${text}`;
+ this.innerHTML = /* html */ `${text}`;
});
// v1.0 added new biome - Wetland
@@ -362,7 +362,7 @@ export function resolveVersionConflicts(version) {
const pattern = document.getElementById("oceanic");
const filter = pattern.firstElementChild.getAttribute("filter");
const href = filter ? "./images/" + filter.replace("url(#", "").replace(")", "") + ".png" : "";
- pattern.innerHTML = ``;
+ pattern.innerHTML = /* html */ ``;
}
if (version < 1.62) {
diff --git a/modules/io/load.js b/modules/io/load.js
index 75687c05..f031e69f 100644
--- a/modules/io/load.js
+++ b/modules/io/load.js
@@ -50,8 +50,8 @@ function loadMapPrompt(blob) {
return;
}
- alertMessage.innerHTML = `Are you sure you want to load saved map?
- All unsaved changes made to the current map will be lost`;
+ alertMessage.innerHTML = /* html */ `Are you sure you want to load saved map?
+ All unsaved changes made to the current map will be lost`;
$("#alert").dialog({
resizable: false,
title: "Load saved map",
@@ -94,9 +94,10 @@ function loadMapFromURL(maplink, random) {
function showUploadErrorMessage(error, URL, random) {
ERROR && console.error(error);
- alertMessage.innerHTML = `Cannot load map from the ${link(URL, "link provided")}.
- ${random ? `A new random map is generated. ` : ""}
- Please ensure the linked file is reachable and CORS is allowed on server side`;
+ alertMessage.innerHTML = /* html */ `Cannot load map from the ${link(URL, "link provided")}. ${
+ random ? `A new random map is generated. ` : ""
+ } Please ensure the
+ linked file is reachable and CORS is allowed on server side`;
$("#alert").dialog({
title: "Loading error",
width: "32em",
@@ -563,8 +564,7 @@ async function parseLoadedData(data) {
ERROR && console.error(error);
clearMainTip();
- alertMessage.innerHTML = `An error is occured on map loading. Select a different file to load,
- generate a new random map or cancel the loading
+ alertMessage.innerHTML = /* html */ `An error is occured on map loading. Select a different file to load, generate a new random map or cancel the loading
+ `;
}
body.innerHTML = lines;
diff --git a/modules/ui/burg-editor.js b/modules/ui/burg-editor.js
index 0e7aacf0..ea3a76f2 100644
--- a/modules/ui/burg-editor.js
+++ b/modules/ui/burg-editor.js
@@ -281,10 +281,10 @@ function editBurg(id) {
const burgsToRemove = burgsInGroup.filter(b => !(pack.burgs[b].capital || pack.burgs[b].lock));
const capital = burgsToRemove.length < burgsInGroup.length;
- alertMessage.innerHTML = `Are you sure you want to remove
- ${basic || capital ? "all unlocked elements in the burg group" : "the entire burg group"}?
- Please note that capital or locked burgs will not be deleted.
-
Burgs to be removed: ${burgsToRemove.length}`;
+ alertMessage.innerHTML = /* html */ `Are you sure you want to remove ${
+ basic || capital ? "all unlocked elements in the burg group" : "the entire burg group"
+ }?
+ Please note that capital or locked burgs will not be deleted.
Burgs to be removed: ${burgsToRemove.length}`;
$("#alert").dialog({
resizable: false,
title: "Remove burg group",
@@ -545,7 +545,7 @@ function editBurg(id) {
function removeSelectedBurg() {
const id = +elSelected.attr("data-id");
if (pack.burgs[id].capital) {
- alertMessage.innerHTML = `You cannot remove the burg as it is a state capital.
+ alertMessage.innerHTML = /* html */ `You cannot remove the burg as it is a state capital.
You can change the capital using Burgs Editor (shift + T)`;
$("#alert").dialog({
resizable: false,
diff --git a/modules/ui/burgs-overview.js b/modules/ui/burgs-overview.js
index 454671cb..bf819465 100644
--- a/modules/ui/burgs-overview.js
+++ b/modules/ui/burgs-overview.js
@@ -82,22 +82,30 @@ function overviewBurgs() {
const province = prov ? pack.provinces[prov].name : "";
const culture = pack.cultures[b.culture].name;
- lines += `
- ${stateSection}
- ${provinceSections}
- ${burgSections}
- ${neutralsSection}
- Generated by ${FMG}. The tool is free, but images may be copyrighted, see ${license}
- `;
+ const html = /* html */ `
+
+
+ ${mapName.value} Emblems Gallery
+
+
+
+
+
${mapName.value} Emblems Gallery
+ ${stateSection} ${provinceSections} ${burgSections} ${neutralsSection}
+ Generated by ${FMG}. The tool is free, but images may be copyrighted, see ${license}
+
+ `;
downloadFile(html, name + ".html", "text/plain");
}
}
@@ -409,9 +482,9 @@ function editEmblem(type, id, el) {
async function renderAllEmblems(states, provinces, burgs) {
tip("Preparing for download...", true, "warn");
- const statePromises = states.map(state => COArenderer.trigger("stateCOA"+state.i, state.coa));
- const provincePromises = provinces.map(province => COArenderer.trigger("provinceCOA"+province.i, province.coa));
- const burgPromises = burgs.map(burg => COArenderer.trigger("burgCOA"+burg.i, burg.coa));
+ const statePromises = states.map(state => COArenderer.trigger("stateCOA" + state.i, state.coa));
+ const provincePromises = provinces.map(province => COArenderer.trigger("provinceCOA" + province.i, province.coa));
+ const burgPromises = burgs.map(burg => COArenderer.trigger("burgCOA" + burg.i, burg.coa));
const promises = [...statePromises, ...provincePromises, ...burgPromises];
return Promise.allSettled(promises).then(res => clearMainTip());
@@ -419,10 +492,11 @@ function editEmblem(type, id, el) {
function dragEmblem() {
const tr = parseTransform(this.getAttribute("transform"));
- const x = +tr[0] - d3.event.x, y = +tr[1] - d3.event.y;
+ const x = +tr[0] - d3.event.x,
+ y = +tr[1] - d3.event.y;
- d3.event.on("drag", function() {
- const transform = `translate(${(x + d3.event.x)},${(y + d3.event.y)})`;
+ d3.event.on("drag", function () {
+ const transform = `translate(${x + d3.event.x},${y + d3.event.y})`;
this.setAttribute("transform", transform);
});
}
@@ -430,4 +504,4 @@ function editEmblem(type, id, el) {
function closeEmblemEditor() {
emblems.selectAll("use").call(d3.drag().on("drag", null)).attr("class", null);
}
-}
\ No newline at end of file
+}
diff --git a/modules/ui/general.js b/modules/ui/general.js
index 91605161..db08473e 100644
--- a/modules/ui/general.js
+++ b/modules/ui/general.js
@@ -405,7 +405,7 @@ document.querySelectorAll("[data-locked]").forEach(function (e) {
// lock option
function lock(id) {
- const input = document.querySelector("[data-stored=\"" + id + "\"]");
+ const input = document.querySelector('[data-stored="' + id + '"]');
if (input) localStorage.setItem(id, input.value);
const el = document.getElementById("lock_" + id);
if (!el) return;
@@ -467,15 +467,18 @@ function showInfo() {
const QAA = link("https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Q&A", "Q&A page");
const VideoTutorial = link("https://youtube.com/playlist?list=PLtgiuDC8iVR2gIG8zMTRn7T_L0arl9h1C", "Video tutorial");
- alertMessage.innerHTML = `
- Fantasy Map Generator (FMG) is a free open-source application.
- It means that you own all created maps and can use them as you wish.
+ alertMessage.innerHTML = /* html */ `Fantasy Map Generator (FMG) is a free open-source application. It means that you own all created maps and can use them as
+ you wish.
-
The development is community-backed, you can donate on ${Patreon}.
- You can also help creating overviews, tutorials and spreding the word about the Generator.
+
+ The development is community-backed, you can donate on ${Patreon}. You can also help creating overviews, tutorials and spreding the word about the
+ Generator.
+
-
The best way to get help is to contact the community on ${Discord} and ${Reddit}.
- Before asking questions, please check out the ${QuickStart}, the ${QAA}, and ${VideoTutorial}.
+
+ The best way to get help is to contact the community on ${Discord} and ${Reddit}. Before asking questions, please check out the ${QuickStart}, the ${QAA},
+ and ${VideoTutorial}.
+
Check out our another project: ${Armoria} — heraldry generator and editor.
diff --git a/modules/ui/heightmap-editor.js b/modules/ui/heightmap-editor.js
index effb81c7..fae944f3 100644
--- a/modules/ui/heightmap-editor.js
+++ b/modules/ui/heightmap-editor.js
@@ -2,12 +2,14 @@
function editHeightmap() {
void (function selectEditMode() {
- alertMessage.innerHTML = `Heightmap is a core element on which all other data (rivers, burgs, states etc) is based.
- So the best edit approach is to erase the secondary data and let the system automatically regenerate it on edit completion.
+ alertMessage.innerHTML = /* html */ `Heightmap is a core element on which all other data (rivers, burgs, states etc) is based. So the best edit approach is to
+ erase the secondary data and let the system automatically regenerate it on edit completion.
Erase mode also allows you Convert an Image into a heightmap or use Template Editor.
You can keep the data, but you won't be able to change the coastline.
-
Try risk mode to change the coastline and keep the data. The data will be restored as much as possible, but it can cause unpredictable errors.
-
Please save the map before editing the heightmap!
+
+ Try risk mode to change the coastline and keep the data. The data will be restored as much as possible, but it can cause unpredictable errors.
+
+
Please save the map before editing the heightmap!
Check out ${link("https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Heightmap-customization", "wiki")} for guidance.
`;
$("#alert").dialog({
@@ -107,7 +109,7 @@ function editHeightmap() {
heightmapInfoX.innerHTML = rn(p[0]);
heightmapInfoY.innerHTML = rn(p[1]);
heightmapInfoCell.innerHTML = cell;
- heightmapInfoHeight.innerHTML = `${grid.cells.h[cell]} (${getHeight(grid.cells.h[cell])})`;
+ heightmapInfoHeight.innerHTML = /* html */ `${grid.cells.h[cell]} (${getHeight(grid.cells.h[cell])})`;
if (tooltip.dataset.main) showMainTip();
// move radius circle if drag mode is active
@@ -485,7 +487,7 @@ function editHeightmap() {
function updateStatistics() {
const landCells = grid.cells.h.reduce((s, h) => (h >= 20 ? s + 1 : s));
- landmassCounter.innerHTML = `${landCells} (${rn((landCells / grid.cells.i.length) * 100)}%)`;
+ landmassCounter.innerHTML = /* html */ `${landCells} (${rn((landCells / grid.cells.i.length) * 100)}%)`;
landmassAverage.innerHTML = rn(d3.mean(grid.cells.h));
}
@@ -1247,11 +1249,8 @@ function editHeightmap() {
function closeImageConverter(event) {
event.preventDefault();
event.stopPropagation();
- alertMessage.innerHTML = `
- Are you sure you want to close the Image Converter?
- Click "Cancel" to geck back to convertion.
- Click "Complete" to apply the conversion.
- Click "Close" to exit conversion mode and restore previous heightmap`;
+ alertMessage.innerHTML = /* html */ ` Are you sure you want to close the Image Converter? Click "Cancel" to geck back to convertion. Click "Complete" to apply
+ the conversion. Click "Close" to exit conversion mode and restore previous heightmap`;
$("#alert").dialog({
resizable: false,
diff --git a/modules/ui/ice-editor.js b/modules/ui/ice-editor.js
index f6648f48..5951e7aa 100644
--- a/modules/ui/ice-editor.js
+++ b/modules/ui/ice-editor.js
@@ -12,7 +12,8 @@ function editIce() {
ice.selectAll("*").classed("draggable", true).call(d3.drag().on("drag", dragElement));
$("#iceEditor").dialog({
- title: "Edit "+type, resizable: false,
+ title: "Edit " + type,
+ resizable: false,
position: {my: "center top+60", at: "top", of: d3.event, collision: "fit"},
close: closeEditor
});
@@ -30,8 +31,9 @@ function editIce() {
function randomizeShape() {
const c = grid.points[+elSelected.attr("cell")];
const s = +elSelected.attr("size");
- const i = ra(grid.cells.i), cn = grid.points[i];
- const poly = getGridPolygon(i).map(p => [p[0]-cn[0], p[1]-cn[1]]);
+ const i = ra(grid.cells.i),
+ cn = grid.points[i];
+ const poly = getGridPolygon(i).map(p => [p[0] - cn[0], p[1] - cn[1]]);
const points = poly.map(p => [rn(c[0] + p[0] * s, 2), rn(c[1] + p[1] * s, 2)]);
elSelected.attr("points", points);
}
@@ -39,10 +41,13 @@ function editIce() {
function changeSize() {
const c = grid.points[+elSelected.attr("cell")];
const s = +elSelected.attr("size");
- const flat = elSelected.attr("points").split(",").map(el => +el);
+ const flat = elSelected
+ .attr("points")
+ .split(",")
+ .map(el => +el);
const pairs = [];
- while (flat.length) pairs.push(flat.splice(0,2));
- const poly = pairs.map(p => [(p[0]-c[0]) / s, (p[1]-c[1]) / s]);
+ while (flat.length) pairs.push(flat.splice(0, 2));
+ const poly = pairs.map(p => [(p[0] - c[0]) / s, (p[1] - c[1]) / s]);
const size = +this.value;
const points = poly.map(p => [rn(c[0] + p[0] * size, 2), rn(c[1] + p[1] * size, 2)]);
elSelected.attr("points", points).attr("size", size);
@@ -65,7 +70,7 @@ function editIce() {
const c = grid.points[i];
const s = +document.getElementById("iceSize").value;
- const points = getGridPolygon(i).map(p => [(p[0] + (c[0]-p[0]) / s)|0, (p[1] + (c[1]-p[1]) / s)|0]);
+ const points = getGridPolygon(i).map(p => [(p[0] + (c[0] - p[0]) / s) | 0, (p[1] + (c[1] - p[1]) / s) | 0]);
const iceberg = ice.append("polygon").attr("points", points).attr("cell", i).attr("size", s);
iceberg.call(d3.drag().on("drag", dragElement));
if (d3.event.shiftKey === false) toggleAdd();
@@ -73,26 +78,32 @@ function editIce() {
function removeIce() {
const type = elSelected.attr("type") ? "Glacier" : "Iceberg";
- alertMessage.innerHTML = `Are you sure you want to remove the ${type}?`;
- $("#alert").dialog({resizable: false, title: "Remove "+type,
+ alertMessage.innerHTML = /* html */ `Are you sure you want to remove the ${type}?`;
+ $("#alert").dialog({
+ resizable: false,
+ title: "Remove " + type,
buttons: {
- Remove: function() {
+ Remove: function () {
$(this).dialog("close");
elSelected.remove();
$("#iceEditor").dialog("close");
},
- Cancel: function() {$(this).dialog("close");}
+ Cancel: function () {
+ $(this).dialog("close");
+ }
}
});
}
function dragElement() {
const tr = parseTransform(this.getAttribute("transform"));
- const dx = +tr[0] - d3.event.x, dy = +tr[1] - d3.event.y;
+ const dx = +tr[0] - d3.event.x,
+ dy = +tr[1] - d3.event.y;
- d3.event.on("drag", function() {
- const x = d3.event.x, y = d3.event.y;
- this.setAttribute("transform", `translate(${(dx+x)},${(dy+y)})`);
+ d3.event.on("drag", function () {
+ const x = d3.event.x,
+ y = d3.event.y;
+ this.setAttribute("transform", `translate(${dx + x},${dy + y})`);
});
}
diff --git a/modules/ui/labels-editor.js b/modules/ui/labels-editor.js
index 3d7a3b7f..8bd04cdd 100644
--- a/modules/ui/labels-editor.js
+++ b/modules/ui/labels-editor.js
@@ -257,9 +257,10 @@ function editLabel() {
const group = elSelected.node().parentNode.id;
const basic = group === "states" || group === "addedLabels";
const count = elSelected.node().parentNode.childElementCount;
- alertMessage.innerHTML = `Are you sure you want to remove
- ${basic ? "all elements in the group" : "the entire label group"}?
-
Labels to be removed: ${count}`;
+ alertMessage.innerHTML = /* html */ `Are you sure you want to remove ${
+ basic ? "all elements in the group" : "the entire label group"
+ }?
Labels to be
+ removed: ${count}`;
$("#alert").dialog({
resizable: false,
title: "Remove route group",
diff --git a/modules/ui/lakes-editor.js b/modules/ui/lakes-editor.js
index 3f1e4d60..eba1bd0d 100644
--- a/modules/ui/lakes-editor.js
+++ b/modules/ui/lakes-editor.js
@@ -5,7 +5,8 @@ function editLake() {
if (layerIsOn("toggleCells")) toggleCells();
$("#lakeEditor").dialog({
- title: "Edit Lake", resizable: false,
+ title: "Edit Lake",
+ resizable: false,
position: {my: "center top+20", at: "top", of: d3.event, collision: "fit"},
close: closeLakesEditor
});
@@ -71,23 +72,41 @@ function editLake() {
function drawLakeVertices() {
const v = getLake().vertices; // lake outer vertices
- const c = [... new Set(v.map(v => pack.vertices.c[v]).flat())];
- debug.select("#vertices").selectAll("polygon").data(c).enter().append("polygon")
- .attr("points", d => getPackPolygon(d)).attr("data-c", d => d);
+ const c = [...new Set(v.map(v => pack.vertices.c[v]).flat())];
+ debug
+ .select("#vertices")
+ .selectAll("polygon")
+ .data(c)
+ .enter()
+ .append("polygon")
+ .attr("points", d => getPackPolygon(d))
+ .attr("data-c", d => d);
- debug.select("#vertices").selectAll("circle").data(v).enter().append("circle")
- .attr("cx", d => pack.vertices.p[d][0]).attr("cy", d => pack.vertices.p[d][1])
- .attr("r", .4).attr("data-v", d => d).call(d3.drag().on("drag", dragVertex))
+ debug
+ .select("#vertices")
+ .selectAll("circle")
+ .data(v)
+ .enter()
+ .append("circle")
+ .attr("cx", d => pack.vertices.p[d][0])
+ .attr("cy", d => pack.vertices.p[d][1])
+ .attr("r", 0.4)
+ .attr("data-v", d => d)
+ .call(d3.drag().on("drag", dragVertex))
.on("mousemove", () => tip("Drag to move the vertex, please use for fine-tuning only. Edit heightmap to change actual cell heights"));
}
function dragVertex() {
- const x = rn(d3.event.x, 2), y = rn(d3.event.y, 2);
+ const x = rn(d3.event.x, 2),
+ y = rn(d3.event.y, 2);
this.setAttribute("cx", x);
this.setAttribute("cy", y);
const v = +this.dataset.v;
pack.vertices.p[v] = [x, y];
- debug.select("#vertices").selectAll("polygon").attr("points", d => getPackPolygon(d));
+ debug
+ .select("#vertices")
+ .selectAll("polygon")
+ .attr("points", d => getPackPolygon(d));
redrawLake();
}
@@ -97,7 +116,7 @@ function editLake() {
const points = feature.vertices.map(v => pack.vertices.p[v]);
const d = round(lineGen(points));
elSelected.attr("d", d);
- defs.select("mask#land > path#land_"+feature.i).attr("d", d); // update land mask
+ defs.select("mask#land > path#land_" + feature.i).attr("d", d); // update land mask
const unit = areaUnit.value === "square" ? " " + distanceUnitInput.value + "²" : " " + areaUnit.value;
feature.area = Math.abs(d3.polygonArea(points));
@@ -115,7 +134,7 @@ function editLake() {
function generateNameRandom() {
const lake = getLake();
- lake.name = lakeName.value = Names.getBase(rand(nameBases.length-1));
+ lake.name = lakeName.value = Names.getBase(rand(nameBases.length - 1));
}
function selectLakeGroup(node) {
@@ -123,7 +142,7 @@ function editLake() {
const select = document.getElementById("lakeGroup");
select.options.length = 0; // remove all options
- lakes.selectAll("g").each(function() {
+ lakes.selectAll("g").each(function () {
select.options.add(new Option(this.id, this.id, false, this.id === group));
});
}
@@ -141,12 +160,18 @@ function editLake() {
} else {
lakeGroupName.style.display = "none";
lakeGroup.style.display = "inline-block";
- }
+ }
}
function createNewGroup() {
- if (!this.value) {tip("Please provide a valid group name"); return;}
- const group = this.value.toLowerCase().replace(/ /g, "_").replace(/[^\w\s]/gi, "");
+ if (!this.value) {
+ tip("Please provide a valid group name");
+ return;
+ }
+ const group = this.value
+ .toLowerCase()
+ .replace(/ /g, "_")
+ .replace(/[^\w\s]/gi, "");
if (document.getElementById(group)) {
tip("Element with this id already exists. Please provide a unique name", false, "error");
@@ -180,7 +205,7 @@ function editLake() {
toggleNewGroupInput();
document.getElementById("lakeGroupName").value = "";
}
-
+
function removeLakeGroup() {
const group = elSelected.node().parentNode.id;
if (["freshwater", "salt", "sinkhole", "frozen", "lava", "dry"].includes(group)) {
@@ -189,11 +214,13 @@ function editLake() {
}
const count = elSelected.node().parentNode.childElementCount;
- alertMessage.innerHTML = `Are you sure you want to remove the group?
- All lakes of the group (${count}) will be turned into Freshwater`;
- $("#alert").dialog({resizable: false, title: "Remove lake group", width:"26em",
+ alertMessage.innerHTML = /* html */ `Are you sure you want to remove the group? All lakes of the group (${count}) will be turned into Freshwater`;
+ $("#alert").dialog({
+ resizable: false,
+ title: "Remove lake group",
+ width: "26em",
buttons: {
- Remove: function() {
+ Remove: function () {
$(this).dialog("close");
const freshwater = document.getElementById("freshwater");
const groupEl = document.getElementById(group);
@@ -204,7 +231,9 @@ function editLake() {
document.getElementById("lakeGroup").selectedOptions[0].remove();
document.getElementById("lakeGroup").value = "freshwater";
},
- Cancel: function() {$(this).dialog("close");}
+ Cancel: function () {
+ $(this).dialog("close");
+ }
}
});
}
@@ -223,4 +252,4 @@ function editLake() {
debug.select("#vertices").remove();
unselect();
}
-}
\ No newline at end of file
+}
diff --git a/modules/ui/military-overview.js b/modules/ui/military-overview.js
index 0d244314..24cf9367 100644
--- a/modules/ui/military-overview.js
+++ b/modules/ui/military-overview.js
@@ -75,18 +75,30 @@ function overviewMilitary() {
const sortData = options.military.map(u => `data-${u.name}="${getForces(u)}"`).join(" ");
const lineData = options.military.map(u => `