From aaf0fec9f54bc6f9eef5df00441d593e053ee74b Mon Sep 17 00:00:00 2001 From: kondou Date: Wed, 31 Jul 2013 21:21:02 +0200 Subject: Fix some JSLint warnings --- apps/files/js/file-upload.js | 23 +++++++++++------------ apps/files/js/fileactions.js | 2 +- apps/files/js/keyboardshortcuts.js | 4 ++-- 3 files changed, 14 insertions(+), 15 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index 942a07dfccc..08047c25fdb 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -1,6 +1,6 @@ $(document).ready(function() { - file_upload_param = { + var file_upload_param = { dropZone: $('#content'), // restrict dropZone to content div //singleFileUploads is on by default, so the data.files array will always have length 1 add: function(e, data) { @@ -142,7 +142,7 @@ $(document).ready(function() { $('#uploadprogressbar').progressbar('value',100); $('#uploadprogressbar').fadeOut(); } - } + }; var file_upload_handler = function() { $('#file_upload_start').fileupload(file_upload_param); }; @@ -156,20 +156,21 @@ $(document).ready(function() { // http://stackoverflow.com/a/6700/11236 var size = 0, key; for (key in obj) { - if (obj.hasOwnProperty(key)) size++; + if (obj.hasOwnProperty(key)) { size++; } } return size; }; // warn user not to leave the page while upload is in progress $(window).bind('beforeunload', function(e) { - if ($.assocArraySize(uploadingFiles) > 0) + if ($.assocArraySize(uploadingFiles) > 0) { return t('files','File upload is in progress. Leaving the page now will cancel the upload.'); + } }); //add multiply file upload attribute to all browsers except konqueror (which crashes when it's used) if(navigator.userAgent.search(/konqueror/i)==-1){ - $('#file_upload_start').attr('multiple','multiple') + $('#file_upload_start').attr('multiple','multiple'); } //if the breadcrumb is to long, start by replacing foldernames with '...' except for the current folder @@ -179,7 +180,7 @@ $(document).ready(function() { crumb=crumb.next('div.crumb'); } //if that isn't enough, start removing items from the breacrumb except for the current folder and it's parent - var crumb=$('div.crumb').first(); + crumb=$('div.crumb').first(); var next=crumb.next('div.crumb'); while($('div.controls').height()>40 && next.next('div.crumb').length>0){ crumb.remove(); @@ -189,7 +190,7 @@ $(document).ready(function() { //still not enough, start shorting down the current folder name var crumb=$('div.crumb>a').last(); while($('div.controls').height()>40 && crumb.text().length>6){ - var text=crumb.text() + var text=crumb.text(); text=text.substr(0,text.length-6)+'...'; crumb.text(text); } @@ -291,7 +292,7 @@ $(document).ready(function() { } var localName=name; if(localName.substr(localName.length-1,1)=='/'){//strip / - localName=localName.substr(0,localName.length-1) + localName=localName.substr(0,localName.length-1); } if(localName.indexOf('/')){//use last part of url localName=localName.split('/').pop(); @@ -300,8 +301,7 @@ $(document).ready(function() { } localName = getUniqueName(localName); //IE < 10 does not fire the necessary events for the progress bar. - if($('html.lte9').length > 0) { - } else { + if($('html.lte9').length === 0) { $('#uploadprogressbar').progressbar({value:0}); $('#uploadprogressbar').fadeIn(); } @@ -309,8 +309,7 @@ $(document).ready(function() { var eventSource=new OC.EventSource(OC.filePath('files','ajax','newfile.php'),{dir:$('#dir').val(),source:name,filename:localName}); eventSource.listen('progress',function(progress){ //IE < 10 does not fire the necessary events for the progress bar. - if($('html.lte9').length > 0) { - } else { + if($('html.lte9').length === 0) { $('#uploadprogressbar').progressbar('value',progress); } }); diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index aa66a57a7b5..f05a320e72d 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -200,7 +200,7 @@ FileActions.register('all', 'Rename', OC.PERMISSION_UPDATE, function () { FileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename) { - var dir = $('#dir').val() + var dir = $('#dir').val(); if (dir !== '/') { dir = dir + '/'; } diff --git a/apps/files/js/keyboardshortcuts.js b/apps/files/js/keyboardshortcuts.js index cc2b5d42139..1d3bae925bc 100644 --- a/apps/files/js/keyboardshortcuts.js +++ b/apps/files/js/keyboardshortcuts.js @@ -131,7 +131,7 @@ var Files = Files || {}; return; } var preventDefault = false; - if ($.inArray(event.keyCode, keys) === -1) keys.push(event.keyCode); + if ($.inArray(event.keyCode, keys) === -1) { keys.push(event.keyCode); } if ( $.inArray(keyCodes.n, keys) !== -1 && ($.inArray(keyCodes.cmdFirefox, keys) !== -1 || $.inArray(keyCodes.cmdOpera, keys) !== -1 || $.inArray(keyCodes.leftCmdWebKit, keys) !== -1 || $.inArray(keyCodes.rightCmdWebKit, keys) !== -1 || $.inArray(keyCodes.ctrl, keys) !== -1 || event.ctrlKey)) { preventDefault = true; //new file/folder prevent browser from responding @@ -165,4 +165,4 @@ var Files = Files || {}; removeA(keys, event.keyCode); }); }; -})(Files); \ No newline at end of file +})(Files); -- cgit v1.2.3 From 1348330c7d75d2b60d845a43be57dedc6199ea1a Mon Sep 17 00:00:00 2001 From: kondou Date: Thu, 1 Aug 2013 18:44:01 +0200 Subject: Fix a syntax error & have if-conds in an own line --- apps/files/js/file-upload.js | 4 +++- apps/files/js/keyboardshortcuts.js | 4 +++- apps/files_sharing/js/public.js | 2 +- core/js/oc-dialogs.js | 28 +++++++++++++++++++++------- settings/js/users.js | 4 +++- 5 files changed, 31 insertions(+), 11 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index 08047c25fdb..87d8b353b68 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -156,7 +156,9 @@ $(document).ready(function() { // http://stackoverflow.com/a/6700/11236 var size = 0, key; for (key in obj) { - if (obj.hasOwnProperty(key)) { size++; } + if (obj.hasOwnProperty(key)) { + size++; + } } return size; }; diff --git a/apps/files/js/keyboardshortcuts.js b/apps/files/js/keyboardshortcuts.js index 1d3bae925bc..9d6c3ae8c33 100644 --- a/apps/files/js/keyboardshortcuts.js +++ b/apps/files/js/keyboardshortcuts.js @@ -131,7 +131,9 @@ var Files = Files || {}; return; } var preventDefault = false; - if ($.inArray(event.keyCode, keys) === -1) { keys.push(event.keyCode); } + if ($.inArray(event.keyCode, keys) === -1) { + keys.push(event.keyCode); + } if ( $.inArray(keyCodes.n, keys) !== -1 && ($.inArray(keyCodes.cmdFirefox, keys) !== -1 || $.inArray(keyCodes.cmdOpera, keys) !== -1 || $.inArray(keyCodes.leftCmdWebKit, keys) !== -1 || $.inArray(keyCodes.rightCmdWebKit, keys) !== -1 || $.inArray(keyCodes.ctrl, keys) !== -1 || event.ctrlKey)) { preventDefault = true; //new file/folder prevent browser from responding diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index 6182e1dde0e..7ffd5e06873 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -51,7 +51,7 @@ $(document).ready(function() { } // Add some form data to the upload handler - var file_upload_param.formData = { + file_upload_param.formData = { MAX_FILE_SIZE: $('#uploadMaxFilesize').val(), requesttoken: $('#publicUploadRequestToken').val(), dirToken: $('#dirToken').val(), diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js index 04fc43af001..b3b1958659f 100644 --- a/core/js/oc-dialogs.js +++ b/core/js/oc-dialogs.js @@ -79,9 +79,15 @@ var OCdialogs = { title: title }).data('path', ''); - if (modal === undefined) { modal = false; } - if (multiselect === undefined) { multiselect = false; } - if (mimetype_filter === undefined) { mimetype_filter = ''; } + if (modal === undefined) { + modal = false; + } + if (multiselect === undefined) { + multiselect = false; + } + if (mimetype_filter === undefined) { + mimetype_filter = ''; + } $('body').append(self.$filePicker); @@ -155,7 +161,9 @@ var OCdialogs = { message: content, type: dialog_type }); - if (modal === undefined) { modal = false; } + if (modal === undefined) { + modal = false; + } $('body').append($dlg); var buttonlist = []; switch (buttons) { @@ -163,7 +171,9 @@ var OCdialogs = { buttonlist = [{ text: t('core', 'Yes'), click: function(){ - if (callback !== undefined) { callback(true); } + if (callback !== undefined) { + callback(true); + } $(dialog_id).ocdialog('close'); }, defaultButton: true @@ -171,7 +181,9 @@ var OCdialogs = { { text: t('core', 'No'), click: function(){ - if (callback !== undefined) { callback(false); } + if (callback !== undefined) { + callback(false); + } $(dialog_id).ocdialog('close'); } }]; @@ -179,7 +191,9 @@ var OCdialogs = { case OCdialogs.OK_BUTTON: var functionToCall = function() { $(dialog_id).ocdialog('close'); - if(callback !== undefined) { callback(); } + if(callback !== undefined) { + callback(); + } }; buttonlist[0] = { text: t('core', 'Ok'), diff --git a/settings/js/users.js b/settings/js/users.js index 798acce8471..ac0d7638f72 100644 --- a/settings/js/users.js +++ b/settings/js/users.js @@ -166,7 +166,9 @@ var UserList = { var c = Number(aa[x]), d = Number(bb[x]); if (c === aa[x] && d === bb[x]) { return c - d; - } else { return (aa[x] > bb[x]) ? 1 : -1; } + } else { + return (aa[x] > bb[x]) ? 1 : -1; + } } } return aa.length - bb.length; -- cgit v1.2.3