diff options
Diffstat (limited to 'apps/files/js/files.js')
-rw-r--r-- | apps/files/js/files.js | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 982351c589e..28d4b49670d 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -25,6 +25,18 @@ Files={ delete uploadingFiles[index]; }); procesSelection(); + }, + containsInvalidCharacters:function (name) { + var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*']; + for (var i = 0; i < invalid_characters.length; i++) { + if (name.indexOf(invalid_characters[i]) != -1) { + $('#notification').text(t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed.")); + $('#notification').fadeIn(); + return true; + } + } + $('#notification').fadeOut(); + return false; } }; $(document).ready(function() { @@ -228,7 +240,12 @@ $(document).ready(function() { } }); }else{ - var date=new Date(); + var dropTarget = $(e.originalEvent.target).closest('tr'); + if(dropTarget && dropTarget.attr('data-type') === 'dir') { // drag&drop upload to folder + var dirName = dropTarget.attr('data-file') + } + + var date=new Date(); if(files){ for(var i=0;i<files.length;i++){ if(files[i].size>0){ @@ -281,7 +298,10 @@ $(document).ready(function() { var jqXHR = $('.file_upload_start').fileupload('send', {files: files[i], formData: function(form) { var formArray = form.serializeArray(); - formArray[1]['value'] = dirName; + // array index 0 contains the max files size + // array index 1 contains the request token + // array index 2 contains the directory + formArray[2]['value'] = dirName; return formArray; }}).success(function(result, textStatus, jqXHR) { var response; @@ -291,7 +311,13 @@ $(document).ready(function() { $('#notification').fadeIn(); } var file=response[0]; + // TODO: this doesn't work if the file name has been changed server side delete uploadingFiles[dirName][file.name]; + if ($.assocArraySize(uploadingFiles[dirName]) == 0) { + delete uploadingFiles[dirName]; + } + + var uploadtext = $('tr').filterAttr('data-type', 'dir').filterAttr('data-file', dirName).find('.uploadtext') var currentUploads = parseInt(uploadtext.attr('currentUploads')); currentUploads -= 1; uploadtext.attr('currentUploads', currentUploads); @@ -491,8 +517,10 @@ $(document).ready(function() { $(this).append(input); input.focus(); input.change(function(){ - if(type != 'web' && $(this).val().indexOf('/')!=-1){ - $('#notification').text(t('files','Invalid name, \'/\' is not allowed.')); + if (type != 'web' && Files.containsInvalidCharacters($(this).val())) { + return; + } else if( type == 'folder' && $('#dir').val() == '/' && $(this).val() == 'Shared') { + $('#notification').text(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud')); $('#notification').fadeIn(); return; } @@ -821,7 +849,7 @@ function getSelectedFiles(property){ name:$(element).attr('data-file'), mime:$(element).data('mime'), type:$(element).data('type'), - size:$(element).data('size'), + size:$(element).data('size') }; if(property){ files.push(file[property]); |