diff --git a/src/locales/en.json b/src/locales/en.json index fff48f2b2..33c30b50a 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -104,6 +104,7 @@ "pad.chat.stick.title": "Stick chat to screen", "pad.chat.writeMessage.placeholder": "Write your message here", + "timeslider.followContents": "Follow pad content updates", "timeslider.pageTitle": "{{appTitle}} Timeslider", "timeslider.toolbar.returnbutton": "Return to pad", "timeslider.toolbar.authors": "Authors:", diff --git a/src/static/js/broadcast.js b/src/static/js/broadcast.js index 117aab671..6f86e50f6 100644 --- a/src/static/js/broadcast.js +++ b/src/static/js/broadcast.js @@ -255,6 +255,11 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro debugLog(e); } + var lineNumber = Changeset.opIterator(Changeset.unpack(changeset).ops).next().lines; + if($('#options-followContents').is(":checked") || $('#options-followContents').prop("checked")){ + goToLineNumber(lineNumber); + } + Changeset.mutateTextLines(changeset, padContents); padContents.currentRevision = revision; padContents.currentTime += timeDelta * 1000; @@ -585,6 +590,14 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro receiveAuthorData(clientVars.collab_client_vars.historicalAuthorData); return changesetLoader; + + function goToLineNumber(lineNumber){ + // Sets the Y scrolling of the browser to go to this line + var line = $('#innerdocbody').find("div:nth-child("+(lineNumber+1)+")"); + var newY = $(line)[0].offsetTop; + let ecb = document.getElementById('editorcontainerbox'); + ecb.scrollTo({top: newY, behavior: 'smooth'}); + } } exports.loadBroadcastJS = loadBroadcastJS; diff --git a/src/templates/timeslider.html b/src/templates/timeslider.html index 06de51200..ec0c7af1b 100644 --- a/src/templates/timeslider.html +++ b/src/templates/timeslider.html @@ -226,14 +226,20 @@
+ + +
++ + +