From 0eba56a23ef06431ba0b39d8a1636c2f1dc9b737 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 22 Sep 2020 15:23:16 +0200 Subject: [PATCH] Add time of patch in OO history and better keyboard shortcuts --- www/common/onlyoffice/history.js | 120 ++++++++++--------------------- www/common/onlyoffice/inner.js | 15 ++-- 2 files changed, 42 insertions(+), 93 deletions(-) diff --git a/www/common/onlyoffice/history.js b/www/common/onlyoffice/history.js index e9cec385b..5f144aa8b 100644 --- a/www/common/onlyoffice/history.js +++ b/www/common/onlyoffice/history.js @@ -1,9 +1,10 @@ define([ 'jquery', '/common/common-interface.js', + '/common/hyperscript.js', '/bower_components/nthen/index.js', //'/bower_components/chainpad-json-validator/json-ot.js', -], function ($, UI, nThen, /* JsonOT */) { +], function ($, UI, h, nThen, /* JsonOT */) { //var ChainPad = window.ChainPad; var History = {}; @@ -42,6 +43,29 @@ define([ if (endWithCp) { cpIndex = 0; } + var $loadMore, $version, $time; + + var showVersion = function (initial) { + var major = sortedCp.length - cpIndex; + var v = major + '.' + msgIndex; + if (initial) { + v = "Latest"; // XXX + } + $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)); + $pos.css('margin-left', p+'%'); + + var time = msgs[msgIndex].time; + if (time) { $time.text(new Date(time).toLocaleString()); } + else { $time.text(''); } + }; + // We want to load a checkpoint (or initial state) var loadMoreOOHistory = function () { if (!Array.isArray(sortedCp)) { return void console.error("Wrong type"); } @@ -127,33 +151,10 @@ define([ UI.spinner($hist).get().show(); - var $loadMore, $version, get; - - var showVersion = function (initial) { - var major = sortedCp.length - cpIndex; - var v = major + '.' + msgIndex; - if (initial) { - v = "Latest"; // XXX - } - $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)); - $pos.css('margin-left', p+'%'); - }; - var $fastPrev = $('