Skip to content
Snippets Groups Projects
Commit f5890dc5 authored by lowercasedonkey's avatar lowercasedonkey
Browse files

use "of" for loop

parent 3e8a692f
No related branches found
No related tags found
1 merge request!8066Simplify appendLabeledChoiceRow() thanks to new scope
......@@ -44,40 +44,40 @@ App.UI.SlaveInteract.placeInLine = function(slave) {
*/
App.UI.SlaveInteract.generateRows = function(array, slave, category, accessCheck = false, refresh) {
const linkArray = [];
for (let i = 0; i < array.length; i++) {
for (const item of array) {
let link;
// Some items will never be in App.Data.slaveWear, especially "none" if it falls in between harsh and nice data sets. Trying to look it up would cause an error, which is what access check works around.
let unlocked = false;
if (accessCheck === true) {
const itemName = (category === "chastity") ? array[i].text.toLowerCase() : array[i].updateSlave[category]; // Yucky. Category name does not match for chastity (since it sets multiple kinds of chastity at once). Compare using a lowercase name instead.
const itemName = (category === "chastity") ? item.text.toLowerCase() : item.updateSlave[category]; // Yucky. Category name does not match for chastity (since it sets multiple kinds of chastity at once). Compare using a lowercase name instead.
unlocked = isItemAccessible.entry(itemName, category, slave);
}
if (accessCheck === false || unlocked) {
// is it just text?
if (array[i].disabled) {
link = App.UI.DOM.disabledLink(array[i].text, [array[i].disabled]);
if (item.disabled) {
link = App.UI.DOM.disabledLink(item.text, [item.disabled]);
} else if (typeof unlocked === 'string') {
link = App.UI.DOM.disabledLink(array[i].text, [unlocked]);
link = App.UI.DOM.disabledLink(item.text, [unlocked]);
} else {
link = document.createElement('span');
// Set up the link
link.appendChild(
App.UI.DOM.link(
`${array[i].text} `,
() => { click(array[i]); },
`${item.text} `,
() => { click(item); },
)
);
if (array[i].FS) {
let FS = App.UI.DOM.disabledLink(`FS`, [FutureSocieties.displayAdj(array[i].FS)]);
if (item.FS) {
let FS = App.UI.DOM.disabledLink(`FS`, [FutureSocieties.displayAdj(item.FS)]);
FS.style.fontStyle = "italic";
link.appendChild(FS);
}
// add a note node if required
if (array[i].note) {
link.appendChild(App.UI.DOM.makeElement('span', ` ${array[i].note}`, 'note'));
if (item.note) {
link.appendChild(App.UI.DOM.makeElement('span', ` ${item.note}`, 'note'));
}
}
linkArray.push(link);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment