From e1bff1b1f29eea30a9f7e068df73883a06f8e437 Mon Sep 17 00:00:00 2001 From: Svornost <11434-svornost@users.noreply.gitgud.io> Date: Fri, 8 May 2020 12:41:34 -0700 Subject: [PATCH] Add a utility function for simple labeled choice lists, and use it where applicable --- src/interaction/slaveInteract.js | 202 +++++-------------------------- 1 file changed, 31 insertions(+), 171 deletions(-) diff --git a/src/interaction/slaveInteract.js b/src/interaction/slaveInteract.js index 248c14d6048..b60f2cf0b4b 100644 --- a/src/interaction/slaveInteract.js +++ b/src/interaction/slaveInteract.js @@ -623,87 +623,16 @@ App.UI.SlaveInteract.drugs = function(slave) { title.appendChild(App.UI.SlaveInteract.generateRows(drugLevelOptions, slave)); el.append(title); - let links; - if (lips.length) { - links = document.createElement('div'); - links.append(`Lips: `); - links.appendChild(App.UI.SlaveInteract.generateRows(lips, slave)); - links.className = "choices"; - el.append(links); - } - - if (breasts.length) { - links = document.createElement('div'); - links.append(`Breasts: `); - links.appendChild(App.UI.SlaveInteract.generateRows(breasts, slave)); - links.className = "choices"; - el.append(links); - } - - if (nipples.length) { - links = document.createElement('div'); - links.append(`Nipples: `); - links.appendChild(App.UI.SlaveInteract.generateRows(nipples, slave)); - links.className = "choices"; - el.append(links); - } - - if (butt.length) { - links = document.createElement('div'); - links.append(`Butt: `); - links.appendChild(App.UI.SlaveInteract.generateRows(butt, slave)); - links.className = "choices"; - el.append(links); - } - - if (dick.length) { - links = document.createElement('div'); - links.append(`Dick: `); - links.appendChild(App.UI.SlaveInteract.generateRows(dick, slave)); - links.className = "choices"; - el.append(links); - } - - if (balls.length) { - links = document.createElement('div'); - links.append(`Balls: `); - links.appendChild(App.UI.SlaveInteract.generateRows(balls, slave)); - links.className = "choices"; - el.append(links); - } - - if (fertility.length) { - links = document.createElement('div'); - links.append(`Fertility: `); - links.appendChild(App.UI.SlaveInteract.generateRows(fertility, slave)); - links.className = "choices"; - el.append(links); - } - - if (hormones.length) { - links = document.createElement('div'); - links.append(`Hormones: `); - links.appendChild(App.UI.SlaveInteract.generateRows(hormones, slave)); - links.className = "choices"; - el.append(links); - } - - if (psych.length) { - links = document.createElement('div'); - links.append(`Psych: `); - links.appendChild(App.UI.SlaveInteract.generateRows(psych, slave)); - links.className = "choices"; - el.append(links); - } - - if (misc.length) { - links = document.createElement('div'); - links.append(`Misc: `); - links.appendChild(App.UI.SlaveInteract.generateRows(misc, slave)); - links.className = "choices"; - el.append(links); - } - + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Lips", lips, slave); + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Breasts", breasts, slave); + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Nipples", nipples, slave); + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Butt", butt, slave); + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Dick", dick, slave); + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Balls", balls, slave); + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Fertility", fertility, slave); + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Hormones", hormones, slave); + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Psych", psych, slave); + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Misc", misc, slave); return jQuery('#drugs').empty().append(el); }; @@ -858,46 +787,11 @@ App.UI.SlaveInteract.diet = function(slave) { } } - let links; - if (health.length) { - links = document.createElement('div'); - links.append(`Health: `); - links.appendChild(App.UI.SlaveInteract.generateRows(health, slave)); - links.className = "choices"; - el.append(links); - } - - if (weight.length) { - links = document.createElement('div'); - links.append(`Weight: `); - links.appendChild(App.UI.SlaveInteract.generateRows(weight, slave)); - links.className = "choices"; - el.append(links); - } - - if (muscle.length) { - links = document.createElement('div'); - links.append(`Muscle: `); - links.appendChild(App.UI.SlaveInteract.generateRows(muscle, slave)); - links.className = "choices"; - el.append(links); - } - - if (production.length) { - links = document.createElement('div'); - links.append(`Production: `); - links.appendChild(App.UI.SlaveInteract.generateRows(production, slave)); - links.className = "choices"; - el.append(links); - } - - if (hormone.length) { - links = document.createElement('div'); - links.append(`Hormone: `); - links.appendChild(App.UI.SlaveInteract.generateRows(hormone, slave)); - links.className = "choices"; - el.append(links); - } + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Health", health, slave); + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Weight", weight, slave); + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Muscle", muscle, slave); + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Production", production, slave); + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Hormone", hormone, slave); return jQuery('#diet').empty().append(el); }; @@ -920,7 +814,6 @@ App.UI.SlaveInteract.dietBase = function(slave) { milk.push({text: `Milk`, disabled: `Diet is based entirely on cum`}); } - // Cum if (slave.dietMilk < 2) { cum.push({text: `Cum added`, updateSlave: {dietCum: 1}}); @@ -955,21 +848,8 @@ App.UI.SlaveInteract.dietBase = function(slave) { title.append(choice); el.append(title); - let links; - if (milk.length) { - links = document.createElement('div'); - links.append(`Milk: `); - links.appendChild(App.UI.SlaveInteract.generateRows(milk, slave)); - links.className = "choices"; - el.append(links); - } - if (cum.length) { - links = document.createElement('div'); - links.append(`Cum: `); - links.appendChild(App.UI.SlaveInteract.generateRows(cum, slave)); - links.className = "choices"; - el.append(links); - } + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Milk", milk, slave); + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Cum", cum, slave); return jQuery('#dietBase').empty().append(el); }; @@ -1002,7 +882,6 @@ App.UI.SlaveInteract.snacks = function(slave) { title.append(choice); el.append(title); - options.push({text: `No access`, updateSlave: {onDiet: 1}}); options.push({text: `Full access`, updateSlave: {onDiet: 0}}); @@ -2203,7 +2082,6 @@ App.UI.SlaveInteract.smartSettings = function(slave) { } let title = document.createElement('div'); - title.textContent = ``; if (slave.clitPiercing === 3) { if (slave.dick < 1) { title.textContent = `${His} smart clit piercing `; @@ -2231,38 +2109,10 @@ App.UI.SlaveInteract.smartSettings = function(slave) { title.append(selected); el.append(title); - let links; - if (level.length) { - links = document.createElement('div'); - links.append(`Level: `); - links.appendChild(App.UI.SlaveInteract.generateRows(level, slave)); - links.className = "choices"; - el.append(links); - } - - if (bodyPart.length) { - links = document.createElement('div'); - links.append(`Body part: `); - links.appendChild(App.UI.SlaveInteract.generateRows(bodyPart, slave)); - links.className = "choices"; - el.append(links); - } - - if (BDSM.length) { - links = document.createElement('div'); - links.append(`BDSM: `); - links.appendChild(App.UI.SlaveInteract.generateRows(BDSM, slave)); - links.className = "choices"; - el.append(links); - } - - if (gender.length) { - links = document.createElement('div'); - links.append(`Gender: `); - links.appendChild(App.UI.SlaveInteract.generateRows(gender, slave)); - links.className = "choices"; - el.append(links); - } + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Level", level, slave); + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Body part", bodyPart, slave); + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "BDSM", BDSM, slave); + App.UI.SlaveInteract.appendLabeledChoiceRow(el, "Gender", gender, slave); return jQuery('#smartSettings').empty().append(el); }; @@ -3116,6 +2966,16 @@ App.UI.SlaveInteract.custom = (function() { } })(); +App.UI.SlaveInteract.appendLabeledChoiceRow = function(parent, label, array, slave) { + if (array.length > 0) { + let links = document.createElement('div'); + links.append(`${label}: `); + links.appendChild(App.UI.SlaveInteract.generateRows(array, slave)); + links.className = "choices"; + return parent.appendChild(links); + } +}; + App.UI.SlaveInteract.generateRows = function(array, slave, category, accessCheck = false) { // category should be in the form of slave.category, the thing we want to update. let row = document.createElement('span'); let useSep = false; -- GitLab