diff --git a/src/js/slaveListing.js b/src/js/slaveListing.js index b76da962f4a9f0a14fdfe1d5eed1ef27afe5eede..2b1f75997c81d9f30a508d179a24a49facaa2def 100644 --- a/src/js/slaveListing.js +++ b/src/js/slaveListing.js @@ -23,6 +23,9 @@ App.UI.SlaveList.render = function() { /** @type {boolean} */ let slaveImagePrinted; + // potentially can be a problem if played long enough to reach Number.MAX_SAFE_INTEGER + let listID = Number.MIN_SAFE_INTEGER; + return renderList; /** @@ -59,7 +62,7 @@ App.UI.SlaveList.render = function() { for (const _si of indices) { let ss = renderSlave(_si, interactionLink, showTransfers, postNote); - res.push(`<div id="slave_${slaves[_si].ID}" style="clear:both">${ss}</div>`); + res.push(`<div id="slave-${slaves[_si].ID}" style="clear:both">${ss}</div>`); } for (const rs of rejectedSlaves) { @@ -73,7 +76,7 @@ App.UI.SlaveList.render = function() { } $(document).one(':passagedisplay', function() { - $("[data-quick-index]").click(function() { + $('[data-quick-index]').unbind().click(function() { let which = this.attributes["data-quick-index"].value; let quick = $("div#list_index" + which); quick.toggleClass("hidden"); @@ -81,6 +84,10 @@ App.UI.SlaveList.render = function() { quickListBuildLinks(); }); + if (V.useSlaveListInPageJSNavigation === 1) { + listID++; + } + return res.join(""); } @@ -156,7 +163,6 @@ App.UI.SlaveList.render = function() { */ function createQuickList(indices) { let res = ""; - let _tableCount = 0; /* Useful for finding weird combinations — usages of this passage that don't yet generate the quick index. * <<print 'pass/count/indexed/flag::[' + passageName + '/' + _Count + '/' + _indexed + '/' + $SlaveSummaryFiler + ']'>> @@ -169,12 +175,12 @@ App.UI.SlaveList.render = function() { _offset = -25; } res += "<br />"; - _tableCount++; /* - * we want <button data-quick-index="<<= _tableCount>>">... + * we want <button data-quick-index="<<= listID>>">... */ const _buttonAttributes = { - 'data-quick-index': _tableCount + 'id':`quick-list-toggle${listID}`, + 'data-quick-index': listID }; res += App.UI.htag("Quick Index", _buttonAttributes, 'button'); /* @@ -218,7 +224,7 @@ App.UI.SlaveList.render = function() { listIndexContent += '</div>'; } res += App.UI.htag(listIndexContent, { - id: `list_index${_tableCount}`, + id: `list_index${listID}`, class: 'hidden' }); } diff --git a/src/js/utilJS.js b/src/js/utilJS.js index 3ef0515773ed268729ff3b0ec6104585737dac9f..d9f92887d1afea8965062108d77036eb6cf84fbf 100644 --- a/src/js/utilJS.js +++ b/src/js/utilJS.js @@ -1927,7 +1927,7 @@ App.UI.htag = function (text, attributes, tag = 'div') { attributes = `id="${attributes.trim()}"`; } - return `<${tag}${attributes}>${payload}</${tag}>`; + return `<${tag} ${attributes}>${payload}</${tag}>`; }; window.SkillIncrease = (function() {