X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/2936591f2732b8c8f23c4edffc0f1a7b30d4bcf0..73a6ba2accc1ac01c6a525a477f7c99c6ee4f3e6:/modules/data/data.js?ds=sidebyside diff --git a/modules/data/data.js b/modules/data/data.js index 22c77fe..e2cdbb1 100644 --- a/modules/data/data.js +++ b/modules/data/data.js @@ -92,6 +92,35 @@ 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}); + }, + }); + } + }, + getDocumentId: function() { + return document_id; } } };