Merge pull request #2220 from Gared/timeslider_improvements

Timeslider improvements
pull/2243/head
John McLear 2014-09-06 18:15:37 +01:00
commit bc8b5cc066
2 changed files with 23 additions and 18 deletions

View File

@ -384,22 +384,10 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
}
if (changeset) applyChangeset(changeset, path.rev, true, timeDelta);
if (BroadcastSlider.getSliderLength() > 10000)
{
var start = (Math.floor((newRevision) / 10000) * 10000); // revision 0 to 10
changesetLoader.queueUp(start, 100);
}
if (BroadcastSlider.getSliderLength() > 1000)
{
var start = (Math.floor((newRevision) / 1000) * 1000); // (start from -1, go to 19) + 1
changesetLoader.queueUp(start, 10);
}
start = (Math.floor((newRevision) / 100) * 100);
changesetLoader.queueUp(start, 1, update);
// Loading changeset history for new revision
loadChangesetsForRevision(newRevision, update);
// Loading changeset history for old revision (to make diff between old and new revision)
loadChangesetsForRevision(padContents.currentRevision - 1);
}
var authors = _.map(padContents.getActiveAuthors(), function(name){
@ -407,6 +395,24 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
});
BroadcastSlider.setAuthors(authors);
}
function loadChangesetsForRevision(revision, callback) {
if (BroadcastSlider.getSliderLength() > 10000)
{
var start = (Math.floor((revision) / 10000) * 10000); // revision 0 to 10
changesetLoader.queueUp(start, 100);
}
if (BroadcastSlider.getSliderLength() > 1000)
{
var start = (Math.floor((revision) / 1000) * 1000); // (start from -1, go to 19) + 1
changesetLoader.queueUp(start, 10);
}
start = (Math.floor((revision) / 100) * 100);
changesetLoader.queueUp(start, 1, callback);
}
changesetLoader = {
running: false,
@ -482,7 +488,7 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
var astart = start + i * granularity - 1; // rev -1 is a blank single line
var aend = start + (i + 1) * granularity - 1; // totalRevs is the most recent revision
if (aend > data.actualEndNum - 1) aend = data.actualEndNum - 1;
debugLog("adding changeset:", astart, aend);
//debugLog("adding changeset:", astart, aend);
var forwardcs = Changeset.moveOpsToNewPool(data.forwardsChangesets[i], pool, padContents.apool);
var backwardcs = Changeset.moveOpsToNewPool(data.backwardsChangesets[i], pool, padContents.apool);
revisionInfo.addChangeset(astart, aend, forwardcs, backwardcs, data.timeDeltas[i]);

View File

@ -334,7 +334,6 @@ function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
$("#ui-slider-bar").mousedown(function(evt)
{
setSliderPosition(Math.floor((evt.clientX - $("#ui-slider-bar").offset().left) * sliderLength / 742));
$("#ui-slider-handle").css('left', (evt.clientX - $("#ui-slider-bar").offset().left));
$("#ui-slider-handle").trigger(evt);
});