diff --git a/src/markets/specificMarkets/prestigiousSlave.js b/src/markets/specificMarkets/prestigiousSlave.js index 1cc36d988025870fe9d772bf524a7c45266d43d6..d6b28bb6f34692f88d1a06cda40a2441c36de5d5 100644 --- a/src/markets/specificMarkets/prestigiousSlave.js +++ b/src/markets/specificMarkets/prestigiousSlave.js @@ -31,22 +31,27 @@ App.Markets["Prestigious Slave"] = function() { "d streamer", ]; App.UI.DOM.appendNewElement("p", el, `You check to see if any especially prestigious slaves are on auction.`); + const content = App.UI.DOM.appendNewElement("span", el); if (V.prestigeAuctioned === 1) { App.UI.DOM.appendNewElement("span", el, ` There are none available right now, but there probably will be next week.`); } else { V.prestigeAuctioned = 1; seed = jsEither(Math.random() * 100 < V.seeDicks ? dickOptions : options); - el.append(passage()); + content.append(passage()); } return el; function passage() { - const el = document.createElement("span"); + const frag = new DocumentFragment(); if (V.cheatMode || V.debugMode) { + const reload = () => { + $(content).empty(); + content.append(passage()); + }; if (V.seeDicks > 0) { options = options.concat(...dickOptions); } - const slaveDropdown = App.UI.DOM.appendNewElement("select", el); + const slaveDropdown = App.UI.DOM.appendNewElement("select", frag); for (const o of options) { const choice = App.UI.DOM.appendNewElement("option", slaveDropdown, o); choice.value = o; @@ -57,18 +62,18 @@ App.Markets["Prestigious Slave"] = function() { slaveDropdown.onchange = () => { const O = slaveDropdown.options[slaveDropdown.selectedIndex]; seed = O.value; - $(el).empty(); - passage(); + reload(); }; + App.UI.DOM.appendNewElement("span", frag, App.UI.DOM.link("Refresh slave", reload)); } slave = makeSlave(seed); const cost = slaveCost(slave); - App.UI.DOM.appendNewElement("p", el, `It will take ${cashFormat(cost)} to win the auction.`); + App.UI.DOM.appendNewElement("p", frag, `It will take ${cashFormat(cost)} to win the auction.`); if (V.cash >= cost) { App.UI.DOM.appendNewElement( "p", - el, + frag, App.UI.DOM.link( `Place that bid`, () => { @@ -78,11 +83,11 @@ App.Markets["Prestigious Slave"] = function() { ) ); } else { - App.UI.DOM.appendNewElement("p", el, `You lack the necessary funds to place a winning bid.`, "note"); + App.UI.DOM.appendNewElement("p", frag, `You lack the necessary funds to place a winning bid.`, "note"); } - el.append(App.Desc.longSlave(slave, {market: "generic"})); - return el; + frag.append(App.Desc.longSlave(slave, {market: "generic"})); + return frag; }