From 41bd157165b9c60f2cad21ebe705ea40f6cfc177 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Mon, 15 May 2023 01:00:25 +0400 Subject: [PATCH] feat(#942): coord data for burgs, markers and regiments csv --- index.html | 6 ++-- modules/ui/burgs-overview.js | 51 ++++++++++++++++++++++------- modules/ui/markers-overview.js | 20 ++++++++---- modules/ui/regiments-overview.js | 56 ++++++++++++++++++++++---------- versioning.js | 2 +- 5 files changed, 97 insertions(+), 38 deletions(-) diff --git a/index.html b/index.html index a221df2a..ff7c5515 100644 --- a/index.html +++ b/index.html @@ -7889,11 +7889,11 @@ - + - - + + diff --git a/modules/ui/burgs-overview.js b/modules/ui/burgs-overview.js index bf819465..5920c442 100644 --- a/modules/ui/burgs-overview.js +++ b/modules/ui/burgs-overview.js @@ -93,7 +93,9 @@ function overviewBurgs() { data-type="${type}" > - + ${r.icon} @@ -79,7 +83,9 @@ function overviewRegiments(state) { lines += /* html */ `
Regiments: ${regiments.length}
- ${options.military.map(u => `
${si(d3.sum(regiments.map(r => r.u[u.name] || 0)))}
`).join(" ")} + ${options.military + .map(u => `
${si(d3.sum(regiments.map(r => r.u[u.name] || 0)))}
`) + .join(" ")}
${si(d3.sum(regiments.map(r => r.a)))}
`; @@ -92,7 +98,9 @@ function overviewRegiments(state) { // add listeners body.querySelectorAll("div.states").forEach(el => el.addEventListener("mouseenter", ev => regimentHighlightOn(ev))); - body.querySelectorAll("div.states").forEach(el => el.addEventListener("mouseleave", ev => regimentHighlightOff(ev))); + body + .querySelectorAll("div.states") + .forEach(el => el.addEventListener("mouseleave", ev => regimentHighlightOff(ev))); } function updateFilter(state) { @@ -158,10 +166,7 @@ function overviewRegiments(state) { function addRegimentOnClick() { const state = +regimentsFilter.value; - if (state === -1) { - tip("Please select state from the list", false, "error"); - return; - } + if (state === -1) return tip("Please select state from the list", false, "error"); const point = d3.mouse(this); const cell = findCell(point[0], point[1]); @@ -180,15 +185,32 @@ function overviewRegiments(state) { function downloadRegimentsData() { const units = options.military.map(u => u.name); - let data = "State,Id,Name," + units.map(u => capitalize(u)).join(",") + ",Total\n"; // headers + let data = + "State,Id,Icon,Name," + + units.map(u => capitalize(u)).join(",") + + ",X,Y,Latitude,Longitude,Base X,Base Y,Base Latitude,Base Longitude\n"; // headers - body.querySelectorAll(":scope > div:not(.totalLine)").forEach(function (el) { - data += el.dataset.state + ","; - data += el.dataset.id + ","; - data += el.dataset.name + ","; - data += units.map(u => el.dataset[u]).join(",") + ","; - data += el.dataset.total + "\n"; - }); + for (const s of pack.states) { + if (!s.i || s.removed || !s.military.length) continue; + + for (const r of s.military) { + data += s.name + ","; + data += r.i + ","; + data += r.icon + ","; + data += r.name + ","; + data += units.map(unit => r.u[unit]).join(",") + ","; + + data += r.x + ","; + data += r.y + ","; + data += getLatitude(r.y, 2) + ","; + data += getLongitude(r.x, 2) + ","; + + data += r.bx + ","; + data += r.by + ","; + data += getLatitude(r.by, 2) + ","; + data += getLongitude(r.bx, 2) + "\n"; + } + } const name = getFileName("Regiments") + ".csv"; downloadFile(data, name); diff --git a/versioning.js b/versioning.js index 94580ba9..e8a1a06c 100644 --- a/versioning.js +++ b/versioning.js @@ -1,7 +1,7 @@ "use strict"; // version and caching control -const version = "1.89.19"; // generator version, update each time +const version = "1.89.20"; // generator version, update each time { document.title += " v" + version;