This commit is contained in:
Azgaar 2019-09-28 20:25:53 +03:00
parent 5b163bc809
commit 1c5f9f7ab6
5 changed files with 250 additions and 7 deletions

View file

@ -297,16 +297,17 @@ function editStates() {
const rural = rn(s.rural * populationRate.value);
const urban = rn(s.urban * populationRate.value * urbanization.value);
const total = rural + urban;
const l = n => Number(n).toLocaleString();
alertMessage.innerHTML = `
Rural: <input type="number" min=0 step=1 id="ruralPop" value=${rural} style="width:6em" ${s.cells?'':"disabled"}>
Rural: <input type="number" min=0 step=1 id="ruralPop" value=${rural} style="width:6em">
Urban: <input type="number" min=0 step=1 id="urbanPop" value=${urban} style="width:6em" ${s.burgs?'':"disabled"}>
<p>Total population: ${total} <span id="totalPop">${total}</span> (<span id="totalPopPerc">100</span>%)</p>`;
<p>Total population: ${l(total)} <span id="totalPop">${l(total)}</span> (<span id="totalPopPerc">100</span>%)</p>`;
const update = function() {
const totalNew = ruralPop.valueAsNumber + urbanPop.valueAsNumber;
if (isNaN(totalNew)) return;
totalPop.innerHTML = totalNew;
totalPop.innerHTML = l(totalNew);
totalPopPerc.innerHTML = rn(totalNew / total * 100);
}
@ -314,7 +315,7 @@ function editStates() {
urbanPop.oninput = () => update();
$("#alert").dialog({
resizable: false, title: "Change state population", width: "23em", buttons: {
resizable: false, title: "Change state population", width: "24em", buttons: {
Apply: function() {applyPopulationChange(); $(this).dialog("close");},
Cancel: function() {$(this).dialog("close");}
}, position: {my: "center", at: "center", of: "svg"}