diff --git a/src/interaction/slaveInteract.js b/src/interaction/slaveInteract.js index 20d546640eb16af8e2d2878650fc259c949bbd8b..247d227709a69f3fd17d64a82394195894688d00 100644 --- a/src/interaction/slaveInteract.js +++ b/src/interaction/slaveInteract.js @@ -2771,38 +2771,49 @@ App.UI.SlaveInteract.custom = (function() { App.UI.DOM.link( title, () => { - // Randomize the array - const shuffled = array.sort(() => 0.5 - Math.random()); - - // Get the first three new names - const names = []; - for (let i = 0; names.length < 3; i++) { - if (i > shuffled.length) { - break; - } - if (shuffled[i] !== slave.slaveName) { - names.push(shuffled[i]); - } - } - - // return the three names as links - const nameLinks = []; - for (const name of names) { - nameLinks.push( - App.UI.DOM.link( - name, - () => { - slave.slaveName = name; - updateName(slave, {oldName:oldName, oldSurname:oldSurname}); - } - ) - ); - } - jQuery(`#${id}`).empty().append(App.UI.DOM.generateLinksStrip(nameLinks)); + linkGuts(); } ) ); return el; + function linkGuts() { + // Randomize the array + const shuffled = array.sort(() => 0.5 - Math.random()); + + // Get the first three new names + const names = []; + for (let i = 0; names.length < 3; i++) { + if (i > shuffled.length) { + break; + } + if (shuffled[i] !== slave.slaveName) { + names.push(shuffled[i]); + } + } + + // return the three names as links + const nameLinks = []; + for (const name of names) { + nameLinks.push( + App.UI.DOM.link( + name, + () => { + slave.slaveName = name; + updateName(slave, {oldName:oldName, oldSurname:oldSurname}); + } + ) + ); + } + nameLinks.push( + App.UI.DOM.link( + "...", + () => { + linkGuts(); + } + ) + ); + jQuery(`#${id}`).empty().append(App.UI.DOM.generateLinksStrip(nameLinks)); + } } }