From bfdb374a2c8287b4dea80696928d27aef96fa343 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 17 May 2012 02:16:33 +0200 Subject: allow reverting file from history dropdown --- apps/files_versions/js/versions.js | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'apps/files_versions/js') diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js index eadf7a51039..61090f956f0 100644 --- a/apps/files_versions/js/versions.js +++ b/apps/files_versions/js/versions.js @@ -34,7 +34,7 @@ function createVersionsDropdown(filename, files) { html += ''; html += ''; //html += ''; - html += ''; + html += ''; html += '
'; html += ''; @@ -47,7 +47,7 @@ function createVersionsDropdown(filename, files) { $.ajax({ type: 'GET', - url: OC.linkTo('files_versions', 'ajax/getVersions.php'), + url: OC.filePath('files_versions', 'ajax', 'getVersions.php'), dataType: 'json', data: { source: files }, async: false, @@ -58,34 +58,39 @@ function createVersionsDropdown(filename, files) { if (versions) { $.each( versions, function(index, row ) { - - addVersion( row ); + addVersion( row ); }); } - + $('#found_versions').change(function(){ + var revision=parseInt($(this).val()); + revertFile(files,revision); + }) } }); - function revertFile() { + function revertFile(file, revision) { $.ajax({ type: 'GET', url: OC.linkTo('files_versions', 'ajax/rollbackVersion.php'), dataType: 'json', - data: {path: file, revision: 'revision'}, + data: {file: file, revision: revision}, async: false, - success: function(versions) { - if (versions) { + success: function(response) { + if (response.status=='error') { + OC.dialogs.alert('Failed to revert '+file+' to revision '+formatDate(revision*1000)+'.','Failed to revert'); } } }); } - function addVersion( name ) { - - var version = ''; + function addVersion(revision ) { + name=formatDate(revision*1000); + var version=$('