]> source.dussan.org Git - nextcloud-server.git/commitdiff
adapt to isFileNameValid, whitespace cleanup
authorJörn Friedrich Dreyer <jfd@butonic.de>
Mon, 7 Jan 2013 09:39:35 +0000 (10:39 +0100)
committerJörn Friedrich Dreyer <jfd@butonic.de>
Mon, 7 Jan 2013 09:39:35 +0000 (10:39 +0100)
apps/files/js/filelist.js
apps/files/js/files.js

index c4c53ca878a99fa3e94dc6eb290ff3bae9378209..66697bbbf56fd3678008f89aad09995612db49e7 100644 (file)
@@ -151,12 +151,7 @@ var FileList={
                        var newname=input.val();
                        if (!Files.isFileNameValid(newname)) {
                                return false;
-                       } else if (newname.length == 0) {
-                               $('#notification').text(t('files', "Name cannot be empty."));
-                               $('#notification').fadeIn();
-                               return false;
-                       }
-                       if (newname != name) {
+                       } else if (newname != name) {
                                if (FileList.checkName(name, newname, false)) {
                                        newname = name;
                                } else {
index a824b9d3059ded25925cb6d560f13d36183fd405..91204f041e5a55cec8c2b04ef769dcf22855eefe 100644 (file)
@@ -26,19 +26,19 @@ Files={
                });
                procesSelection();
        },
-    isFileNameValid:function (name) {
-        if (name === '.') {
-            $('#notification').text(t('files', "'.' is an invalid file name."));
-            $('#notification').fadeIn();
-            return false;
-        }
-        if (name.length == 0) {
-            $('#notification').text(t('files', "File name cannot be empty."));
-            $('#notification').fadeIn();
-            return false;
-        }
-
-        // check for invalid characters
+       isFileNameValid:function (name) {
+               if (name === '.') {
+                       $('#notification').text(t('files', '\'.\' is an invalid file name.'));
+                       $('#notification').fadeIn();
+                       return false;
+               }
+               if (name.length == 0) {
+                       $('#notification').text(t('files', 'File name cannot be empty.'));
+                       $('#notification').fadeIn();
+                       return false;
+               }
+
+               // check for invalid characters
                var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*'];
                for (var i = 0; i < invalid_characters.length; i++) {
                        if (name.indexOf(invalid_characters[i]) != -1) {
@@ -526,18 +526,14 @@ $(document).ready(function() {
                        event.stopPropagation();
                        event.preventDefault();
                        var newname=input.val();
-                       if(type != 'web' && !Files.isFileNameValid(newname)){
-                               return false;
-                       } else if (newname.length == 0) {
-                               if(type == 'web') {
-                                       $('#notification').text(t('files', "URL cannot be empty."));
-                               } else {
-                                       $('#notification').text(t('files', "Name cannot be empty."));
-                               }
+                       if(type == 'web' && newname.length == 0) {
+                               $('#notification').text(t('files', 'URL cannot be empty.'));
                                $('#notification').fadeIn();
                                return false;
+                       } else if (type != 'web' && !Files.isFileNameValid(newname)) {
+                               return false;
                        } else if( type == 'folder' && $('#dir').val() == '/' && newname == 'Shared') {
-                               $('#notification').text(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud'));
+                               $('#notification').text(t('files','Invalid folder name. Usage of \'Shared\' is reserved by Owncloud'));
                                $('#notification').fadeIn();
                                return false;
                        }