From 59a32358b616a3ea249c3b740dba941c9ed20d4c Mon Sep 17 00:00:00 2001 From: lowercasedonkey <lowercasedonkey@gmail.com> Date: Wed, 7 Oct 2020 17:01:35 -0400 Subject: [PATCH] start moving description to dom --- src/interaction/siDescription.js | 61 ++++++++++++++++++++++++++++++ src/uncategorized/slaveInteract.tw | 26 +------------ 2 files changed, 62 insertions(+), 25 deletions(-) create mode 100644 src/interaction/siDescription.js diff --git a/src/interaction/siDescription.js b/src/interaction/siDescription.js new file mode 100644 index 00000000000..947e3581480 --- /dev/null +++ b/src/interaction/siDescription.js @@ -0,0 +1,61 @@ +App.UI.SlaveInteract.description = function(slave) { + const el = document.createElement("p"); + el.id = "si-description"; + el.append(wardrobeContent()); + return el; + + function wardrobeContent() { + const el = new DocumentFragment(); + const descriptionLink = document.createElement("div"); + descriptionLink.style.fontStyle = "italic"; + descriptionLink.id = "description-link"; + if (V.seeDetails === 1) { + descriptionLink.append(showOptions()); + el.append(descriptionLink); + + const descriptionOptions = document.createElement("div"); + descriptionOptions.id = "description-options"; + el.append(descriptionOptions); + + // <span id="LSD"></span> + } else { + descriptionLink.append( + App.UI.DOM.link( + "Show descriptions", + () => { + V.seeDetails = 1; + }, + [], + "Slave Interact" + ) + ); + el.append(descriptionLink); + } + + + return el; + + function showOptions() { + return App.UI.DOM.link( + "Description Options", + () => { + jQuery("#description-link").empty().append(hideOptions()); + jQuery("#description-options").empty().append(App.UI.renderPassage("Description Options")); + } + ); + } + + function hideOptions() { + return App.UI.DOM.link( + "Description Options", + () => { + jQuery("#description-link").empty().append(showOptions()); + jQuery("#description-options").empty().append(App.UI.renderPassage()); + } + ); + } + } + function refresh() { + jQuery("#si-description").empty().append(description()); + } +}; diff --git a/src/uncategorized/slaveInteract.tw b/src/uncategorized/slaveInteract.tw index 426aa8d00c3..cbd7ea5329a 100644 --- a/src/uncategorized/slaveInteract.tw +++ b/src/uncategorized/slaveInteract.tw @@ -77,31 +77,7 @@ <div id="Description" class="tab-content"> <div class="content"> - <<if $seeDetails == 1>> - <div style="font-style:italic"> - <<link "Description Options">> - <<replace #hideOptionPages>> - <<link "(hide)">> - <<replace #hideOptionPages>> - <</replace>> - <<replace #optionPages>> - /* Hide */ - <</replace>> - <</link>> - <</replace>> - <<replace #optionPages>> - <<include "Description Options">> - <</replace>> - <</link>> - <span id="hideOptionPages"></span> - <p id="optionPages"></p> - </div> - <span id="LSD"></span> - <<else>> - <div style="font-style:italic"> - [[Show descriptions|Slave Interact][$seeDetails = 1]] - </div> - <</if>> + </div> </div> -- GitLab