From cb05ca71c4763083a70efb1ba7656925511bf26a Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 22 Sep 2020 13:45:12 +0200 Subject: [PATCH] Semantic history 1 --- www/common/sframe-common-history.js | 48 ++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/www/common/sframe-common-history.js b/www/common/sframe-common-history.js index 399357106..b7f8f97f9 100644 --- a/www/common/sframe-common-history.js +++ b/www/common/sframe-common-history.js @@ -107,6 +107,7 @@ define([ var states = []; var c = 0;//states.length - 1; + var semantic = false; var $hist = $toolbar.find('.cp-toolbar-history'); var $bottom = $toolbar.find('.cp-toolbar-bottom'); @@ -157,6 +158,14 @@ define([ if (cb) { cb(); } }); }; + + var getIndex = function (i) { + return states.length - 1 + i; + }; + var getRank = function (idx) { + return idx - states.length + 1; + }; + get = function (i, blockOnly) { i = parseInt(i); if (isNaN(i)) { return; } @@ -165,7 +174,20 @@ define([ if (i <= -(states.length - 11)) { loadMore(); } - var idx = states.length - 1 + i; + + var idx = getIndex(i); + if (semantic) { + // If semantic is truc, jump to the next patch from a different netflux ID + var author = states[idx].author; + for (j = idx; (j > 1 && j < (states.length - 1)); ((i > c) ? j++ : j--)) { + if (author !== states[j].author) { + idx = j; + i = getRank(idx); + break; + } + } + } + if (blockOnly) { return states[idx]; } var val = states[idx].getContent().doc; @@ -218,6 +240,11 @@ define([ title: Messages.history_restoreTitle }).appendTo($hist);//.text(Messages.history_restore); if (History.readOnly) { $rev.css('visibility', 'hidden'); } + + Messages.history_session = "Group by user"; // XXX + var $cbox = $(UI.createCheckbox('cp-history-session', + Messages.history_session, + false, { label: { class: 'noTitle' } })).appendTo($hist); $('', {'class': 'cp-history-filler'}).appendTo($hist); var $fastPrev = $('