Clean up: removing unused template
[fnpeditor.git] / modules / data / data.js
index 22c77fe..e2cdbb1 100644 (file)
@@ -92,6 +92,35 @@ return function(sandbox) {
         },\r
         getHistory: function() {\r
             return history;\r
         },\r
         getHistory: function() {\r
             return history;\r
+        },\r
+        fetchDiff: function(ver1, ver2) {\r
+            $.ajax({\r
+                method: 'get',\r
+                url: '/' + gettext('editor') + '/' + document_id + '/diff',\r
+                data: {from: ver1, to: ver2},\r
+                success: function(data) {\r
+                    sandbox.publish('diffFetched', {table: data, ver1: ver1, ver2: ver2})\r
+                },\r
+            });\r
+        },\r
+        restoreVersion: function(options) {\r
+            if(options.version && options.description) {\r
+                sandbox.publish('restoringStarted', {version: options.version});\r
+                $.ajax({\r
+                    method: 'post',\r
+                    dataType: 'json',\r
+                    url: '/' + gettext('editor') + '/' + document_id + '/revert',\r
+                    data: JSON.stringify(options),\r
+                    success: function(data) {\r
+                        doc = data.document;\r
+                        reloadHistory();\r
+                        sandbox.publish('documentReverted', {document: data.document, version: data.version});\r
+                    },\r
+                }); \r
+            }\r
+        },\r
+        getDocumentId: function() {\r
+            return document_id;\r
         }\r
     }\r
 };\r
         }\r
     }\r
 };\r