X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/2936591f2732b8c8f23c4edffc0f1a7b30d4bcf0..e8c45077de2d4ada496850fd77fa5035f07f8a4d:/modules/data/data.js diff --git a/modules/data/data.js b/modules/data/data.js index 22c77fe..8c35436 100644 --- a/modules/data/data.js +++ b/modules/data/data.js @@ -92,6 +92,32 @@ return function(sandbox) { }, getHistory: function() { return history; + }, + fetchDiff: function(ver1, ver2) { + $.ajax({ + method: 'get', + url: '/' + gettext('editor') + '/' + document_id + '/diff', + data: {from: ver1, to: ver2}, + success: function(data) { + sandbox.publish('diffFetched', {table: data, ver1: ver1, ver2: ver2}) + }, + }); + }, + restoreVersion: function(options) { + if(options.version && options.description) { + sandbox.publish('restoringStarted', {version: options.version}); + $.ajax({ + method: 'post', + dataType: 'json', + url: '/' + gettext('editor') + '/' + document_id + '/revert', + data: JSON.stringify(options), + success: function(data) { + doc = data.document; + reloadHistory(); + sandbox.publish('documentReverted', {document: data.document, version: data.version}); + }, + }); + } } } };