diff --git a/devNotes/QuickList.txt b/devNotes/QuickList.txt new file mode 100644 index 0000000000000000000000000000000000000000..632cf31284fee54d07a5fa6ffdca26fbe7473353 --- /dev/null +++ b/devNotes/QuickList.txt @@ -0,0 +1,37 @@ + +QuickList is built from the interaction of six parts. + +1] The Quick List option enable/disable control. +2] The list context, basically if there are more than one, and the + context is correct, the togle, the table will be available. +3] The Slave Summary Passage contains the Quick List toggle button, + clicking it either shows or hides the quick list table. +4] The Slave Summary Passage contains the actual quick list table, which + if shown has a button for each slave name in the list, in columns up + to 5 wide. +5] The Slave Summary Passage contains invivisible <a> links or any other + html element nearby or tied to each slave's name. These are + generated with an html attribute id set to "slave-##" where ## is the + slave's ID. +6] The JS code to tie a scroll animation from the visible name buttons + in the quick list table down to the invisible links/elements. + +The slave summary passage is called in many strange contexts, and for +this reason, there is some serious complexity in getting consistent +results. As it stands now, the passage sometimes calls itsefl +recursively (for facilities), but it doesn't do that for the Main +penthouse page. + +The list context is duplicated, so that we can quickly loop over the +list context to get the slave names in the list, all without disturbing +the principal list context for the slave data. + +If the list context has more than one slave, and is either the first +call for the Main/penthous list, or the recursive call for any other +facility, And we haven't *already* built a quick list table, then we +procede to build the quick list table. + +We use special attributes on the built button to name the invisible +link to which we'll navigate, the speed that we'll animate our +navigation and an offset. + diff --git a/src/uncategorized/slaveSummary.tw b/src/uncategorized/slaveSummary.tw index f74359b4764d39c527c1a5e7d6fe3ad178ec6e3b..b22fca3376b1b0943cead2a30c1aa01198305cfa 100644 --- a/src/uncategorized/slaveSummary.tw +++ b/src/uncategorized/slaveSummary.tw @@ -90,12 +90,18 @@ <<capture _ssi>> <<if $useSlaveListInPageJSNavigation == 1>> - <<set _Count = _indexSlavesIdxs.length>> - <<if ((_Count > 1) && (_indexed == 0) && (((_Pass == 'Main') && (ndef $Flag)) || ($Flag == 1)))>> - <<set _indexed = 1, _counter = 0, _buttons = []>> - <style> - .hidden {display:none;} - table.quicklist { + <<set _Count = _indexSlavesIdxs.length>> + /* Useful for finding weird combinations -- usages of this passage that don't yet generate the quick index. + * <<print 'pass/count/indexed/flag::[' + _Pass + '/' + _Count + '/' + _indexed + '/' + $Flag + ']'>> + */ + <<if ((_Count > 1) && (_indexed == 0) && (((_Pass == 'Main') && (ndef $Flag)) || ($Flag == 1)))>> + <<set _indexed = 1, _counter = 0, _buttons = [], _offset = -50>> + <<if (/Select/i.test(_Pass))>> + <<set _offset = -25>> + <</if>> + <style> + .hidden { display:none; } + table.quicklist { table-layout: fixed; text-align: center; border-collapse: separate; @@ -103,62 +109,68 @@ border-style: hidden; empty-cells: hide; width: 70%; - } + } table.quicklist td { margin: 1px; } table.quicklist col { width: 8%; } - </style> + </style> <br /> <button data-quick-index="1">Quick Index</button> - <div id="list_index" class="hidden"> - <<for !_.isUndefined(_ssii = _indexSlavesIdxs.shift())>> - <<set _IndexSlave = $slaves[_ssii]>> - <<if $surnameOrder != 1>> - <<if ["Cambodian", "Chinese", "Hungarian", "Japanese", "Korean", "Mongolian", "Taiwanese", "Vietnamese"].includes(_Slave.nationality)>> - <<set _indexSlaveName = [_IndexSlave.slaveSurname || "", _IndexSlave.slaveName].join(" ").trim()>> - <<else>> - <<set _indexSlaveName = [_IndexSlave.slaveName, _IndexSlave.slaveSurname || ""].join(" ").trim()>> - <</if>> - <<else>> - <<set _indexSlaveName = [_IndexSlave.slaveName, _IndexSlave.slaveSurname || ""].join(" ").trim()>> - <</if>> - <<set _buttons.push('<button data-scroll-to="#slave-' + _IndexSlave.ID + '" data-scroll-offset="300">' + _indexSlaveName + '</button>'); >> - <</for>> + <div id="list_index" class="hidden"> + <<for !_.isUndefined(_ssii = _indexSlavesIdxs.shift())>> + <<set _IndexSlave = $slaves[_ssii]>> + <<if $surnameOrder != 1>> + <<if ["Cambodian", "Chinese", "Hungarian", "Japanese", "Korean", "Mongolian", "Taiwanese", "Vietnamese"].includes(_IndexSlave.nationality)>> + <<set _indexSlaveName = [_IndexSlave.slaveSurname || "", _IndexSlave.slaveName].join(" ").trim()>> + <<else>> + <<set _indexSlaveName = [_IndexSlave.slaveName, _IndexSlave.slaveSurname || ""].join(" ").trim()>> + <</if>> + <<else>> + <<set _indexSlaveName = [_IndexSlave.slaveName, _IndexSlave.slaveSurname || ""].join(" ").trim()>> + <</if>> + <<set _buttons.push('<button data-scroll-to="#slave-' + _IndexSlave.ID + '" data-scroll-offset="' + _offset + '">' + _indexSlaveName + '</button>'); >> + <</for>> <<if !_.isUndefined(_buttons[0])>> - <table class="quicklist"> + <table class="quicklist"> <<for !_.isUndefined(_buttons[0])>> <tr> - <<for _cols = 0; _cols <= 4; _cols++>> - <<set _button = _buttons.shift()>> - <<if !_.isUndefined(_button)>> - <td></td> + <<for _cols = 0; _cols <= 4; _cols++>> + <<set _button = _buttons.shift()>> + <<if !_.isUndefined(_button)>> + <td></td> <td colspan="10"> - <<print _button>> - </td> - <</if>> - <</for>> - <td></td> - </tr> - <</for>> + <<print _button>> + </td> + <</if>> + <</for>> + <td></td> + </tr> + <</for>> </table> - <script> + <script> /* * Use javascript scrollTop animation for in page navigation. */ - $("[data-quick-index]").click(function() { - var $quick = $('div#list_index'); - $quick.toggleClass("hidden"); - }); - $("[data-scroll-to]").click(function() { - var $this = $(this); - var $toElement = $this.attr('data-scroll-to'), $offset = $this.attr('data-scroll-offset') || 0, $speed = $this.attr('data-scroll-speed') || 900; - $('html, body').animate( { - scrollTop: $($toElement).offset().top + $offset - }, $speed); + $("[data-quick-index]").click(function () { + var $quick = $('div#list_index'); + $quick.toggleClass("hidden"); + }); + $("[data-scroll-to]").click(function() { + var $this = $(this), $toElement = $this.attr('data-scroll-to'), + /* + * note the *1 enforces $offset to be an integer, without + * it we scroll to True, which goes nowhere fast. + */ + $offset = $this.attr('data-scroll-offset') * 1 || 0, + $speed = $this.attr('data-scroll-speed') * 1 || 500; + $('html, body').animate({ + scrollTop: $($toElement).offset().top + $offset + }, $speed); + }); - </script> - <</if>> - </div> - <</if>> + </script> + <</if>> + </div> + <</if>> <</if>> <<switch _Pass>> <<case "Main">> @@ -213,7 +225,6 @@ <<elseif "guard you" == _Slave.assignment>>''@@.lightcoral;BG@@'' <</if>> <<if Array.isArray($personalAttention) && $personalAttention.findIndex(function(s) { return s.ID == _Slave.ID; }) != -1>>''@@.lightcoral;PA@@''<</if>> - <<print '<a id="slave-' + $slaves[_ssi].ID + '"></a>'>> [[_slaveName|Slave Interact][$activeSlave = $slaves[_ssi]]] /* lists their names */ <<case "Personal Attention Select">> @@ -252,7 +263,6 @@ [[_slaveName|Slave Interact][$activeSlave = $slaves[_ssi]]] <<else>> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> - <<print '<a id="slave-' + $slaves[_ssi].ID + '"></a>'>> [[_slaveName|Slave Interact][$activeSlave = $slaves[_ssi]]] <</if>> <<case "Subordinate Targeting">> @@ -275,7 +285,6 @@ <</if>> <<elseif $Flag == 1>> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> - <<print '<a id="slave-' + $slaves[_ssi].ID + '"></a>'>> [[_slaveName|Slave Interact][$activeSlave = $slaves[_ssi]]] <<else>> <<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> @@ -301,11 +310,10 @@ <</if>> <<elseif $Flag == 1>> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> - <<print '<a id="slave-' + $slaves[_ssi].ID + '"></a>'>> [[_slaveName|Slave Interact][$activeSlave = $slaves[_ssi]]] <<else>> <<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> - [[_slaveName|Slave Interact][$activeSlave = $slaves[_ssi]]] + [[_slaveName|Slave Interact][$activeSlave = $slaves[_ssi]]] <</if>> <<case "Madam Select">> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> @@ -327,7 +335,6 @@ <</if>> <<elseif $Flag == 1>> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> - <<print '<a id="slave-' + $slaves[_ssi].ID + '"></a>'>> [[_slaveName|Slave Interact][$activeSlave = $slaves[_ssi]]] <<else>> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> @@ -348,11 +355,10 @@ <</if>> <<elseif $Flag == 1>> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> - <<print '<a id="slave-' + $slaves[_ssi].ID + '"></a>'>> [[_slaveName|Slave Interact][$activeSlave = $slaves[_ssi]]] <<else>> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> - [[_slaveName|Slave Interact][$activeSlave = $slaves[_ssi]]] + [[_slaveName|Slave Interact][$activeSlave = $slaves[_ssi]]] <</if>> <<case "Nurse Select">> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> @@ -374,7 +380,6 @@ <</if>> <<elseif $Flag == 1>> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> - <<print '<a id="slave-' + $slaves[_ssi].ID + '"></a>'>> [[_slaveName|Slave Interact][$activeSlave = $slaves[_ssi]]] <<else>> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> @@ -429,7 +434,6 @@ <</if>> <<elseif $Flag == 1>> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> - <<print '<a id="slave-' + $slaves[_ssi].ID + '"></a>'>> [[_slaveName|Slave Interact][$activeSlave = $slaves[_ssi]]] <<else>> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> @@ -450,7 +454,6 @@ <</if>> <<elseif $Flag == 1>> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> - <<print '<a id="slave-' + $slaves[_ssi].ID + '"></a>'>> [[_slaveName|Slave Interact][$activeSlave = $slaves[_ssi]]] <<else>> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> @@ -463,7 +466,7 @@ <<if $Flag == 0>> <<if $masterSuite <= $masterSuiteSlaves>><<continue>><</if>> <<if (_Slave.devotion > 20) || ((_Slave.devotion >= -50) && (_Slave.trust < -20)) || (_Slave.trust < -50)>> - <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if> + <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> [[_slaveName|Slave Interact][$activeSlave = $slaves[_ssi]]] <<else>> <br>//_Slave.slaveName is not sufficiently broken for the master suite// @@ -471,7 +474,6 @@ <</if>> <<elseif $Flag == 1>> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> - <<print '<a id="slave-' + $slaves[_ssi].ID + '"></a>'>> [[_slaveName|Slave Interact][$activeSlave = $slaves[_ssi]]] <<else>> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> @@ -493,7 +495,6 @@ <</if>> <<elseif $Flag == 1>> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> - <<print '<a id="slave-' + $slaves[_ssi].ID + '"></a>'>> [[_slaveName|Slave Interact][$activeSlave = $slaves[_ssi]]] <<else>> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> @@ -520,7 +521,6 @@ <</if>> <<else>> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> - <<print '<a id="slave-' + $slaves[_ssi].ID + '"></a>'>> [[_slaveName|Slave Interact][$activeSlave = $slaves[_ssi]]] <</if>> <<case "Pit">> @@ -574,7 +574,6 @@ <</if>> <<case "Matchmaking">> <br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>><<if ($seeImages == 1) && ($seeSummaryImages == 1)>><div class="imageRef smlImg"><<SlaveArt _Slave 1>></div><</if>> - <<print '<a id="slave-' + $slaves[_ssi].ID + '"></a>'>> [[_slaveName|Slave Interact][$activeSlave = $slaves[_ssi]]] <</switch>> @@ -748,7 +747,8 @@ will <</if>> /* closes _numFacilities */ -<br><<if $seeImages != 1 || $seeSummaryImages != 1 || $imageChoice == 1>> <</if>> +<<print '<span id="slave-' + $slaves[_ssi].ID + '"> </span><br/>'>> +<<if $seeImages != 1 || $seeSummaryImages != 1 || $imageChoice == 1>> <</if>> <<SlaveSummary _Slave>>