From be05392fff7079f061f5d43f19067b42b15dc1fa Mon Sep 17 00:00:00 2001
From: Pregmodder <pregmodder@gmail.com>
Date: Sat, 27 Apr 2019 22:41:58 -0400
Subject: [PATCH] rulesAssistantOptions cleaning

---
 src/js/rulesAssistantOptions.js | 114 ++++++++++++++++++++++----------
 1 file changed, 78 insertions(+), 36 deletions(-)

diff --git a/src/js/rulesAssistantOptions.js b/src/js/rulesAssistantOptions.js
index bcfb6fd9668..0dbd993aaf8 100644
--- a/src/js/rulesAssistantOptions.js
+++ b/src/js/rulesAssistantOptions.js
@@ -26,7 +26,7 @@ window.rulesAssistantOptions = (function() {
 		const root = new Root(element);
 	}
 
-	function returnP(e) {return e.keyCode === 13;}
+	function returnP(e) { return e.keyCode === 13; }
 
 	function newRule(root) {
 		const rule = emptyDefaultRule();
@@ -172,7 +172,7 @@ window.rulesAssistantOptions = (function() {
 			data.forEach(item => this.appendChild(new ListItem(...item)));
 		}
 
-		createEditor(...args) {return null;}
+		createEditor(...args) { return null; }
 
 		render(prefix, editor, ...args) {
 			const elem = document.createElement("div");
@@ -204,10 +204,12 @@ window.rulesAssistantOptions = (function() {
 				this.value.innerHTML = `${what}`;
 		}
 
-		getData(what) {return (this.value.tagName === "INPUT" ? this.parse(this.value.value) : this.selectedItem.data);}
+		getData(what) {
+			return (this.value.tagName === "INPUT" ? this.parse(this.value.value): this.selectedItem.data);
+		}
 
 		// customizable input field parser / sanity checker
-		parse(what) {return what;}
+		parse(what) { return what; }
 
 		propagateChange() {
 			if (this.onchange instanceof Function)
@@ -255,8 +257,12 @@ window.rulesAssistantOptions = (function() {
 			res.setAttribute("type", "text");
 			res.classList.add("rajs-value"); //
 			// call the variable binding when the input field is no longer being edited, and when the enter key is pressed
-			res.onblur = () => { this.inputEdited(); };
-			res.onkeypress = (e) => { if (returnP(e)) this.inputEdited(); };
+			res.onblur = () => {
+				this.inputEdited();
+			};
+			res.onkeypress = (e) => {
+				if (returnP(e)) this.inputEdited();
+			};
 			return res;
 		}
 	}
@@ -273,12 +279,18 @@ window.rulesAssistantOptions = (function() {
 			res.setAttribute("min", min);
 			res.setAttribute("max", max);
 			res.classList.add("rajs-value"); //
-			res.onblur = () => { this.inputEdited(); };
-			res.onkeypress = (e) => { if (returnP(e)) this.inputEdited(); };
+			res.onblur = () => {
+				this.inputEdited();
+			};
+			res.onkeypress = (e) => {
+				if (returnP(e)) this.inputEdited();
+			};
 			return res;
 		}
 
-		parse(what) {return what === "" ? this.nullValue : parseInt(what);}
+		parse(what) {
+			return what === "" ? this.nullValue : parseInt(what);
+		}
 	}
 
 	// a way to organize lists with too many elements in subsections
@@ -309,7 +321,7 @@ window.rulesAssistantOptions = (function() {
 	class Options extends Element {
 		constructor(elements = []) {
 			super();
-			elements.forEach(element => {this.appendChild(element);});
+			elements.forEach(element => { this.appendChild(element); });
 		}
 
 		render() {
@@ -351,7 +363,7 @@ window.rulesAssistantOptions = (function() {
 			);
 		}
 
-		onchange() {return;}
+		onchange() { return; }
 	}
 
 	class ButtonItem extends Element {
@@ -657,11 +669,11 @@ window.rulesAssistantOptions = (function() {
 				this.show_custom_editor(CustomEditor, current_rule.condition.data);
 			} else if (this.betweenP(value)) {
 				current_rule.condition.function = "between";
-				current_rule.condition.data = {attribute: value, value: [null, null]};
+				current_rule.condition.data = { attribute: value, value: [null, null] };
 				this.show_custom_editor(RangeEditor, current_rule.condition.function, current_rule.condition.data);
 			} else if (this.belongsP(value)) {
 				current_rule.condition.function = "belongs";
-				current_rule.condition.data = {attribute: value, value: []};
+				current_rule.condition.data = { attribute: value, value: [] };
 				this.show_custom_editor(ItemEditor, current_rule.condition.function, current_rule.condition.data);
 			}
 		}
@@ -697,7 +709,7 @@ window.rulesAssistantOptions = (function() {
 			const min = document.createElement("input");
 			min.setAttribute("type", "text");
 			min.value = `${ data.value[0]}`;
-			min.onkeypress = e => {if (returnP(e)) this.setmin(min.value);};
+			min.onkeypress = e => { if (returnP(e)) this.setmin(min.value); };
 			min.onblur = e => this.setmin(min.value);
 			this.min = min;
 			elem.appendChild(min);
@@ -711,7 +723,7 @@ window.rulesAssistantOptions = (function() {
 			const max = document.createElement("input");
 			max.setAttribute("type", "text");
 			max.value = `${ data.value[1]}`;
-			max.onkeypress = e => {if (returnP(e)) this.setmax(max.value);};
+			max.onkeypress = e => { if (returnP(e)) this.setmax(max.value); };
 			max.onblur = e => this.setmax(max.value);
 			this.max = max;
 			elem.appendChild(max);
@@ -770,7 +782,7 @@ window.rulesAssistantOptions = (function() {
 			const input = document.createElement("input");
 			input.setAttribute("type", "text");
 			input.value = JSON.stringify(data.value);
-			input.onkeypress = e => {if (returnP(e)) this.setValue(input);};
+			input.onkeypress = e => { if (returnP(e)) this.setValue(input); };
 			input.onblur = e => this.setValue(input);
 			this.input = input;
 			elem.appendChild(input);
@@ -898,7 +910,9 @@ window.rulesAssistantOptions = (function() {
 				current_rule.condition.selectedSlaves.includes(slave.ID))));
 		}
 
-		onchange() {current_rule.condition.selectedSlaves = this.getSelection();}
+		onchange() {
+			current_rule.condition.selectedSlaves = this.getSelection();
+		}
 	}
 
 	class SlaveExclusion extends ButtonList {
@@ -910,7 +924,9 @@ window.rulesAssistantOptions = (function() {
 				current_rule.condition.excludedSlaves.includes(slave.ID))));
 		}
 
-		onchange() {current_rule.condition.excludedSlaves = this.getSelection();}
+		onchange() {
+			current_rule.condition.excludedSlaves = this.getSelection();
+		}
 	}
 
 	// parent section for effect editing
@@ -1220,8 +1236,8 @@ window.rulesAssistantOptions = (function() {
 				["Toga (FS)", "a toga"],
 				["Western clothing (FS)", "Western clothing"],
 			];
-			spclothes.forEach(pair => {if (isItemAccessible(pair[1])) nclothes.push(pair);});
-			fsnclothes.forEach(pair => {if (isItemAccessible(pair[1])) nclothes.push(pair);});
+			spclothes.forEach(pair => { if (isItemAccessible(pair[1])) nclothes.push(pair); });
+			fsnclothes.forEach(pair => { if (isItemAccessible(pair[1])) nclothes.push(pair); });
 			const nice = new ListSubSection(this, "Nice", nclothes);
 			this.appendChild(nice);
 
@@ -1235,7 +1251,7 @@ window.rulesAssistantOptions = (function() {
 			const fshclothes = [
 				["Chains (FS)", "chains"],
 			];
-			fshclothes.forEach(pair => {if (isItemAccessible(pair[1])) hclothes.push(pair);});
+			fshclothes.forEach(pair => { if (isItemAccessible(pair[1])) hclothes.push(pair); });
 
 			const harsh = new ListSubSection(this, "Harsh", hclothes);
 			this.appendChild(harsh);
@@ -1268,7 +1284,7 @@ window.rulesAssistantOptions = (function() {
 				["Bowtie collar", "bowtie"],
 				["Ancient Egyptian", "ancient Egyptian"],
 			];
-			fsncollars.forEach(pair => {if (isItemAccessible(pair[1])) ncollars.push(pair);});
+			fsncollars.forEach(pair => { if (isItemAccessible(pair[1])) ncollars.push(pair); });
 			const nice = new ListSubSection(this, "Nice", ncollars);
 			this.appendChild(nice);
 
@@ -1298,7 +1314,9 @@ window.rulesAssistantOptions = (function() {
 	class CorsetList extends List {
 		constructor() {
 			const bellies = [];
-			setup.bellyAccessories.forEach(acc => {if (acc.fs === undefined && acc.rs === undefined)bellies.push([acc.name, acc.value]);
+			setup.bellyAccessories.forEach(acc => {
+				if (acc.fs === undefined && acc.rs === undefined)
+					bellies.push([acc.name, acc.value]);
 				else if (acc.fs === "repopulation" && V.arcologies[0].FSRepopulationFocus !== "unset")
 					bellies.push([`${acc.name } (FS)`, acc.value]);
 				else if (acc.rs === "boughtBelly" && V.clothesBoughtBelly === 1)
@@ -1340,7 +1358,9 @@ window.rulesAssistantOptions = (function() {
 	class VagAccVirginsList extends List {
 		constructor() {
 			const accs = [];
-			setup.vaginalAccessories.forEach(acc => {if (acc.fs === undefined && acc.rs === undefined)accs.push([acc.name, acc.value]);
+			setup.vaginalAccessories.forEach(acc => {
+				if (acc.fs === undefined && acc.rs === undefined)
+					accs.push([acc.name, acc.value]);
 				else if (acc.rs === "buyBigDildos" && V.toysBoughtDildos === 1)
 					accs.push([`${acc.name } (Purchased)`, acc.value]);
 			});
@@ -1353,7 +1373,9 @@ window.rulesAssistantOptions = (function() {
 	class VagAccAVirginsList extends List {
 		constructor() {
 			const accs = [];
-			setup.vaginalAccessories.forEach(acc => {if (acc.fs === undefined && acc.rs === undefined)accs.push([acc.name, acc.value]);
+			setup.vaginalAccessories.forEach(acc => {
+				if (acc.fs === undefined && acc.rs === undefined)
+					accs.push([acc.name, acc.value]);
 				else if (acc.rs === "buyBigDildos" && V.toysBoughtDildos === 1)
 					accs.push([`${acc.name } (Purchased)`, acc.value]);
 			});
@@ -1366,7 +1388,9 @@ window.rulesAssistantOptions = (function() {
 	class VagAccOtherList extends List {
 		constructor() {
 			const accs = [];
-			setup.vaginalAccessories.forEach(acc => {if (acc.fs === undefined && acc.rs === undefined)accs.push([acc.name, acc.value]);
+			setup.vaginalAccessories.forEach(acc => {
+				if (acc.fs === undefined && acc.rs === undefined)
+					accs.push([acc.name, acc.value]);
 				else if (acc.rs === "buyBigDildos" && V.toysBoughtDildos === 1)
 					accs.push([`${acc.name } (Purchased)`, acc.value]);
 			});
@@ -1379,7 +1403,9 @@ window.rulesAssistantOptions = (function() {
 	class VaginalAttachmentsList extends List {
 		constructor() {
 			const accs = [];
-			setup.vaginalAttachments.forEach(acc => {if (acc.fs === undefined && acc.rs === undefined)accs.push([acc.name, acc.value]);
+			setup.vaginalAttachments.forEach(acc => {
+				if (acc.fs === undefined && acc.rs === undefined)
+					accs.push([acc.name, acc.value]);
 				else if (acc.rs === "buyVaginalAttachments" && V.toysBoughtVaginalAttachments === 1)
 					accs.push([`${acc.name } (Purchased)`, acc.value]);
 			});
@@ -1434,7 +1460,9 @@ window.rulesAssistantOptions = (function() {
 	class ButtplugsVirginsList extends List {
 		constructor() {
 			const accs = [];
-			setup.buttplugs.forEach(acc => {if (acc.fs === undefined && acc.rs === undefined)accs.push([acc.name, acc.value]);
+			setup.buttplugs.forEach(acc => {
+				if (acc.fs === undefined && acc.rs === undefined)
+					accs.push([acc.name, acc.value]);
 				else if (acc.rs === "buyBigPlugs" && V.toysBoughtButtPlugs === 1)
 					accs.push([`${acc.name } (Purchased)`, acc.value]);
 			});
@@ -1447,7 +1475,9 @@ window.rulesAssistantOptions = (function() {
 	class ButtplugsOtherList extends List {
 		constructor() {
 			const accs = [];
-			setup.buttplugs.forEach(acc => {if (acc.fs === undefined && acc.rs === undefined)accs.push([acc.name, acc.value]);
+			setup.buttplugs.forEach(acc => {
+				if (acc.fs === undefined && acc.rs === undefined)
+					accs.push([acc.name, acc.value]);
 				else if (acc.rs === "buyBigPlugs" && V.toysBoughtButtPlugs === 1)
 					accs.push([`${acc.name } (Purchased)`, acc.value]);
 			});
@@ -1460,7 +1490,9 @@ window.rulesAssistantOptions = (function() {
 	class ButtplugAttachmentsList extends List {
 		constructor() {
 			const accs = [];
-			setup.buttplugAttachments.forEach(acc => {if (acc.fs === undefined && acc.rs === undefined)accs.push([acc.name, acc.value]);
+			setup.buttplugAttachments.forEach(acc => {
+				if (acc.fs === undefined && acc.rs === undefined)
+					accs.push([acc.name, acc.value]);
 				else if (acc.rs === "buyTails" && V.toysBoughtButtPlugTails === 1)
 					accs.push([`${acc.name } (Purchased)`, acc.value]);
 			});
@@ -1553,8 +1585,9 @@ window.rulesAssistantOptions = (function() {
 		}
 
 		nds() {
-			[this.breasts, this.butts, this.lips, this.dicks, this.balls].forEach(i => {i.setValue("no default change");
-			i.propagateChange();
+			[this.breasts, this.butts, this.lips, this.dicks, this.balls].forEach(i => {
+				i.setValue("no default change");
+				i.propagateChange();
 			});
 		}
 
@@ -1595,7 +1628,9 @@ window.rulesAssistantOptions = (function() {
 		}
 
 		none() {
-			this.sublists.forEach(i => {i.setValue(0); i.propagateChange();
+			this.sublists.forEach(i => {
+				i.setValue(0);
+				i.propagateChange();
 			});
 		}
 	}
@@ -1932,7 +1967,9 @@ window.rulesAssistantOptions = (function() {
 			];
 			super("Diet base", pairs);
 			this.setValue(this.value2string(current_rule.set.dietCum, current_rule.set.dietMilk));
-			this.onchange = (value) => { current_rule.set.dietCum = value.cum; current_rule.set.dietMilk = value.milk;
+			this.onchange = (value) => {
+				current_rule.set.dietCum = value.cum;
+				current_rule.set.dietMilk = value.milk;
 				this.setValue(this.value2string(current_rule.set.dietCum, current_rule.set.dietMilk));
 			};
 		}
@@ -2261,7 +2298,9 @@ window.rulesAssistantOptions = (function() {
 				"orange",
 				"amber",
 				"red"
-			].forEach(i => items.push(new OptionsItem(i, item => {this.value = item.label; this.parent.setValue();
+			].forEach(i => items.push(new OptionsItem(i, item => {
+				this.value = item.label;
+				this.parent.setValue();
 			})));
 			super(items);
 		}
@@ -2285,7 +2324,10 @@ window.rulesAssistantOptions = (function() {
 				"bright",
 				"teary",
 				"vacant"
-			].forEach(i => items.push(new OptionsItem(i, item => {this.value = item.label; this.parent.setValue();})));
+			].forEach(i => items.push(new OptionsItem(i, item => {
+				this.value = item.label;
+				this.parent.setValue();
+			})));
 			super(items);
 		}
 	}
-- 
GitLab