From 8db159e5777b03d896203c8b699e9bb48b082223 Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Tue, 18 Feb 2020 00:39:30 -0500
Subject: [PATCH] fixes

---
 src/js/itemAvailability.js |   2 +-
 src/js/wardrobeUse.js      | 235 ++-----------------------------------
 2 files changed, 9 insertions(+), 228 deletions(-)

diff --git a/src/js/itemAvailability.js b/src/js/itemAvailability.js
index eb2139a7328..71d22d4394a 100644
--- a/src/js/itemAvailability.js
+++ b/src/js/itemAvailability.js
@@ -217,7 +217,7 @@ window.isClothingAccessible = (function() {
 		}
 		let niceDB;
 		let harshDB;
-		if (category === "clothing") {
+		if (["clothing", "clothes"].includes(category)) {
 			niceDB = App.Data.misc.niceClothes;
 			harshDB = App.Data.misc.harshClothes;
 		} else if (category === "collar") {
diff --git a/src/js/wardrobeUse.js b/src/js/wardrobeUse.js
index ce014017d13..9d0b05c630e 100644
--- a/src/js/wardrobeUse.js
+++ b/src/js/wardrobeUse.js
@@ -25,7 +25,7 @@ App.UI.Wardrobe.clothes = function(slave) {
 	if (slave.clothes !== `choosing her own clothes`) {
 		let choiceOptionsArray= [];
 		choiceOptionsArray.push({text: `Let ${him} choose`, updateSlave: {clothes: `choosing her own clothes`}});
-		label.appendChild(generateRows(choiceOptionsArray));
+		label.appendChild(App.UI.Wardrobe.generateRows(choiceOptionsArray, "clothes", slave, true));
 	}
 	el.appendChild(label);
 
@@ -65,93 +65,17 @@ App.UI.Wardrobe.clothes = function(slave) {
 	let links = document.createElement('div');
 	links.className = "choices";
 	links.append(`Nice: `);
-	links.appendChild(generateRows(niceOptionsArray));
+	links.appendChild(App.UI.Wardrobe.generateRows(niceOptionsArray, "clothes", slave, false));
 	el.appendChild(links);
 
 	// Harsh options
 	links = document.createElement('div');
 	links.className = "choices";
 	links.append(`Harsh: `);
-	links.appendChild(generateRows(harshOptionsArray));
+	links.appendChild(App.UI.Wardrobe.generateRows(harshOptionsArray, "clothes", slave, false));
 	el.appendChild(links);
 
 	return jQuery('#clothes').empty().append(el);
-
-
-	function generateRows(array) {
-		let row = document.createElement('span');
-		for (let i = 0; i < array.length; i++) {
-			let link;
-			const separator  = document.createTextNode(` | `);
-			const keys = Object.keys(array[i]);
-
-			// Test to see if there was a problem with the key
-			for (let j = 0; j < keys.length; j++) {
-				if (["FS", "text", "updateSlave", "update", "note", "disabled"].includes(keys[j])) {
-					continue;
-				} else {
-					array[i].text += " ERROR, THIS SCENE WAS NOT ENTERED CORRECTLY";
-					console.log("Trash found while generateRows() was running: " + keys[j] + ": " + array[i][keys[j]]);
-					break;
-				}
-			}
-			if (array[i].updateSlave.clothes === `choosing her own clothes` || isClothingAccessible.entry(array[i].updateSlave.clothes, "clothing")) {
-				// is it just text?
-				if (array[i].disabled) {
-					link = App.UI.DOM.disabledLink(array[i].text, [array[i].disabled]);
-				} else {
-					link = document.createElement('span');
-
-					// Set up the link
-					link.appendChild(
-						App.UI.DOM.link(
-							`${array[i].text} `,
-							() => { click(array[i]); },
-						)
-					);
-
-					if (array[i].FS) {
-						let FS = array[i].FS.substring(2); // Given "FSEdoRevivalist", cut off the first two letters to start a user friendly tooltip
-						FS = FS.replace(/([A-Z])/g, ` $1`); // Given "EdoRevivalist", find every capital letter and put a space in front of it
-						FS = App.UI.DOM.disabledLink(`FS`, [FS]); // Tooltip should read "Edo Revivalist"
-						FS.style.fontStyle = "italic";
-						link.appendChild(FS);
-					}
-
-					// add a note node if required
-					if (array[i].note) {
-						let note  = document.createElement('span');
-						note.textContent = (` ${array[i].note}`);
-						note.className = "note";
-						link.appendChild(note);
-					}
-				}
-				row.appendChild(link);
-				if (i < array.length-1) {
-					row.appendChild(separator);
-				}
-			}
-		}
-
-		return row;
-
-		function click(arrayOption) {
-			if (arrayOption.updateSlave) {
-				Object.assign(slave, arrayOption.updateSlave);
-			}
-			if (arrayOption.update) {
-				Object.assign(V, arrayOption.update);
-			}
-			if (arrayOption.clothes === `choosing her own clothes`) {
-				slave.choosesOwnClothes = 1;
-			} else {
-				slave.choosesOwnClothes = 0;
-			}
-
-			App.UI.Wardrobe.refreshAll(slave);
-			return;
-		}
-	}
 };
 
 App.UI.Wardrobe.collar = function(slave) {
@@ -173,7 +97,7 @@ App.UI.Wardrobe.collar = function(slave) {
 	if (slave.collar !== `none`) {
 		let choiceOptionsArray= [];
 		choiceOptionsArray.push({text: `None`, updateSlave: {collar: `none`}});
-		label.appendChild(generateRows(choiceOptionsArray));
+		label.appendChild(App.UI.Wardrobe.generateRows(choiceOptionsArray, "collar", slave, true));
 	}
 
 	el.appendChild(label);
@@ -213,87 +137,17 @@ App.UI.Wardrobe.collar = function(slave) {
 	let links = document.createElement('div');
 	links.className = "choices";
 	links.append(`Nice: `);
-	links.appendChild(generateRows(niceOptionsArray));
+	links.appendChild(App.UI.Wardrobe.generateRows(niceOptionsArray, "collar", slave, false));
 	el.appendChild(links);
 
 	// Harsh options
 	links = document.createElement('div');
 	links.className = "choices";
 	links.append(`Harsh: `);
-	links.appendChild(generateRows(harshOptionsArray));
+	links.appendChild(App.UI.Wardrobe.generateRows(harshOptionsArray, "collar", slave, false));
 	el.appendChild(links);
 
 	return jQuery('#collar').empty().append(el);
-
-
-	function generateRows(array) {
-		let row = document.createElement('span');
-		for (let i = 0; i < array.length; i++) {
-			let link;
-			const separator  = document.createTextNode(` | `);
-			const keys = Object.keys(array[i]);
-
-			// Test to see if there was a problem with the key
-			for (let j = 0; j < keys.length; j++) {
-				if (["FS", "text", "updateSlave", "update", "note", "disabled"].includes(keys[j])) {
-					continue;
-				} else {
-					array[i].text += " ERROR, THIS SCENE WAS NOT ENTERED CORRECTLY";
-					console.log("Trash found while generateRows() was running: " + keys[j] + ": " + array[i][keys[j]]);
-					break;
-				}
-			}
-			if (array[i].updateSlave.collar === `none` || isClothingAccessible.entry(array[i].updateSlave.collar, "collar")) {
-				// is it just text?
-				if (array[i].disabled) {
-					link = App.UI.DOM.disabledLink(array[i].text, [array[i].disabled]);
-				} else {
-					link = document.createElement('span');
-
-					// Set up the link
-					link.appendChild(
-						App.UI.DOM.link(
-							`${array[i].text} `,
-							() => { click(array[i]); },
-						)
-					);
-
-					if (array[i].FS) {
-						let FS = array[i].FS.substring(2); // Given "FSEdoRevivalist", cut off the first two letters to start a user friendly tooltip
-						FS = FS.replace(/([A-Z])/g, ` $1`); // Given "EdoRevivalist", find every capital letter and put a space in front of it
-						FS = App.UI.DOM.disabledLink(`FS`, [FS]); // Tooltip should read "Edo Revivalist"
-						FS.style.fontStyle = "italic";
-						link.appendChild(FS);
-					}
-
-					// add a note node if required
-					if (array[i].note) {
-						let note  = document.createElement('span');
-						note.textContent = (` ${array[i].note}`);
-						note.className = "note";
-						link.appendChild(note);
-					}
-				}
-				row.appendChild(link);
-				if (i < array.length-1) {
-					row.appendChild(separator);
-				}
-			}
-		}
-
-		return row;
-
-		function click(arrayOption) {
-			if (arrayOption.updateSlave) {
-				Object.assign(slave, arrayOption.updateSlave);
-			}
-			if (arrayOption.update) {
-				Object.assign(V, arrayOption.update);
-			}
-			App.UI.Wardrobe.refreshAll(slave);
-			return;
-		}
-	}
 };
 
 App.UI.Wardrobe.armAccessory = function(slave) {
@@ -331,76 +185,6 @@ App.UI.Wardrobe.armAccessory = function(slave) {
 	el.appendChild(links);
 
 	return jQuery('#armAccessory').empty().append(el);
-
-
-	function generateRows(array) {
-		let row = document.createElement('span');
-		for (let i = 0; i < array.length; i++) {
-			let link;
-			const separator  = document.createTextNode(` | `);
-			const keys = Object.keys(array[i]);
-
-			// Test to see if there was a problem with the key
-			for (let j = 0; j < keys.length; j++) {
-				if (["FS", "text", "updateSlave", "update", "note", "disabled"].includes(keys[j])) {
-					continue;
-				} else {
-					array[i].text += " ERROR, THIS SCENE WAS NOT ENTERED CORRECTLY";
-					console.log("Trash found while generateRows() was running: " + keys[j] + ": " + array[i][keys[j]]);
-					break;
-				}
-			}
-			// if (array[i].updateSlave.armAccessory === `none` || isClothingAccessible.entry(array[i].updateSlave.armAccessory, "armAccessory")) {
-				// is it just text?
-				if (array[i].disabled) {
-					link = App.UI.DOM.disabledLink(array[i].text, [array[i].disabled]);
-				} else {
-					link = document.createElement('span');
-
-					// Set up the link
-					link.appendChild(
-						App.UI.DOM.link(
-							`${array[i].text} `,
-							() => { click(array[i]); },
-						)
-					);
-
-					if (array[i].FS) {
-						let FS = array[i].FS.substring(2); // Given "FSEdoRevivalist", cut off the first two letters to start a user friendly tooltip
-						FS = FS.replace(/([A-Z])/g, ` $1`); // Given "EdoRevivalist", find every capital letter and put a space in front of it
-						FS = App.UI.DOM.disabledLink(`FS`, [FS]); // Tooltip should read "Edo Revivalist"
-						FS.style.fontStyle = "italic";
-						link.appendChild(FS);
-					}
-
-					// add a note node if required
-					if (array[i].note) {
-						let note  = document.createElement('span');
-						note.textContent = (` ${array[i].note}`);
-						note.className = "note";
-						link.appendChild(note);
-					}
-				}
-				row.appendChild(link);
-				if (i < array.length-1) {
-					row.appendChild(separator);
-				}
-			//}
-		}
-
-		return row;
-
-		function click(arrayOption) {
-			if (arrayOption.updateSlave) {
-				Object.assign(slave, arrayOption.updateSlave);
-			}
-			if (arrayOption.update) {
-				Object.assign(V, arrayOption.update);
-			}
-			App.UI.Wardrobe.refreshAll(slave);
-			return;
-		}
-	}
 };
 
 App.UI.Wardrobe.shoes = function(slave) {
@@ -502,7 +286,7 @@ App.UI.Wardrobe.legAccessory = function(slave) {
 	return jQuery('#legAccessory').empty().append(el);
 };
 
-App.UI.Wardrobe.generateRows = function(array, category, slave, ignoreAccessCheck="false") { //cateogy should be in the form of slave.category, the thing we want to update.
+App.UI.Wardrobe.generateRows = function(array, category, slave, ignoreAccessCheck="false") { //category should be in the form of slave.category, the thing we want to update.
 	let row = document.createElement('span');
 	for (let i = 0; i < array.length; i++) {
 		let link;
@@ -569,10 +353,7 @@ App.UI.Wardrobe.generateRows = function(array, category, slave, ignoreAccessChec
 		App.UI.Wardrobe.refreshAll(slave);
 		return;
 	}
-}
-
-
-
+};
 
 App.UI.Wardrobe.refreshAll = function(slave) {
 	App.UI.Wardrobe.clothes(slave);
-- 
GitLab