From a8aaf505d2feb79910ce6dd761549c011a06644a Mon Sep 17 00:00:00 2001 From: Svornost <11434-svornost@users.noreply.gitgud.io> Date: Sun, 16 Aug 2020 02:43:09 -0700 Subject: [PATCH] Move genre choice links to DOM to make the next bit of SlaveInteract conversion easier for lowercasedonkey. --- src/js/porn.js | 10 +++++++--- src/uncategorized/slaveInteract.tw | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/js/porn.js b/src/js/porn.js index f646c25d68c..c9ee2b723ba 100644 --- a/src/js/porn.js +++ b/src/js/porn.js @@ -620,10 +620,14 @@ App.Porn.getGenresByType = function(type) { return _.values(App.Porn.Genre).filter((g) => g.type === type); }; -/** Returns a string with the pipe-separated SugarCube links necessary to set any valid genre for this slave. +/** Returns the links necessary to set any valid porn genre for this slave. * @param {string} page SugarCube passage name to redirect to when the link is clicked + * @param {App.Entity.SlaveState} slave + * @returns {HTMLElement} */ App.Porn.genreChoiceLinks = function(page, slave) { - let makeLink = function(genre) { return App.UI.link(genre.uiName(), (s, g) => s.porn.focus = g.focusName, [slave, genre], page); }; - return this.getAllGenres().filter((g) => g.valid(slave)).map((g) => makeLink(g)).reduce((acc, cur) => `${acc} | ${cur}`); + let makeLink = function(genre) { return App.UI.DOM.link(genre.uiName(), (s, g) => s.porn.focus = g.focusName, [slave, genre], page); }; + let links = this.getAllGenres().filter((g) => g.valid(slave)).map(makeLink); + links.push(App.UI.DOM.link("No focus", (s) => s.porn.focus = "none", [slave], page)); + return App.UI.DOM.generateLinksStrip(links); }; diff --git a/src/uncategorized/slaveInteract.tw b/src/uncategorized/slaveInteract.tw index c80382f4ac8..a8fb058ab4e 100644 --- a/src/uncategorized/slaveInteract.tw +++ b/src/uncategorized/slaveInteract.tw @@ -316,7 +316,7 @@ <<else>> You are focusing attention on the <<= getSlave($AS).porn.focus>> aspect of $his content. <</if>> - <<= App.Porn.genreChoiceLinks("Slave Interact", getSlave($AS))>> | [[No focus|Slave Interact][getSlave($AS).porn.focus = "none"]] + <<includeDOM App.Porn.genreChoiceLinks("Slave Interact", getSlave($AS))>> <</if>> <</if>> <</if>> -- GitLab