From fc5c1d8089a1929d9b5efb6d0e4b87ac86ce7f9a Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Mon, 1 Jun 2020 17:05:27 -0700
Subject: [PATCH] Cleanup.  Remove App.UI.DOM.includeDOM() in favor of the
 <<includeDOM>> macro.

---
 src/endWeek/slaveAssignmentReport.js          |  7 ------
 src/gui/multipleInspect.js                    | 23 ++-----------------
 src/js/main.js                                |  6 ++---
 src/js/utilsDOM.js                            | 15 ------------
 src/uncategorized/householdLiquidator.tw      |  2 +-
 src/uncategorized/main.tw                     |  2 +-
 .../reFSEgyptianRevivalistAcquisition.tw      |  2 +-
 src/uncategorized/recETS.tw                   |  2 +-
 src/uncategorized/slaveAssignmentsReport.tw   |  3 +--
 9 files changed, 10 insertions(+), 52 deletions(-)

diff --git a/src/endWeek/slaveAssignmentReport.js b/src/endWeek/slaveAssignmentReport.js
index ac7203838a9..d68248c0d9c 100644
--- a/src/endWeek/slaveAssignmentReport.js
+++ b/src/endWeek/slaveAssignmentReport.js
@@ -399,13 +399,6 @@ App.EndWeek.slaveAssignmentReport = function() {
 		}
 	}
 
