From 7d6bee9cc5b0965334ca29b1803682527db21ce6 Mon Sep 17 00:00:00 2001
From: ezsh <ezsh.junk@gmail.com>
Date: Thu, 16 May 2019 13:32:59 +0200
Subject: [PATCH] Fix quick scroll buttons targets

The slave containers shall be named "slave-number" and not
"slave_number".
---
 src/js/slaveListing.js | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/js/slaveListing.js b/src/js/slaveListing.js
index b76da962f4a..2b1f75997c8 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'
 			});
 		}
-- 
GitLab