diff --git a/src/facilities/farmyard/farmyard.tw b/src/facilities/farmyard/farmyard.tw index 61b49e5eeb2661aa430bc2c7b1f6959c124caa8b..901459486d005b6e6d2ae313a89ef4fe3eadf988 100644 --- a/src/facilities/farmyard/farmyard.tw +++ b/src/facilities/farmyard/farmyard.tw @@ -451,3 +451,5 @@ $farmyardNameCaps is an oasis of growth in the midst of the jungle of steel and <<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.farmyard)>> <br><br>Rename $farmyardName: <<textbox "$farmyardName" $farmyardName "Farmyard">> //Use a noun or similar short phrase// + +<<run App.UI.SlaveList.ScrollPosition.restore()>> diff --git a/src/facilities/nursery/nursery.tw b/src/facilities/nursery/nursery.tw index 4b970dbaf1095051c2774a55c7554c8d956a05b1..915c66f57beab6ef70624c35465a50183ba39f9a 100644 --- a/src/facilities/nursery/nursery.tw +++ b/src/facilities/nursery/nursery.tw @@ -418,3 +418,5 @@ FIXME: not sure if this works <br><br> Rename $nurseryName: <<textbox "$nurseryName" $nurseryName "Nursery">> //Use a noun or similar short phrase// + +<<run App.UI.SlaveList.ScrollPosition.restore()>> diff --git a/src/js/assignJS.js b/src/js/assignJS.js index 6a7cfa5bf44b804a23fe6250efe447b50411357c..ea032e85b8a7bd38aae751e1fe0fe8f506a6ca94 100644 --- a/src/js/assignJS.js +++ b/src/js/assignJS.js @@ -702,7 +702,7 @@ App.UI.jobLinks = function() { return res; } - function transfersFragment(index) { + function transfersFragment(index, callback) { /** @type {HTMLElement[]} */ const transfers = []; const slave = App.Utils.slaveByIndex(index); @@ -711,7 +711,7 @@ App.UI.jobLinks = function() { if (!f.established) { continue; } const rejects = f.canHostSlave(slave); if (rejects.length === 0) { - transfers.push(f.transferLinkElement(index, undefined, passage())); + transfers.push(f.transferLinkElement(index, undefined, passage(), callback)); } else { transfers.push(App.UI.DOM.disabledLink(f.genericName, rejects)); } diff --git a/src/js/slaveListing.js b/src/js/slaveListing.js index ca8b29aa9a976456c9e51b6eb8a9081740dfc094..1990b0390b65bee1fce8f687118fc07123cf9e94 100644 --- a/src/js/slaveListing.js +++ b/src/js/slaveListing.js @@ -299,12 +299,12 @@ App.UI.SlaveList.render = function() { res.appendChild(assignment); if ((V.displayAssignments === 1) && (passageName === "Main") && (slave.ID !== V.HeadGirl.ID) && (slave.ID !== V.Recruiter.ID) && (slave.ID !== V.Bodyguard.ID)) { - res.appendChild(App.UI.jobLinks.assignmentsFragment(index, "Main")); + res.appendChild(App.UI.jobLinks.assignmentsFragment(index, "Main", (slave, assignment) => { App.UI.SlaveList.ScrollPosition.record(); assignJob(slave, assignment); })); } if (showTransfers) { res.appendChild(document.createElement("br")); res.appendChild(document.createTextNode('Transfer to: ')); - res.appendChild(App.UI.jobLinks.transfersFragment(index)); + res.appendChild(App.UI.jobLinks.transfersFragment(index, (slave, assignment) => { App.UI.SlaveList.ScrollPosition.record(); assignJob(slave, assignment); })); } res.appendChild(SlaveSummaryUncached(slave)); @@ -457,6 +457,32 @@ App.UI.SlaveList.Decoration.penthousePositions = (slave) => { return null; }; +App.UI.SlaveList.ScrollPosition = (function() { + let lastPassage = null; + let position = 0; + + return { + reset : function() { + lastPassage = null; + position = 0; + }, + + record : function() { + lastPassage = passage(); + position = window.pageYOffset; + }, + + restore : function() { + $(document).one(':passageend', () => { + if (lastPassage === passage()) { + window.scrollTo(0, position); + } + this.reset(); + }); + } + }; +})(); + App.UI.SlaveList.SlaveInteract = {}; /** @@ -465,7 +491,7 @@ App.UI.SlaveList.SlaveInteract = {}; * @returns {HTMLElement} */ App.UI.SlaveList.SlaveInteract.stdInteract = (slave, index) => - App.UI.DOM.passageLink(SlaveFullName(slave), 'Slave Interact', () => { App.Utils.setActiveSlaveByIndex(index); }); + App.UI.DOM.passageLink(SlaveFullName(slave), 'Slave Interact', () => { App.UI.SlaveList.ScrollPosition.record(); App.Utils.setActiveSlaveByIndex(index); }); /** diff --git a/src/uncategorized/brothel.tw b/src/uncategorized/brothel.tw index ee1e6356251ce992ad3bba494308fd3d5742300c..9e10a5cce4ea98775927a2c1ec4a3ce7f4dc9bd7 100644 --- a/src/uncategorized/brothel.tw +++ b/src/uncategorized/brothel.tw @@ -204,3 +204,5 @@ Last week this <<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.brothel)>> <br><br>Rename $brothelName: <<textbox "$brothelName" $brothelName "Brothel">> //Use a noun or similar short phrase// + +<<run App.UI.SlaveList.ScrollPosition.restore()>> diff --git a/src/uncategorized/cellblock.tw b/src/uncategorized/cellblock.tw index 807ce726501dd797b12097bba9844f653edfd9e8..9617373852ac80645c05e406179813bdd80b0d2f 100644 --- a/src/uncategorized/cellblock.tw +++ b/src/uncategorized/cellblock.tw @@ -109,3 +109,5 @@ $cellblockNameCaps <<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.cellblock)>> <br><br>Rename $cellblockName: <<textbox "$cellblockName" $cellblockName "Cellblock">> //Use a noun or similar short phrase// + +<<run App.UI.SlaveList.ScrollPosition.restore()>> diff --git a/src/uncategorized/clinic.tw b/src/uncategorized/clinic.tw index f73345426f75803e74d17d36ca77b187b34fe58e..2a04620e489cc6a17c11f220a7fca53e4f01d841 100644 --- a/src/uncategorized/clinic.tw +++ b/src/uncategorized/clinic.tw @@ -138,3 +138,5 @@ $clinicNameCaps <<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.clinic, true)>> <br><br>Rename $clinicName: <<textbox "$clinicName" $clinicName "Clinic">> //Use a noun or similar short phrase// + +<<run App.UI.SlaveList.ScrollPosition.restore()>> diff --git a/src/uncategorized/club.tw b/src/uncategorized/club.tw index 39993381c863c488f01b40704e8ca3f13075c56a..c5a6c5f3fdbe5347e52bea597c46a1157ad0fe3d 100644 --- a/src/uncategorized/club.tw +++ b/src/uncategorized/club.tw @@ -256,3 +256,5 @@ $clubNameCaps <<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.club)>> <br><br>Rename $clubName: <<textbox "$clubName" $clubName "Club">> //Use a noun or similar short phrase// + +<<run App.UI.SlaveList.ScrollPosition.restore()>> diff --git a/src/uncategorized/main.tw b/src/uncategorized/main.tw index b9fc571e1472e376276cafe247e18314bfa8f4de..ad81505f2668e4033bfa3b92e83b8e4f21cc1f90 100644 --- a/src/uncategorized/main.tw +++ b/src/uncategorized/main.tw @@ -193,3 +193,5 @@ __''MAIN MENU''__ //[[Summary Options]]// <<if ($debugMode == 1)>> //| [[Show all walk past scenes|Walk Past List]]// <</if>> + +<<run App.UI.SlaveList.ScrollPosition.restore()>> diff --git a/src/uncategorized/masterSuite.tw b/src/uncategorized/masterSuite.tw index bbf22969bddeda2e900a8af464b5d7263b65ba4d..5dbf1924576617db1017bbf2676e834c868f0ece 100644 --- a/src/uncategorized/masterSuite.tw +++ b/src/uncategorized/masterSuite.tw @@ -358,3 +358,5 @@ $masterSuiteNameCaps is furnished <<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.masterSuite)>> <br><br>Rename $masterSuiteName: <<textbox "$masterSuiteName" $masterSuiteName "Master Suite">> //Use a noun or similar short phrase// + +<<run App.UI.SlaveList.ScrollPosition.restore()>> diff --git a/src/uncategorized/schoolroom.tw b/src/uncategorized/schoolroom.tw index 9c4b5fce23087c54565f7cf7944b8df69f4251d7..2a501be2d51a134ca5cb4cf7294d50cd8201c8cc 100644 --- a/src/uncategorized/schoolroom.tw +++ b/src/uncategorized/schoolroom.tw @@ -130,3 +130,5 @@ $schoolroomNameCaps is well-equipped, with wallscreens to display lessons. These <<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.schoolroom, true)>> <br><br>Rename $schoolroomName: <<textbox "$schoolroomName" $schoolroomName "Schoolroom">> //Use a noun or similar short phrase// + +<<run App.UI.SlaveList.ScrollPosition.restore()>> diff --git a/src/uncategorized/servantsQuarters.tw b/src/uncategorized/servantsQuarters.tw index 136ff5ae9ebad872e2c764c5c22f7d598d63c89a..add0f4b50075679f9891ec2e4ecf4d14b3c14ceb 100644 --- a/src/uncategorized/servantsQuarters.tw +++ b/src/uncategorized/servantsQuarters.tw @@ -119,3 +119,5 @@ $servantsQuartersNameCaps <<print App.UI.SlaveList.listSJFacilitySlaves(_facility)>> <br><br>Rename $servantsQuartersName: <<textbox "$servantsQuartersName" $servantsQuartersName "Servants' Quarters">> //Use a noun or similar short phrase// + +<<run App.UI.SlaveList.ScrollPosition.restore()>> diff --git a/src/uncategorized/spa.tw b/src/uncategorized/spa.tw index a4043af398ce03c5e72b97e80fefd4b3faa51f06..1721b3dbb1ce48632f5c88fc14a1bf845707ac83 100644 --- a/src/uncategorized/spa.tw +++ b/src/uncategorized/spa.tw @@ -116,3 +116,5 @@ $spaNameCaps <<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.spa, true)>> <br><br>Rename $spaName: <<textbox "$spaName" $spaName "Spa">> //Use a noun or similar short phrase// + +<<run App.UI.SlaveList.ScrollPosition.restore()>>