diff --git a/src/interaction/siModify.js b/src/interaction/siModify.js index 21effcd53d69fc9ff12bf7c551332e9173387727..d71672b97352c6cf4e555ca93d185f7174209163 100644 --- a/src/interaction/siModify.js +++ b/src/interaction/siModify.js @@ -1,6 +1,6 @@ /** * @param {App.Entity.SlaveState} slave - * @returns {Node} + * @returns {DocumentFragment} */ App.UI.SlaveInteract.modify = function(slave) { const {he, his} = getPronouns(slave); diff --git a/src/interaction/slaveInteract.js b/src/interaction/slaveInteract.js index 0b85f03a0340a1269c12a7ba07df3954d0bc8a89..f7084dd551061b3c05bedc4c16ea37f237eb705c 100644 --- a/src/interaction/slaveInteract.js +++ b/src/interaction/slaveInteract.js @@ -70,7 +70,7 @@ App.UI.SlaveInteract.mainPage = function(slave) { * @typedef {Object} siCategory * @property {string} title * @property {string} id - * @property {Node} node + * @property {DocumentFragment|HTMLElement} node * @property {Function} [onClick] */ @@ -156,6 +156,10 @@ App.UI.SlaveInteract.mainPage = function(slave) { return el; + /** + * @param {siCategory} item + * @returns {HTMLElement} + */ function makeTabButton(item) { const btn = document.createElement("button"); btn.className = "tab-links"; @@ -173,18 +177,26 @@ App.UI.SlaveInteract.mainPage = function(slave) { } } + /** + * @returns {DocumentFragment} + */ function displayWithoutTabs() { const el = new DocumentFragment(); App.Events.drawEventArt(el, slave); for (const item of buttons) { App.UI.DOM.appendNewElement("h2", el, item.title); - el.append(item.node); + el.append(makeContentSpan(item)); if (item.hasOwnProperty("onClick")) { item.onClick(); } } return el; } + + /** + * @param {siCategory} item + * @returns {HTMLElement} + */ function makeTabContents(item) { const wrapperEl = document.createElement("div"); wrapperEl.id = item.id; @@ -193,14 +205,21 @@ App.UI.SlaveInteract.mainPage = function(slave) { const classEl = document.createElement("div"); classEl.classList.add("content"); + classEl.append(makeContentSpan(item)); + wrapperEl.append(classEl); + + return wrapperEl; + } + + /** + * @param {siCategory} item + * @returns {HTMLElement} + */ + function makeContentSpan(item) { const uniqueContent = document.createElement("span"); uniqueContent.id = `content-${item.id}`; uniqueContent.append(item.node); - classEl.append(uniqueContent); - wrapperEl.append(classEl); - - - return wrapperEl; + return uniqueContent; } };