From f3585b7a6d11f0643ddf9d33c2402204df3f6fbe Mon Sep 17 00:00:00 2001 From: lowercasedonkey <lowercasedonkey@gmail.com> Date: Tue, 18 Feb 2020 00:08:12 -0500 Subject: [PATCH] cleanup --- src/js/wardrobeUse.js | 160 ++++++++++-------------------------------- 1 file changed, 39 insertions(+), 121 deletions(-) diff --git a/src/js/wardrobeUse.js b/src/js/wardrobeUse.js index 8bfc0064b8f..7a38fb280cc 100644 --- a/src/js/wardrobeUse.js +++ b/src/js/wardrobeUse.js @@ -11,8 +11,24 @@ App.UI.Wardrobe.clothes = function(slave) { he, him, his, hers, himself, boy, He, His } = getPronouns(slave); - let choiceOptionsArray= []; - choiceOptionsArray.push({text: `Let ${him} choose`, updateSlave: {clothes: `choosing her own clothes`}}); + let el = document.createElement('div'); + + let label = document.createElement('div'); + label.append(`Clothes: `); + + let choice = document.createElement('span'); + choice.style.fontWeight = "bold"; + choice.textContent = (`${slave.clothes} `); + label.appendChild(choice); + + // Choose her own + 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)); + } + el.appendChild(label); + let niceOptionsArray= []; let harshOptionsArray= []; @@ -45,22 +61,6 @@ App.UI.Wardrobe.clothes = function(slave) { niceOptionsArray = niceOptionsArray.sort((a, b) => (a.text > b.text) ? 1 : -1); harshOptionsArray = harshOptionsArray.sort((a, b) => (a.text > b.text) ? 1 : -1); - let el = document.createElement('div'); - - let label = document.createElement('div'); - label.append(`Clothes: `); - - let choice = document.createElement('span'); - choice.style.fontWeight = "bold"; - choice.textContent = (`${slave.clothes} `); - label.appendChild(choice); - - // Choose her own - label.appendChild(generateRows(choiceOptionsArray)); - - el.appendChild(label); - - // Nice options let links = document.createElement('div'); links.className = "choices"; @@ -159,14 +159,24 @@ App.UI.Wardrobe.collar = function(slave) { return; } - const - { - // eslint-disable-next-line no-unused-vars - he, him, his, hers, himself, boy, He, His - } = getPronouns(slave); + let el = document.createElement('div'); - let choiceOptionsArray= []; - choiceOptionsArray.push({text: `None`, updateSlave: {collar: `none`}}); + let label = document.createElement('div'); + label.append(`Collar: `); + + let choice = document.createElement('span'); + choice.style.fontWeight = "bold"; + choice.textContent = (`${slave.collar} `); + label.appendChild(choice); + + // Choose her own + if (slave.collar !== `none`) { + let choiceOptionsArray= []; + choiceOptionsArray.push({text: `None`, updateSlave: {collar: `none`}}); + label.appendChild(generateRows(choiceOptionsArray)); + } + + el.appendChild(label); let niceOptionsArray= []; let harshOptionsArray= []; @@ -199,22 +209,6 @@ App.UI.Wardrobe.collar = function(slave) { niceOptionsArray = niceOptionsArray.sort((a, b) => (a.text > b.text) ? 1 : -1); harshOptionsArray = harshOptionsArray.sort((a, b) => (a.text > b.text) ? 1 : -1); - let el = document.createElement('div'); - - let label = document.createElement('div'); - label.append(`Collar: `); - - let choice = document.createElement('span'); - choice.style.fontWeight = "bold"; - choice.textContent = (`${slave.collar} `); - label.appendChild(choice); - - // Choose her own - label.appendChild(generateRows(choiceOptionsArray)); - - el.appendChild(label); - - // Nice options let links = document.createElement('div'); links.className = "choices"; @@ -307,12 +301,6 @@ App.UI.Wardrobe.armAccessory = function(slave) { return; } - const - { - // eslint-disable-next-line no-unused-vars - he, him, his, hers, himself, boy, He, His - } = getPronouns(slave); - let el = document.createElement('div'); let label = document.createElement('div'); @@ -457,11 +445,11 @@ App.UI.Wardrobe.shoes = function(slave) { label.appendChild(choice); // Choose her own - label.appendChild(generateRows(choiceOptionsArray)); - + if (slave.shoes !== `none`) { + label.appendChild(App.UI.Wardrobe.generateRows(choiceOptionsArray, "shoes", slave, true)); + } el.appendChild(label); - // Options let links = document.createElement('div'); links.className = "choices"; @@ -469,76 +457,6 @@ App.UI.Wardrobe.shoes = function(slave) { el.appendChild(links); return jQuery('#shoes').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.shoes === `none` || isClothingAccessible.entry(array[i].updateSlave.shoes, "shoes")) { - // 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.legAccessory = function(slave) { @@ -567,7 +485,7 @@ App.UI.Wardrobe.legAccessory = function(slave) { // Choose her own if (slave.legAccessory !== "none") { array.push({text: `None`, updateSlave: {legAccessory: `none`}}); - label.appendChild(generateRows(array)); + label.appendChild(App.UI.Wardrobe.generateRows(array, "legAccessory", slave, true)); } el.appendChild(label); -- GitLab