Add version number in oo history

pull/1/head
yflory 4 years ago
parent 20b23ee9d1
commit 3c5d3ce43e

@ -41,6 +41,7 @@
width: 100%; width: 100%;
text-align: center; text-align: center;
color: black; color: black;
left: 0;
} }
.cp-toolbar-history-goto { .cp-toolbar-history-goto {
display: inline-block; display: inline-block;

@ -64,6 +64,8 @@ define([
var fromHash = nextId ? hashes[nextId].hash : config.onlyoffice.lastHash; var fromHash = nextId ? hashes[nextId].hash : config.onlyoffice.lastHash;
msgIndex = 0; msgIndex = 0;
showVersion();
if (ooMessages[id]) { if (ooMessages[id]) {
// Cp already loaded: reload OO // Cp already loaded: reload OO
loading = false; loading = false;
@ -123,14 +125,28 @@ define([
var $loadMore, $version, get; var $loadMore, $version, get;
var showVersion = function () {
var major = sortedCp.length - cpIndex;
var v = major + '.' + msgIndex;
$version.text("Version " + v); // XXX
var $pos = $hist.find('.cp-toolbar-history-pos');
var cps = sortedCp.length;
var id = sortedCp[cps - cpIndex -1] || -1;
if (!ooMessages[id]) { return; }
var msgs = ooMessages[id];
var p = 100*(msgIndex / (msgs.length-1));
$pos.css('margin-left', p+'%');
};
var $fastPrev = $('<button>', { var $fastPrev = $('<button>', {
'class': 'cp-toolbar-history-fast-previous fa fa-fast-backward buttonPrimary', 'class': 'cp-toolbar-history-fast-previous fa fa-fast-backward buttonPrimary',
title: Messages.history_prev title: Messages.history_prev
}); });
var $prev = $('<button>', { /*var $prev = $('<button>', {
'class': 'cp-toolbar-history-previous fa fa-step-backward buttonPrimary', 'class': 'cp-toolbar-history-previous fa fa-step-backward buttonPrimary',
title: Messages.history_prev title: Messages.history_prev
}); });*/
var $next = $('<button>', { var $next = $('<button>', {
'class': 'cp-toolbar-history-next fa fa-step-forward buttonPrimary', 'class': 'cp-toolbar-history-next fa fa-step-forward buttonPrimary',
title: Messages.history_next title: Messages.history_next
@ -142,7 +158,7 @@ define([
update = function () { update = function () {
var cps = sortedCp.length; var cps = sortedCp.length;
$prev.show(); //$prev.show();
$fastPrev.show(); $fastPrev.show();
$next.show(); $next.show();
$fastNext.show(); $fastNext.show();
@ -155,9 +171,9 @@ define([
} }
var id = sortedCp[cps - cpIndex -1] || -1; var id = sortedCp[cps - cpIndex -1] || -1;
var msgs = (ooMessages[id] || []).length; var msgs = (ooMessages[id] || []).length;
if (msgIndex <= 0) { /*if (msgIndex <= 0) {
$prev.hide(); $prev.hide();
} }*/
if (msgIndex >= (msgs - 1)) { if (msgIndex >= (msgs - 1)) {
$next.hide(); $next.hide();
} }
@ -187,9 +203,6 @@ define([
$hist.find('.cp-toolbar-history-next').css('visibility', 'hidden'); $hist.find('.cp-toolbar-history-next').css('visibility', 'hidden');
$hist.find('.cp-toolbar-history-fast-next').css('visibility', 'hidden'); $hist.find('.cp-toolbar-history-fast-next').css('visibility', 'hidden');
} }
var $pos = $hist.find('.cp-toolbar-history-pos');
var p = 100 * (1 - (-c / (states.length-2)));
$pos.css('margin-left', p+'%');
// Display the version when the full history is loaded // Display the version when the full history is loaded
// Note: the first version is always empty and probably can't be displayed, so // Note: the first version is always empty and probably can't be displayed, so
@ -216,6 +229,7 @@ define([
config.onPatch(patch); config.onPatch(patch);
loading = false; loading = false;
msgIndex++; msgIndex++;
showVersion();
}; };
// Create the history toolbar // Create the history toolbar
@ -230,7 +244,7 @@ define([
$('<span>', {'class': 'cp-history-filler'}).appendTo($hist); $('<span>', {'class': 'cp-history-filler'}).appendTo($hist);
$fastPrev.appendTo($hist); $fastPrev.appendTo($hist);
$prev.hide().appendTo($hist); //$prev.hide().appendTo($hist);
var $nav = $('<div>', {'class': 'cp-toolbar-history-goto'}).appendTo($hist); var $nav = $('<div>', {'class': 'cp-toolbar-history-goto'}).appendTo($hist);
$next.hide().appendTo($hist); $next.hide().appendTo($hist);
$fastNext.hide().appendTo($hist); $fastNext.hide().appendTo($hist);
@ -251,7 +265,7 @@ define([
$version = $('<span>', { $version = $('<span>', {
'class': 'cp-toolbar-history-version' 'class': 'cp-toolbar-history-version'
}).prependTo($bar).hide(); }).prependTo($bar);
/* /*
$loadMore = $('<button>', { $loadMore = $('<button>', {
@ -296,12 +310,12 @@ define([
update(); update();
}); });
// Reset current checkpoint // Reset current checkpoint
$prev.click(function () { /*$prev.click(function () {
if (loading) { return; } if (loading) { return; }
loading = true; loading = true;
loadMoreOOHistory(); loadMoreOOHistory();
update(); update();
}); });*/
// Go to previous checkpoint // Go to previous checkpoint
$fastNext.click(function () { $fastNext.click(function () {
if (loading) { return; } if (loading) { return; }
@ -314,7 +328,9 @@ define([
$fastPrev.click(function () { $fastPrev.click(function () {
if (loading) { return; } if (loading) { return; }
loading = true; loading = true;
cpIndex++; if (msgIndex === 0) {
cpIndex++;
}
loadMoreOOHistory(); loadMoreOOHistory();
update(); update();
}); });
@ -331,6 +347,12 @@ define([
}; };
display(); display();
if (config.onlyoffice.lastHash === hashes[sortedCp[sortedCp.length - 1]].hash) {
cpIndex = 0;
}
showVersion();
//return void loadMoreOOHistory(); //return void loadMoreOOHistory();
}; };

Loading…
Cancel
Save