-	/* IMPORTANT FOR REASONS!!! */
-	// <<unset _ii>>
-	/** /Accordion */
-
-	/* release loading screen as soon as the event loop can run */
-	//App.UI.EndWeekAnim.end();
-
 	return res;
 
 	function _countPenthousePopulation() {
diff --git a/src/gui/multipleInspect.js b/src/gui/multipleInspect.js
index c46c8d3b712..508a63e29e7 100644
--- a/src/gui/multipleInspect.js
+++ b/src/gui/multipleInspect.js
@@ -4,11 +4,9 @@ App.UI.MultipleInspect = (function() {
 		V.saleDescription = (saleDescription ? 1 : 0);
 		V.applyLaw = (applyLaw ? 1 : 0);
 
-		// embedded sugarcube sucks but that's just how LSD works right now
 		const oldAS = V.activeSlave;
 		V.activeSlave = slave;
-		const frag = document.createDocumentFragment();
-		$(frag).wiki(`<<include "Long Slave Description">>`);
+		const frag = App.UI.DOM.renderPassage("Long Slave Description");
 		V.activeSlave = oldAS;
 		return frag;
 	}
@@ -47,22 +45,5 @@ App.UI.MultipleInspect = (function() {
 		return frag;
 	}
 
-	/**
-	 * Provide a mechanism to inspect multiple slaves at once (for example, for Household Liquidators and recETS).
-	 * Usable directly from SugarCube passages.
-	 * @param {Array<App.Entity.SlaveState>} slaves
-	 * @param {boolean} showFamilyTree
-	 * @param {boolean} saleDescription
-	 * @param {boolean} applyLaw
-	 * @returns {string}
-	 */
-	function MultipleInspectSugarcube(slaves, showFamilyTree, saleDescription, applyLaw) {
-		const frag = MultipleInspectDOM(slaves, showFamilyTree, saleDescription, applyLaw);
-		return App.UI.DOM.includeDOM(frag, "MultipleInspect", "div");
-	}
-
-	return {
-		DOM: MultipleInspectDOM,
-		SC: MultipleInspectSugarcube
-	};
+	return MultipleInspectDOM;
 })();
diff --git a/src/js/main.js b/src/js/main.js
index e65ab93f01e..1854c4e6343 100644
--- a/src/js/main.js
+++ b/src/js/main.js
@@ -162,11 +162,11 @@ App.MainView.useFucktoy = function(slave) {
  * @returns {HTMLDivElement}
  */
 App.MainView.useGuard = function() {
-	const guard = V.slaves[V.slaveIndices[V.Bodyguard.ID]];
+	const guard = S.Bodyguard;
 
 	const outerDiv = document.createElement("div");
 
-	if (guard === undefined || guard.assignment !== "guard you") {
+	if (!guard || guard.assignment !== "guard you") {
 		return outerDiv;
 	}
 
@@ -273,5 +273,5 @@ App.MainView.full = function() {
 		fragment.append(App.MainView.useGuard());
 	}
 
-	return App.UI.DOM.includeDOM(fragment, "mainFullDOM");
+	return fragment;
 };
diff --git a/src/js/utilsDOM.js b/src/js/utilsDOM.js
index 030d439d05b..25cbe24234b 100644
--- a/src/js/utilsDOM.js
+++ b/src/js/utilsDOM.js
@@ -251,21 +251,6 @@ App.UI.DOM.colorInput = function(defaultValue, onEnter) {
 	return input;
 };
 
-/**
- * @param {Node} node
- * @param {string} [uniqueID] - should be unique in the whole passage
- * @param {string} [tag]
- * @returns {string}
- */
-App.UI.DOM.includeDOM = function(node, uniqueID, tag = "span") {
-	if (uniqueID === undefined) {
-		uniqueID = Math.random().toString(36).substring(2, 10); // TODO not perfect, but works for now
-	}
-	$(document).one(':passagedisplay', () => { $(`#inclDOM${uniqueID}`).append(node); });
-
-	return `<${tag} id='inclDOM${uniqueID}'></${tag}>`;
-};
-
 /**
  * Concats an array of DOM nodes or strings into a human readable list.
  *
diff --git a/src/uncategorized/householdLiquidator.tw b/src/uncategorized/householdLiquidator.tw
index b2cd1488b4b..5d6b023b379 100644
--- a/src/uncategorized/householdLiquidator.tw
+++ b/src/uncategorized/householdLiquidator.tw
@@ -107,4 +107,4 @@ The price is <<print cashFormatColor(_totalCost)>>. <<if $slavesSeen > $slaveMar
 <br>[[Decline to purchase them and check out another set of slaves|Household Liquidator][$slavesSeen += 2]]
 <br><br>
 
-<<= App.UI.MultipleInspect.SC(_newSlaves, true, true, true)>>
+<<includeDOM App.UI.MultipleInspect(_newSlaves, true, true, true)>>
diff --git a/src/uncategorized/main.tw b/src/uncategorized/main.tw
index 7df482f44fe..d505c8d2d6e 100644
--- a/src/uncategorized/main.tw
+++ b/src/uncategorized/main.tw
@@ -50,7 +50,7 @@
 	[[Hide|Main][$seeDesk = 0]]
 <</if>>
 
-<<print App.MainView.full()>>
+<<includeDOM App.MainView.full()>>
 
 <<set $activeSlave = $slaves.random()>>
 <<if $activeSlave && ($activeSlave.assignment != "please you") && ($activeSlave.assignment != "guard you")>>
diff --git a/src/uncategorized/reFSEgyptianRevivalistAcquisition.tw b/src/uncategorized/reFSEgyptianRevivalistAcquisition.tw
index 4287f086cc2..b9a3c46185a 100644
--- a/src/uncategorized/reFSEgyptianRevivalistAcquisition.tw
+++ b/src/uncategorized/reFSEgyptianRevivalistAcquisition.tw
@@ -68,7 +68,7 @@ This call is coming from a public kiosk, which is usually an indication that the
 <<set _totalValue = slaveCost($activeSlave) + slaveCost(_secondSlave)>>
 //Enslaving them will cost <<print cashFormat(_contractCost)>>. Selling them immediately will bring in approximately <<print cashFormat(_totalValue-_contractCost)>>.//
 <br><br>
-<<= App.UI.MultipleInspect.SC(_newSlaves, true, false, false)>>
+<<includeDOM App.UI.MultipleInspect(_newSlaves, true, false, false)>>
 <br><br>
 <span id="result">
 <<if $cash >= _contractCost>>
diff --git a/src/uncategorized/recETS.tw b/src/uncategorized/recETS.tw
index 95113206f3f..628bf12cd0f 100644
--- a/src/uncategorized/recETS.tw
+++ b/src/uncategorized/recETS.tw
@@ -1404,7 +1404,7 @@
 		<<elseif ["addict mother daughter", "posh mother daughter", "mismatched pair"].includes($RecETSevent)>>
 			<<set _newSlaves = [$relative]>> /* caller doesn't want relative involved, so you don't get to inspect her even if you can force a sale */
 		<</if>>
-		<<= App.UI.MultipleInspect.SC(_newSlaves, true, true, false)>>
+		<<includeDOM App.UI.MultipleInspect(_newSlaves, true, true, false)>>
 	</span>
 
 	<span id="result">
diff --git a/src/uncategorized/slaveAssignmentsReport.tw b/src/uncategorized/slaveAssignmentsReport.tw
index c020c8ce15f..d1145b3b4f0 100644
--- a/src/uncategorized/slaveAssignmentsReport.tw
+++ b/src/uncategorized/slaveAssignmentsReport.tw
@@ -4,6 +4,5 @@
 
 <h1> $arcologies[0].name Weekly Slave Report - Week $week</h1>
 
-<<print App.UI.DOM.includeDOM(App.EndWeek.slaveAssignmentReport(), "weeklyReport", "div")>>
-/* release loading screen as soon as the event loop can run */
+<<includeDOM App.EndWeek.slaveAssignmentReport()>>
 <<run App.UI.EndWeekAnim.end()>>
-- 
GitLab