diff --git a/src/markets/specificMarkets/customSlaveMarket.js b/src/markets/specificMarkets/customSlaveMarket.js index 225dff20dc8af8674ffcc7a0720bbadbc88c8313..cf5a3c3b11d43e35b0587341f394881833ea6614 100644 --- a/src/markets/specificMarkets/customSlaveMarket.js +++ b/src/markets/specificMarkets/customSlaveMarket.js @@ -730,53 +730,40 @@ App.Markets["Custom Slave"] = function() { for (const [value, text] of limbs) { const div = document.createElement("div"); - div.id = `${value}-text`; + + // Desc setup + const descText = document.createElement("span"); + descText.id = (`${value}-text`).replace(/\./g, "-"); const hasLimb = (_.get(slave, value) !== null); - div.append(description(hasLimb, text)); - if (hasLimb) { - div.append( - App.UI.DOM.link( - "Remove", - () => { - _.set(slave, value, null); - jQuery(`#${div.id}`).empty().append(description(false, text)) - } - ) - ); - } else { - div.append( - App.UI.DOM.link( - "Add", - () => { - _.set(slave, value, new App.Entity.LimbState()); - /*switch (value) { - case "arm.left": - slave.arm.left = new App.Entity.LimbState(); - break; - case "arm.right": - slave.arm.left = new App.Entity.LimbState(); - break; - case "leg.left": - slave.arm.left = new App.Entity.LimbState(); - break; - case "leg.right": - slave.arm.left = new App.Entity.LimbState(); - break; - }*/ - jQuery(`#${div.id}`).empty().append(description(true, text)) - } - ) - ); - } + descText.append(description(hasLimb, text)); + div.append(descText); + + const linkArray = []; + linkArray.push( + App.UI.DOM.link( + "Add", + () => { + _.set(slave, value, new App.Entity.LimbState()); + jQuery(`#${div.id}`).empty().append(description(true, text)); + } + ) + ); + linkArray.push( + App.UI.DOM.link( + "Remove", + () => { + _.set(slave, value, null); + jQuery(`#${div.id}`).empty().append(description(false, text)); + } + ) + ); + div.append(App.UI.DOM.generateLinksStrip(linkArray)); el.append(div); } - createDescription(el, description, slaveProperty); - el.append(choicesMaker(slaveProperty, choices, description)); - function description(hasLimb, text) { - return `${text}: ${(hasLimb) ? `Yes` : `No`}`; + return `${text}: ${(hasLimb) ? `Yes` : `No`} `; } return el;