From 3cde53eae9aa8bdc84a2f20a1e0892c79ce8172c Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Fri, 14 Aug 2020 20:33:14 -0400
Subject: [PATCH] steps to drop nationalitiescheck

---
 .../customizeSlaveTrade.js                    | 44 +++++++++++--------
 src/events/intro/introSummary.tw              | 11 +----
 2 files changed, 26 insertions(+), 29 deletions(-)

diff --git a/src/events/intro/customizeSlaveTrade/customizeSlaveTrade.js b/src/events/intro/customizeSlaveTrade/customizeSlaveTrade.js
index 563b63dfed6..94d57e6f3bb 100644
--- a/src/events/intro/customizeSlaveTrade/customizeSlaveTrade.js
+++ b/src/events/intro/customizeSlaveTrade/customizeSlaveTrade.js
@@ -34,26 +34,9 @@ App.UI.CustomSlaveTrade = function() {
 			);
 		}
 		frag.append(p);
-		p = document.createElement("p");
 
-		/* Generates cloned array of V.nationalities, removing duplicates and then sorting */
-		V.nationalitiesCheck = Object.assign({}, V.nationalities);
-
-		/* Prints distribution of V.nationalities, using V.nationalitiesCheck to render array */
-		let percentPerPoint = 100.0 / hashSum(V.nationalities);
-		let len = Object.keys(V.nationalitiesCheck).length;
-		let j = 0;
-		for (const nation in V.nationalitiesCheck) {
-			div = document.createElement("div");
-			div.append(`${nation} `);
-			App.UI.DOM.appendNewElement("span", div, (V.nationalities[nation] * percentPerPoint).toFixed(2), "orange");
-			j++;
-			if (j < len) {
-				div.append(` | `);
-			}
-			p.append(div);
-		}
-		frag.append(p);
+		App.UI.DOM.appendNewElement("p", frag, App.UI.nationalitiesCheck());
+
 		p = document.createElement("p");
 
 		/* Fine control tweaking of populations */
@@ -397,3 +380,26 @@ App.UI.CustomSlaveTrade = function() {
 		return App.UI.DOM.generateLinksStrip(links);
 	}
 };
+
+App.UI.nationalitiesCheck = function() {
+	const frag = new DocumentFragment();
+
+	/* Generates cloned array of V.nationalities, removing duplicates and then sorting */
+	V.nationalitiesCheck = Object.assign({}, V.nationalities);
+
+	/* Prints distribution of V.nationalities, using V.nationalitiesCheck to render array */
+	let percentPerPoint = 100.0 / hashSum(V.nationalities);
+	let len = Object.keys(V.nationalitiesCheck).length;
+	let j = 0;
+	for (const nation in V.nationalitiesCheck) {
+		const span = document.createElement("span");
+		span.append(`${nation} `);
+		App.UI.DOM.appendNewElement("span", span, (V.nationalities[nation] * percentPerPoint).toFixed(2), "orange");
+		j++;
+		if (j < len) {
+			span.append(` | `);
+		}
+		frag.append(span);
+	}
+	return frag;
+};
diff --git a/src/events/intro/introSummary.tw b/src/events/intro/introSummary.tw
index 8f268af067f..3b694d9ce2c 100644
--- a/src/events/intro/introSummary.tw
+++ b/src/events/intro/introSummary.tw
@@ -239,18 +239,9 @@ You may review your settings before clicking "Continue" to begin.<br>
 		.customButton("Adjust the slave trade", () => {V.customWA = 0; V.customVariety = 1}, "Customize Slave Trade")
 		.customButton("Stop customizing", () => {delete V.customVariety})>>
 
-		<<if ndef $nationalitiesCheck>> /* NGP: regenerate $nationalitiesCheck from previous game's $nationalities array */
-			<div id="SilentlyButWithStyle" style="display: none;"><<include "Customize Slave Trade">></div>
-		<</if>>
 		<<run _options.addOption("").addCustomElement(`
 			<hr style="margin:0">
-			<<set _len = Object.keys($nationalitiesCheck).length>>
-			<<set _j = 0>>
-			<<for _nation, _i range $nationalitiesCheck>>
-				<<print _nation>> @@.orange;<<print (($nationalities[_nation]/hashSum($nationalities))*100).toFixed(2)>>%@@
-				<<set _j++>>
-				<<if _j < _len>> |	<</if>>
-			<</for>>
+			App.UI.nationalitiesCheck().outerHTML
 			<br style="clear:both"><hr style="margin:0">
 		`)>>
 	<</if>> /* closes $customVariety is defined */
-- 
GitLab