From bf61d841a2b3305bc51de6109917725466239061 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20M=C3=BCller?= Date: Mon, 28 Apr 2014 16:51:57 +0200 Subject: [PATCH] typos, naming, remove unused code, identation --- apps/files/js/filelist.js | 28 +++++++--------- apps/files/js/files.js | 63 ++++++++++++++++-------------------- apps/files/js/filesummary.js | 1 - 3 files changed, 39 insertions(+), 53 deletions(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 5667d07ede7..40ec898635e 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -323,7 +323,7 @@ window.FileList = { mimetype: $el.attr('data-mime'), type: $el.attr('data-type'), size: parseInt($el.attr('data-size'), 10), - etag: $el.attr('data-etag'), + etag: $el.attr('data-etag') }; }, @@ -371,7 +371,7 @@ window.FileList = { /** * Sets the files to be displayed in the list. - * This operation will rerender the list and update the summary. + * This operation will re-render the list and update the summary. * @param filesArray array of file data (map) */ setFiles: function(filesArray) { @@ -673,7 +673,6 @@ window.FileList = { */ changeDirectory: function(targetDir, changeUrl, force) { var $dir = $('#dir'), - url, currentDir = $dir.val() || '/'; targetDir = targetDir || '/'; if (!force && currentDir === targetDir) { @@ -971,19 +970,16 @@ window.FileList = { event.stopPropagation(); event.preventDefault(); try { - var newname = input.val(); - var directory = FileList.getCurrentDirectory(); - if (newname !== oldname) { + var newName = input.val(); + if (newName !== oldname) { checkInput(); - // save background image, because it's replaced by a spinner while async request - var oldBackgroundImage = td.css('background-image'); // mark as loading td.css('background-image', 'url('+ OC.imagePath('core', 'loading.gif') + ')'); $.ajax({ url: OC.filePath('files','ajax','rename.php'), data: { dir : $('#dir').val(), - newname: newname, + newname: newName, file: oldname }, success: function(result) { @@ -1004,20 +1000,20 @@ window.FileList = { } input.tipsy('hide'); tr.data('renaming',false); - tr.attr('data-file', newname); + tr.attr('data-file', newName); var path = td.children('a.name').attr('href'); // FIXME this will fail if the path contains the filename. - td.children('a.name').attr('href', path.replace(encodeURIComponent(oldname), encodeURIComponent(newname))); - var basename = newname; - if (newname.indexOf('.') > 0 && tr.data('type') !== 'dir') { - basename = newname.substr(0, newname.lastIndexOf('.')); + td.children('a.name').attr('href', path.replace(encodeURIComponent(oldname), encodeURIComponent(newName))); + var basename = newName; + if (newName.indexOf('.') > 0 && tr.data('type') !== 'dir') { + basename = newName.substr(0, newName.lastIndexOf('.')); } td.find('a.name span.nametext').text(basename); - if (newname.indexOf('.') > 0 && tr.data('type') !== 'dir') { + if (newName.indexOf('.') > 0 && tr.data('type') !== 'dir') { if ( ! td.find('a.name span.extension').exists() ) { td.find('a.name span.nametext').append(''); } - td.find('a.name span.extension').text(newname.substr(newname.lastIndexOf('.'))); + td.find('a.name span.extension').text(newName.substr(newName.lastIndexOf('.'))); } form.remove(); FileActions.display( tr.find('td.filename'), true); diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 6857450602c..6d167851e64 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -8,8 +8,8 @@ * */ -/* global OC, t, n, FileList, FileActions */ -/* global getURLParameter, isPublic */ +/* global OC, t, FileList */ +/* global getURLParameter */ var Files = { // file space size sync _updateStorageStatistics: function() { @@ -96,10 +96,10 @@ var Files = { throw t('files', 'File name cannot be empty.'); } // check for invalid characters - var invalid_characters = + var invalidCharacters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*', '\n']; - for (var i = 0; i < invalid_characters.length; i++) { - if (trimmedName.indexOf(invalid_characters[i]) !== -1) { + for (var i = 0; i < invalidCharacters.length; i++) { + if (trimmedName.indexOf(invalidCharacters[i]) !== -1) { throw t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed."); } } @@ -116,7 +116,8 @@ var Files = { return; } if (usedSpacePercent > 90) { - OC.Notification.show(t('files', 'Your storage is almost full ({usedSpacePercent}%)', {usedSpacePercent: usedSpacePercent})); + OC.Notification.show(t('files', 'Your storage is almost full ({usedSpacePercent}%)', + {usedSpacePercent: usedSpacePercent})); } }, @@ -222,7 +223,7 @@ $(document).ready(function() { // TODO use OC.dialogs $(document).bind('drop dragover', function (e) { e.preventDefault(); // prevent browser from doing anything, if file isn't dropped in dropZone - }); + }); //do a background scan if needed scanFiles(); @@ -299,16 +300,6 @@ function scanFiles(force, dir, users) { } scanFiles.scanning=false; -function boolOperationFinished(data, callback) { - result = jQuery.parseJSON(data.responseText); - Files.updateMaxUploadFilesize(result); - if (result.status === 'success') { - callback.call(); - } else { - alert(result.data.message); - } -} - // TODO: move to FileList var createDragShadow = function(event) { //select dragged file @@ -362,25 +353,25 @@ var dragOptions={ revert: 'invalid', revertDuration: 300, opacity: 0.7, zIndex: 100, appendTo: 'body', cursorAt: { left: 24, top: 18 }, helper: createDragShadow, cursor: 'move', - start: function(event, ui){ - var $selectedFiles = $('td.filename input:checkbox:checked'); - if($selectedFiles.length > 1){ - $selectedFiles.parents('tr').fadeTo(250, 0.2); - } - else{ - $(this).fadeTo(250, 0.2); - } - }, - stop: function(event, ui) { - var $selectedFiles = $('td.filename input:checkbox:checked'); - if($selectedFiles.length > 1){ - $selectedFiles.parents('tr').fadeTo(250, 1); - } - else{ - $(this).fadeTo(250, 1); - } - $('#fileList tr td.filename').addClass('ui-draggable'); + start: function(event, ui){ + var $selectedFiles = $('td.filename input:checkbox:checked'); + if($selectedFiles.length > 1){ + $selectedFiles.parents('tr').fadeTo(250, 0.2); + } + else{ + $(this).fadeTo(250, 0.2); + } + }, + stop: function(event, ui) { + var $selectedFiles = $('td.filename input:checkbox:checked'); + if($selectedFiles.length > 1){ + $selectedFiles.parents('tr').fadeTo(250, 1); } + else{ + $(this).fadeTo(250, 1); + } + $('#fileList tr td.filename').addClass('ui-draggable'); + } }; // sane browsers support using the distance option if ( $('html.ie').length === 0) { @@ -446,7 +437,7 @@ Files.generatePreviewUrl = function(urlSpec) { urlSpec.x *= window.devicePixelRatio; urlSpec.forceIcon = 0; return OC.generateUrl('/core/preview.png?') + $.param(urlSpec); -} +}; Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) { // get mime icon url diff --git a/apps/files/js/filesummary.js b/apps/files/js/filesummary.js index b3e3beeb24a..b5130247cc9 100644 --- a/apps/files/js/filesummary.js +++ b/apps/files/js/filesummary.js @@ -167,7 +167,6 @@ var summary = this.summary; var directoryInfo = n('files', '%n folder', '%n folders', summary.totalDirs); var fileInfo = n('files', '%n file', '%n files', summary.totalFiles); - var fileSize; var infoVars = { dirs: ''+directoryInfo+'', -- 2.39.5