From 05fe8e71550e5211afa6289c4005214eb3903a3a Mon Sep 17 00:00:00 2001 From: Svornost <11434-svornost@users.noreply.gitgud.io> Date: Fri, 8 May 2020 13:08:53 -0700 Subject: [PATCH] JSDoc --- src/interaction/slaveInteract.js | 37 ++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/interaction/slaveInteract.js b/src/interaction/slaveInteract.js index b60f2cf0b4b..84f1b19fe6c 100644 --- a/src/interaction/slaveInteract.js +++ b/src/interaction/slaveInteract.js @@ -1,4 +1,9 @@ /* eslint-disable no-unused-vars */ // TODO: remove after testing + +/** Find the previous and next slaves' IDs based on the current sort order + * @param {App.Entity.SlaveState} slave + * @returns {[number, number]} - previous and next slave ID + */ App.UI.SlaveInteract.placeInLine = function(slave) { const useSlave = assignmentVisible(slave) ? ((s) => assignmentVisible(s)) : ((s) => slave.assignment === s.assignment); const slaveList = V.slaves.filter(useSlave); @@ -97,6 +102,7 @@ App.UI.SlaveInteract.modify = function(slave) { /** * @param {App.Entity.SlaveState} slave + * @returns {Node} */ App.UI.SlaveInteract.fucktoyPref = function(slave) { const {his} = getPronouns(slave); @@ -247,7 +253,7 @@ App.UI.SlaveInteract.work = function(slave) { // CAN BE REASSIGNED span.classList.remove("note"); span.id = "assignmentLinks"; - span.appendChild(App.UI.SlaveInteract.assignmentBlock("assignmentLinks", slave)); + span.appendChild(App.UI.SlaveInteract.assignmentBlock(slave)); if ((V.brothel + V.club + V.dairy + V.farmyard + V.servantsQuarters + V.masterSuite + V.spa + V.nursery + V.clinic + V.schoolroom + V.cellblock + V.arcade + V.HGSuite) > 0) { span.append(`Transfer to: `); @@ -321,10 +327,9 @@ App.UI.SlaveInteract.work = function(slave) { }; /** - * @param {string} blockId * @param {App.Entity.SlaveState} slave */ -App.UI.SlaveInteract.assignmentBlock = function(blockId, slave) { +App.UI.SlaveInteract.assignmentBlock = function(slave) { let el = document.createElement('div'); let title = document.createElement('div'); let separator = document.createTextNode(` | `); @@ -2966,6 +2971,22 @@ App.UI.SlaveInteract.custom = (function() { } })(); +/** @typedef RowItem + * @type {object} + * @property {string} [FS] - FS requirement, if any + * @property {string} [text] - link text + * @property {object} [updateSlave] - properties to be merged onto the slave + * @property {object} [update] - properties to be merged into global state + * @property {string} [disabled] - text indicating why the option is unavailable + * @property {string} [note] + */ + +/** Append a simple row of choices with a label to a container, if there are choices to be made. + * @param {Node} parent + * @param {string} label + * @param {RowItem[]} array + * @param {App.Entity.SlaveState} slave + */ App.UI.SlaveInteract.appendLabeledChoiceRow = function(parent, label, array, slave) { if (array.length > 0) { let links = document.createElement('div'); @@ -2976,7 +2997,14 @@ App.UI.SlaveInteract.appendLabeledChoiceRow = function(parent, label, array, sla } }; -App.UI.SlaveInteract.generateRows = function(array, slave, category, accessCheck = false) { // category should be in the form of slave.category, the thing we want to update. +/** Generate a row of choices + * @param {RowItem[]} array + * @param {App.Entity.SlaveState} slave + * @param {string} [category] - should be in the form of slave.category, the thing we want to update. + * @param {boolean} [accessCheck=false] + * @returns {HTMLSpanElement} + */ +App.UI.SlaveInteract.generateRows = function(array, slave, category, accessCheck = false) { let row = document.createElement('span'); let useSep = false; for (let i = 0; i < array.length; i++) { @@ -3044,6 +3072,7 @@ App.UI.SlaveInteract.generateRows = function(array, slave, category, accessCheck return row; + /** @param {RowItem} arrayOption */ function click(arrayOption) { if (arrayOption.updateSlave) { for (const slaveProperty in arrayOption.updateSlave) { -- GitLab