diff --git a/src/js/wardrobeUse.js b/src/js/wardrobeUse.js index 99ee1e71b29d71e373a38fbf351aa8322bb84914..159b1ef3145b22042d4d1ab996eb50a092c2ddf6 100644 --- a/src/js/wardrobeUse.js +++ b/src/js/wardrobeUse.js @@ -327,7 +327,7 @@ App.UI.Wardrobe.armAccessory = function(slave) { // Choose her own if (slave.armAccessory !== "none") { - array.push({text: `None`, updateSlave: {armaccessory: `none`}}); + array.push({text: `None`, updateSlave: {armAccessory: `none`}}); label.appendChild(generateRows(array)); } @@ -541,12 +541,127 @@ App.UI.Wardrobe.shoes = function(slave) { } }; +App.UI.Wardrobe.legAccessory = function(slave) { + if (slave.fuckdoll !== 0) { + 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'); + label.append(`Leg accessory: `); + + let choice = document.createElement('span'); + choice.style.fontWeight = "bold"; + choice.textContent = (`${slave.legAccessory} `); + label.appendChild(choice); + + let array = []; + + // Choose her own + if (slave.legAccessory !== "none") { + array.push({text: `None`, updateSlave: {legAccessory: `none`}}); + label.appendChild(generateRows(array)); + } + + el.appendChild(label); + + let links = document.createElement('div'); + links.className = "choices"; + array = [ + {text: "Short stockings", updateSlave: {legAccessory: "short stockings"}}, + {text: "Long stockings", updateSlave: {legAccessory: "long stockings"}} + ]; + links.appendChild(generateRows(array)); + el.appendChild(links); + + return jQuery('#legAccessory').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.legAccessory === `none` || isClothingAccessible.entry(array[i].updateSlave.legAccessory, "legAccessory")) { + // 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.refreshAll = function(slave) { App.UI.Wardrobe.clothes(slave); App.UI.Wardrobe.collar(slave); App.UI.Wardrobe.armAccessory(slave); App.UI.Wardrobe.shoes(slave); + App.UI.Wardrobe.legAccessory(slave); return; };