From 620fe2876c7ec5d4bb6704821137b1b3054cb56b Mon Sep 17 00:00:00 2001
From: DCoded <dcoded@live.com>
Date: Wed, 5 Aug 2020 00:10:01 -0400
Subject: [PATCH] DOMified weightRulesEffect()

---
 src/endWeek/reports/childrenReport.js | 43 ++++++++++++++++++++-------
 1 file changed, 32 insertions(+), 11 deletions(-)

diff --git a/src/endWeek/reports/childrenReport.js b/src/endWeek/reports/childrenReport.js
index 3e42ddb2e6e..6d563c937aa 100644
--- a/src/endWeek/reports/childrenReport.js
+++ b/src/endWeek/reports/childrenReport.js
@@ -38,7 +38,7 @@ App.Facilities.Nursery.childrenReport = function childrenReport() {
 
 			// TODO: rework these entirely
 			if (Matron || nannies) {
-				childDiv.append(weightRulesEffects(child));
+				childDiv.appendChild(weightRulesEffects(child));
 				childDiv.append(musclesRulesEffects(child));
 			}
 		} else {
@@ -165,40 +165,61 @@ App.Facilities.Nursery.childrenReport = function childrenReport() {
 	// MARK: Nursery Rules Effects
 
 	function weightRulesEffects(child) {
-		let r = [];
+		// TODO: redo this entire section
+		// TODO: double check these classes, make sure they make sense
+		const div = document.createElement("div");
 
 		if (V.nurseryWeight) {
-			const firstNanny = NL > 0 ? nannies[0] : null;
-			r.push(`<br>`);
+			const
+				caretaker = Matron ? Matron.slaveName : NL > 1 ? `A nanny` : firstNanny.slaveName,
+				firstNanny = NL > 0 ? nannies[0] : null;
+
 			if (V.nurseryWeightSetting === 1) {
+				const weightSpan = App.UI.DOM.makeElement("div", 'rapid weight gain.', ["health", "dec"]);
+
 				if (child.weight < 200) {
 					child.weight += 5;
 				}
-				r.push(`${He} is being fed an excessive amount of food, causing <span class="red">rapid weight gain.</span> `);
+
+				div.append(`${He} is being fed an excessive amount of food, causing`, weightSpan);
 			} else if (V.nurseryWeightSetting === 2) {
+				const weightSpan = App.UI.DOM.makeElement("div", `decreases the amount of food ${he} eats.`, "improvement");
+
 				if (child.weight > 10) {
 					child.weight--;
-					r.push(`${Matron ? Matron.slaveName : NL > 1 ? `A nanny` : firstNanny.slaveName} notices ${he} is overweight and <span class="green">decreases the amount of food ${he} eats.</span> `);
+
+					div.append(`${caretaker} notices ${he} is overweight and `, weightSpan);
 				} else if (child.weight <= -10) {
+					const weightSpan = App.UI.DOM.makeElement("div", `increases the amount of food ${he} eats.`, "improvement");
+
 					child.weight++;
-					r.push(`${Matron ? Matron.slaveName : NL > 1 ? `A nanny` : firstNanny.slaveName} notices ${he} is underweight and <span class="green">increases the amount of food ${he} eats.</span> `);
+
+					div.append(`${caretaker} notices ${he} is underweight and `, weightSpan);
 				} else {
-					r.push(`${He} is <span class="lime">currently a healthy weight;</span> efforts will be made to maintain it. `);
+					const weightSpan = App.UI.DOM.makeElement("div", 'currently a healthy weight;', ["change", "positive"]);
+
+					div.append(`${He} is `, weightSpan, ` efforts will be made to maintain it. `);
 				}
 			} else if (V.nurseryWeightSetting === 0) {
 				if (child.weight > -20) {
-					r.push(`${His} developing body <span class="red">quickly sheds its gained weight.</span> `);
+					const weightSpan = App.UI.DOM.makeElement("div", 'quickly sheds its gained weight.', ["health", "dec"]);
+
 					child.weight -= 40;
+
+					div.append(`${His} developing body `, weightSpan);
 				}
 			}
 		} else {
 			if (child.weight > -20) {
+				const weightSpan = App.UI.DOM.makeElement("div", 'quickly sheds its gained weight.', ["health", "dec"]);
+
 				child.weight -= 40;
-				r.push(`${His} developing body <span class="red">quickly sheds its gained weight.</span>`);
+
+				div.append(`${His} developing body `, weightSpan);
 			}
 		}
 
-		return r.join(' ');
+		return div;
 	}
 
 	function musclesRulesEffects(child) {
-- 
GitLab