From c0f639b4e3491cb62c376e5213f78cc2c881c4c2 Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Mon, 30 Nov 2020 15:22:07 -0500
Subject: [PATCH] cleanup

---
 .../bodyModification/bodyModification.js      | 119 ++++++++++--------
 .../bodyModification/createBrand.js           |   2 +
 2 files changed, 66 insertions(+), 55 deletions(-)

diff --git a/src/facilities/bodyModification/bodyModification.js b/src/facilities/bodyModification/bodyModification.js
index 6aac6e91ec8..4975c400918 100644
--- a/src/facilities/bodyModification/bodyModification.js
+++ b/src/facilities/bodyModification/bodyModification.js
@@ -90,7 +90,7 @@ App.UI.bodyModification = function(slave, cheat = false) {
 								}
 								r.push(` become scarred`);
 							}
-							r.push(`.`);
+							r.push(r.pop() + ".");
 					}
 					r.push(`No matter how you chose to apply it, scarring so much of ${his} body has <span class="health.dec"> hurt ${his} health.</span>`);
 					healthDamage(slave, 20);
@@ -495,55 +495,18 @@ App.UI.bodyModification = function(slave, cheat = false) {
 		r.push(App.UI.DOM.generateLinksStrip(linkArray));
 		App.Events.addNode(el, r, "div");
 
-		// Custom
-		App.UI.DOM.appendNewElement("h3", el, "Custom Tattoos");
-		r = [];
-		for (const location of validTattooLocations) {
-			const varName = tattooLocations.get(location);
-			if (varName) {
-				r.push(App.UI.DOM.makeElement("div", `${capFirstChar(location)}: `));
-				r.push(
-					App.UI.DOM.makeElement(
-						"div",
-						App.UI.DOM.makeTextBox(
-							slave[`${varName}Tat`],
-							(v) => {
-								modReaction += App.Medicine.Modification.setTattoo(slave, varName, v);
-								refresh();
-							}
-						)
-					)
-				);
-			}
-		}
-
-		// Custom
-		r.push(App.UI.DOM.makeElement("div", `Custom: `));
-		r.push(
-			App.UI.DOM.makeElement(
-				"div",
-				App.UI.DOM.makeTextBox(
-					slave.custom.tattoo,
-					(v) => {
-						slave.custom.tattoo = v;
-						cashX(forceNeg(V.surgeryCost), "slaveMod", slave);
-						refresh();
-					}
-				)
+		const customEl = document.createElement("div");
+		customEl.id = "custom-el";
+		customEl.append(
+			App.UI.DOM.link(
+				"Show custom tattoo locations",
+				() => {
+					jQuery("#custom-el").empty().append(customTats());
+				}
 			)
 		);
-		App.Events.addNode(el, r, "div", "grid-2columns-auto");
-		if (slave.custom.tattoo !== "") {
-			el.append(
-				App.UI.DOM.link(
-					"Remove custom Tattoo",
-					() => {
-						slave.custom.tattoo = "";
-						cashX(forceNeg(V.surgeryCost), "slaveMod", slave);
-					}
-				)
-			);
-		}
+		el.append(customEl);
+
 		return el;
 
 		function applyTat(location) {
@@ -553,11 +516,62 @@ App.UI.bodyModification = function(slave, cheat = false) {
 				V.degradation += 1;
 			}
 		}
+
+		function customTats() {
+			const el = new DocumentFragment();
+			App.UI.DOM.appendNewElement("h3", el, "Custom Tattoos");
+			const r = [];
+			for (const location of validTattooLocations) {
+				const varName = tattooLocations.get(location);
+				if (varName) {
+					r.push(App.UI.DOM.makeElement("div", `${capFirstChar(location)}: `));
+					r.push(
+						App.UI.DOM.makeElement(
+							"div",
+							App.UI.DOM.makeTextBox(
+								slave[`${varName}Tat`],
+								(v) => {
+									modReaction += App.Medicine.Modification.setTattoo(slave, varName, v);
+									refresh();
+								}
+							)
+						)
+					);
+				}
+			}
+
+			r.push(App.UI.DOM.makeElement("div", `Custom: `));
+			r.push(
+				App.UI.DOM.makeElement(
+					"div",
+					App.UI.DOM.makeTextBox(
+						slave.custom.tattoo,
+						(v) => {
+							slave.custom.tattoo = v;
+							cashX(forceNeg(V.surgeryCost), "slaveMod", slave);
+							refresh();
+						}
+					)
+				)
+			);
+			App.Events.addNode(el, r, "div", "grid-2columns-auto");
+			if (slave.custom.tattoo !== "") {
+				el.append(
+					App.UI.DOM.link(
+						"Remove custom Tattoo",
+						() => {
+							slave.custom.tattoo = "";
+							cashX(forceNeg(V.surgeryCost), "slaveMod", slave);
+						}
+					)
+				);
+			}
+			return el;
+		}
 	}
 
 	function branding() {
 		const el = new DocumentFragment();
-		App.UI.DOM.appendNewElement("h2", el, "Branding");
 		const selection = document.createElement("span");
 		selection.id = "brand-selection";
 		selection.append(App.Medicine.Modification.Select.brand(slave, cheat));
@@ -840,12 +854,7 @@ App.UI.bodyModification = function(slave, cheat = false) {
 					}
 				)
 			);
-			r.push(`with ${V.scarDesign.local} on the ${V.scarTarget.local}`);
-			if (slave.scar[V.scarTarget.local]) {
-				r.push(`, adding to the scars that are already there?`);
-			} else {
-				r.push(`.`);
-			}
+			r.push(`with ${V.scarDesign.local} on the ${V.scarTarget.local}${(slave.scar[V.scarTarget.local]) ? `, adding to the scars that are already there?`: `.`}`);
 		}
 		App.Events.addNode(el, r, "div");
 
diff --git a/src/facilities/bodyModification/createBrand.js b/src/facilities/bodyModification/createBrand.js
index 8eaefc2dbec..fb7b5cc58e1 100644
--- a/src/facilities/bodyModification/createBrand.js
+++ b/src/facilities/bodyModification/createBrand.js
@@ -4,6 +4,8 @@ App.Medicine.Modification.Select.brand = function(slave, cheat = false) {
 	let div = document.createElement('div');
 	const {his, His, him, He} = getPronouns(slave);
 
+	App.UI.DOM.appendNewElement("h2", el, "Branding");
+
 	for (const brandPlace in slave.brand) {
 		div = document.createElement('div');
 		div.append(`${His} ${brandPlace} is marked with ${slave.brand[brandPlace]}`);
-- 
GitLab