Merge pull request #4262 from owncloud/fix_jslint_kondou

Fix some JSLint warnings
This commit is contained in:
Christopher 2013-08-20 12:45:10 -07:00
commit 90da518e3e
19 changed files with 82 additions and 64 deletions

View File

@ -1,6 +1,6 @@
$(document).ready(function() { $(document).ready(function() {
file_upload_param = { var file_upload_param = {
dropZone: $('#content'), // restrict dropZone to content div dropZone: $('#content'), // restrict dropZone to content div
//singleFileUploads is on by default, so the data.files array will always have length 1 //singleFileUploads is on by default, so the data.files array will always have length 1
add: function(e, data) { add: function(e, data) {
@ -142,7 +142,7 @@ $(document).ready(function() {
$('#uploadprogressbar').progressbar('value',100); $('#uploadprogressbar').progressbar('value',100);
$('#uploadprogressbar').fadeOut(); $('#uploadprogressbar').fadeOut();
} }
} };
var file_upload_handler = function() { var file_upload_handler = function() {
$('#file_upload_start').fileupload(file_upload_param); $('#file_upload_start').fileupload(file_upload_param);
}; };
@ -163,13 +163,14 @@ $(document).ready(function() {
// warn user not to leave the page while upload is in progress // warn user not to leave the page while upload is in progress
$(window).bind('beforeunload', function(e) { $(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.'); 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) //add multiply file upload attribute to all browsers except konqueror (which crashes when it's used)
if(navigator.userAgent.search(/konqueror/i)==-1){ 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 //if the breadcrumb is to long, start by replacing foldernames with '...' except for the current folder
@ -302,8 +303,7 @@ $(document).ready(function() {
} }
localName = getUniqueName(localName); localName = getUniqueName(localName);
//IE < 10 does not fire the necessary events for the progress bar. //IE < 10 does not fire the necessary events for the progress bar.
if($('html.lte9').length > 0) { if($('html.lte9').length === 0) {
} else {
$('#uploadprogressbar').progressbar({value:0}); $('#uploadprogressbar').progressbar({value:0});
$('#uploadprogressbar').fadeIn(); $('#uploadprogressbar').fadeIn();
} }
@ -311,8 +311,7 @@ $(document).ready(function() {
var eventSource=new OC.EventSource(OC.filePath('files','ajax','newfile.php'),{dir:$('#dir').val(),source:name,filename:localName}); var eventSource=new OC.EventSource(OC.filePath('files','ajax','newfile.php'),{dir:$('#dir').val(),source:name,filename:localName});
eventSource.listen('progress',function(progress){ eventSource.listen('progress',function(progress){
//IE < 10 does not fire the necessary events for the progress bar. //IE < 10 does not fire the necessary events for the progress bar.
if($('html.lte9').length > 0) { if($('html.lte9').length === 0) {
} else {
$('#uploadprogressbar').progressbar('value',progress); $('#uploadprogressbar').progressbar('value',progress);
} }
}); });

View File

@ -198,7 +198,7 @@ FileActions.register('all', 'Rename', OC.PERMISSION_UPDATE, function () {
FileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename) { FileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename) {
var dir = $('#dir').val() var dir = $('#dir').val();
if (dir !== '/') { if (dir !== '/') {
dir = dir + '/'; dir = dir + '/';
} }

View File

@ -131,7 +131,9 @@ var Files = Files || {};
return; return;
} }
var preventDefault = false; var preventDefault = false;
if ($.inArray(event.keyCode, keys) === -1) keys.push(event.keyCode); if ($.inArray(event.keyCode, keys) === -1) {
keys.push(event.keyCode);
}
if ( 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)) { $.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 preventDefault = true; //new file/folder prevent browser from responding

View File

@ -31,19 +31,19 @@ $(document).ready(function() {
} }
} }
FileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function(filename) { FileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function(filename) {
var tr = $('tr').filterAttr('data-file', filename) var tr = $('tr').filterAttr('data-file', filename);
if (tr.length > 0) { if (tr.length > 0) {
window.location = $(tr).find('a.name').attr('href'); window.location = $(tr).find('a.name').attr('href');
} }
}); });
FileActions.register('file', 'Download', OC.PERMISSION_READ, '', function(filename) { FileActions.register('file', 'Download', OC.PERMISSION_READ, '', function(filename) {
var tr = $('tr').filterAttr('data-file', filename) var tr = $('tr').filterAttr('data-file', filename);
if (tr.length > 0) { if (tr.length > 0) {
window.location = $(tr).find('a.name').attr('href'); window.location = $(tr).find('a.name').attr('href');
} }
}); });
FileActions.register('dir', 'Download', OC.PERMISSION_READ, '', function(filename) { FileActions.register('dir', 'Download', OC.PERMISSION_READ, '', function(filename) {
var tr = $('tr').filterAttr('data-file', filename) var tr = $('tr').filterAttr('data-file', filename);
if (tr.length > 0) { if (tr.length > 0) {
window.location = $(tr).find('a.name').attr('href')+'&download'; window.location = $(tr).find('a.name').attr('href')+'&download';
} }

View File

@ -124,19 +124,19 @@ function createVersionsDropdown(filename, files) {
} }
function addVersion( revision ) { function addVersion( revision ) {
title = formatDate(revision.version*1000); var title = formatDate(revision.version*1000);
name ='<span class="versionDate" title="' + title + '">' + revision.humanReadableTimestamp + '</span>'; var name ='<span class="versionDate" title="' + title + '">' + revision.humanReadableTimestamp + '</span>';
path = OC.filePath('files_versions', '', 'download.php'); var path = OC.filePath('files_versions', '', 'download.php');
download ='<a href="' + path + "?file=" + files + '&revision=' + revision.version + '">'; var download ='<a href="' + path + "?file=" + files + '&revision=' + revision.version + '">';
download+='<img'; download+='<img';
download+=' src="' + OC.imagePath('core', 'actions/download') + '"'; download+=' src="' + OC.imagePath('core', 'actions/download') + '"';
download+=' name="downloadVersion" />'; download+=' name="downloadVersion" />';
download+=name; download+=name;
download+='</a>'; download+='</a>';
revert='<span class="revertVersion"'; var revert='<span class="revertVersion"';
revert+=' id="' + revision.version + '"'; revert+=' id="' + revision.version + '"';
revert+=' value="' + files + '">'; revert+=' value="' + files + '">';
revert+='<img'; revert+='<img';

View File

@ -120,7 +120,7 @@ var LdapConfiguration = {
} }
); );
} }
} };
$(document).ready(function() { $(document).ready(function() {
$('#ldapAdvancedAccordion').accordion({ heightStyle: 'content', animate: 'easeInOutCirc'}); $('#ldapAdvancedAccordion').accordion({ heightStyle: 'content', animate: 'easeInOutCirc'});

View File

@ -24,7 +24,7 @@ if (typeof Object.keys !== 'function') {
} }
} }
return k; return k;
} };
} }
/** /**

View File

@ -9,7 +9,7 @@ OC.AppConfig={
getCall:function(action,data,callback){ getCall:function(action,data,callback){
data.action=action; data.action=action;
$.getJSON(OC.AppConfig.url,data,function(result){ $.getJSON(OC.AppConfig.url,data,function(result){
if(result.status='success'){ if(result.status==='success'){
if(callback){ if(callback){
callback(result.data); callback(result.data);
} }
@ -19,7 +19,7 @@ OC.AppConfig={
postCall:function(action,data,callback){ postCall:function(action,data,callback){
data.action=action; data.action=action;
$.post(OC.AppConfig.url,data,function(result){ $.post(OC.AppConfig.url,data,function(result){
if(result.status='success'){ if(result.status==='success'){
if(callback){ if(callback){
callback(result.data); callback(result.data);
} }

View File

@ -13,7 +13,7 @@
this.originalCss = { this.originalCss = {
display: this.element[0].style.display, display: this.element[0].style.display,
width: this.element[0].style.width, width: this.element[0].style.width,
height: this.element[0].style.height, height: this.element[0].style.height
}; };
this.originalTitle = this.element.attr('title'); this.originalTitle = this.element.attr('title');
@ -152,7 +152,7 @@
content_height -= this.$buttonrow.outerHeight(true); content_height -= this.$buttonrow.outerHeight(true);
} }
this.parent = this.$dialog.parent().length > 0 ? this.$dialog.parent() : $('body'); this.parent = this.$dialog.parent().length > 0 ? this.$dialog.parent() : $('body');
content_height = Math.min(content_height, this.parent.height()-20) content_height = Math.min(content_height, this.parent.height()-20);
this.element.css({ this.element.css({
height: content_height + 'px', height: content_height + 'px',
width: this.$dialog.innerWidth()-20 + 'px' width: this.$dialog.innerWidth()-20 + 'px'
@ -187,7 +187,7 @@
} }
}, },
widget: function() { widget: function() {
return this.$dialog return this.$dialog;
}, },
close: function() { close: function() {
this._destroyOverlay(); this._destroyOverlay();
@ -200,10 +200,10 @@
}, },
destroy: function() { destroy: function() {
if(this.$title) { if(this.$title) {
this.$title.remove() this.$title.remove();
} }
if(this.$buttonrow) { if(this.$buttonrow) {
this.$buttonrow.remove() this.$buttonrow.remove();
} }
if(this.originalTitle) { if(this.originalTitle) {

View File

@ -11,11 +11,11 @@ ListView.generateTable=function(collumns){
html+='<thead>'; html+='<thead>';
html+='</head>'; html+='</head>';
html+='<tbody>'; html+='<tbody>';
html+'<tr class="template">'; html+='<tr class="template">';
$.each(collumns,function(index,collumn){ $.each(collumns,function(index,collumn){
html+='<th class="'+collumn.toLower()+'"</th>'; html+='<th class="'+collumn.toLower()+'"</th>';
}); });
html+'</tr>'; html+='</tr>';
html+='</tbody>'; html+='</tbody>';
html='</table>'; html='</table>';
return $(html); return $(html);

View File

@ -25,7 +25,7 @@
'labels':[], 'labels':[],
'oncheck':false, 'oncheck':false,
'onuncheck':false, 'onuncheck':false,
'minWidth': 'default;', 'minWidth': 'default;'
}; };
$(this).attr('data-msid', multiSelectId); $(this).attr('data-msid', multiSelectId);
$.extend(settings,options); $.extend(settings,options);
@ -200,7 +200,7 @@
return false; return false;
} }
var li=$(this).parent(); var li=$(this).parent();
var val = $(this).val() var val = $(this).val();
var select=button.parent().next(); var select=button.parent().next();
if(typeof settings.createCallback === 'function') { if(typeof settings.createCallback === 'function') {
var response = settings.createCallback(select, val); var response = settings.createCallback(select, val);

View File

@ -79,9 +79,15 @@ var OCdialogs = {
title: title title: title
}).data('path', ''); }).data('path', '');
if (modal === undefined) { modal = false }; if (modal === undefined) {
if (multiselect === undefined) { multiselect = false }; modal = false;
if (mimetype_filter === undefined) { mimetype_filter = '' }; }
if (multiselect === undefined) {
multiselect = false;
}
if (mimetype_filter === undefined) {
mimetype_filter = '';
}
$('body').append(self.$filePicker); $('body').append(self.$filePicker);
@ -106,7 +112,7 @@ var OCdialogs = {
datapath.push(self.$filePicker.data('path') + '/' + $(element).text()); datapath.push(self.$filePicker.data('path') + '/' + $(element).text());
}); });
} else { } else {
var datapath = self.$filePicker.data('path'); datapath = self.$filePicker.data('path');
datapath += '/' + self.$filelist.find('.filepicker_element_selected .filename').text(); datapath += '/' + self.$filelist.find('.filepicker_element_selected .filename').text();
} }
callback(datapath); callback(datapath);
@ -151,7 +157,9 @@ var OCdialogs = {
message: content, message: content,
type: dialog_type type: dialog_type
}); });
if (modal === undefined) { modal = false }; if (modal === undefined) {
modal = false;
}
$('body').append($dlg); $('body').append($dlg);
var buttonlist = []; var buttonlist = [];
switch (buttons) { switch (buttons) {
@ -159,7 +167,9 @@ var OCdialogs = {
buttonlist = [{ buttonlist = [{
text: t('core', 'Yes'), text: t('core', 'Yes'),
click: function(){ click: function(){
if (callback !== undefined) { callback(true) }; if (callback !== undefined) {
callback(true);
}
$(dialog_id).ocdialog('close'); $(dialog_id).ocdialog('close');
}, },
defaultButton: true defaultButton: true
@ -167,7 +177,9 @@ var OCdialogs = {
{ {
text: t('core', 'No'), text: t('core', 'No'),
click: function(){ click: function(){
if (callback !== undefined) { callback(false) }; if (callback !== undefined) {
callback(false);
}
$(dialog_id).ocdialog('close'); $(dialog_id).ocdialog('close');
} }
}]; }];
@ -175,7 +187,9 @@ var OCdialogs = {
case OCdialogs.OK_BUTTON: case OCdialogs.OK_BUTTON:
var functionToCall = function() { var functionToCall = function() {
$(dialog_id).ocdialog('close'); $(dialog_id).ocdialog('close');
if(callback !== undefined) { callback() }; if(callback !== undefined) {
callback();
}
}; };
buttonlist[0] = { buttonlist[0] = {
text: t('core', 'Ok'), text: t('core', 'Ok'),
@ -183,7 +197,7 @@ var OCdialogs = {
defaultButton: true defaultButton: true
}; };
break; break;
}; }
$(dialog_id).ocdialog({ $(dialog_id).ocdialog({
closeOnEscape: true, closeOnEscape: true,
@ -265,7 +279,7 @@ var OCdialogs = {
var sorted = dirs.concat(others); var sorted = dirs.concat(others);
$.each(sorted, function(idx, entry) { $.each(sorted, function(idx, entry) {
$li = self.$listTmpl.octemplate({ var $li = self.$listTmpl.octemplate({
type: entry.type, type: entry.type,
dir: dir, dir: dir,
filename: entry.name, filename: entry.name,
@ -283,13 +297,13 @@ var OCdialogs = {
*/ */
_fillSlug: function() { _fillSlug: function() {
this.$dirTree.empty(); this.$dirTree.empty();
var self = this var self = this;
var path = this.$filePicker.data('path'); var path = this.$filePicker.data('path');
var $template = $('<span data-dir="{dir}">{name}</span>'); var $template = $('<span data-dir="{dir}">{name}</span>');
if(path) { if(path) {
var paths = path.split('/'); var paths = path.split('/');
$.each(paths, function(index, dir) { $.each(paths, function(index, dir) {
var dir = paths.pop(); dir = paths.pop();
if(dir === '') { if(dir === '') {
return false; return false;
} }
@ -323,7 +337,7 @@ var OCdialogs = {
$element.toggleClass('filepicker_element_selected'); $element.toggleClass('filepicker_element_selected');
return; return;
} else if ( $element.data('type') === 'dir' ) { } else if ( $element.data('type') === 'dir' ) {
this._fillFilePicker(this.$filePicker.data('path') + '/' + $element.data('entryname')) this._fillFilePicker(this.$filePicker.data('path') + '/' + $element.data('entryname'));
} }
} }
}; };

View File

@ -23,7 +23,7 @@ var OCCategories= {
d.css('cursor', 'wait').find('input,button:not(#category_addbutton)') d.css('cursor', 'wait').find('input,button:not(#category_addbutton)')
.prop('disabled', true).css('cursor', 'wait'); .prop('disabled', true).css('cursor', 'wait');
} }
} };
var dlg = $('#edit_categories_dialog').dialog({ var dlg = $('#edit_categories_dialog').dialog({
modal: true, modal: true,
height: 350, minHeight:200, width: 250, minWidth: 200, height: 350, minHeight:200, width: 250, minWidth: 200,

View File

@ -1,4 +1,4 @@
OC.router_base_url = OC.webroot + '/index.php', OC.router_base_url = OC.webroot + '/index.php';
OC.Router = { OC.Router = {
// register your ajax requests to load after the loading of the routes // register your ajax requests to load after the loading of the routes
// has finished. otherwise you face problems with race conditions // has finished. otherwise you face problems with race conditions

View File

@ -103,9 +103,9 @@ OC.Share={
var checkReshare = true; var checkReshare = true;
if (typeof OC.Share.statuses[itemSource] === 'undefined') { if (typeof OC.Share.statuses[itemSource] === 'undefined') {
// NOTE: Check does not always work and misses some shares, fix later // NOTE: Check does not always work and misses some shares, fix later
checkShares = true; var checkShares = true;
} else { } else {
checkShares = true; var checkShares = true;
} }
$.ajax({type: 'GET', url: OC.filePath('core', 'ajax', 'share.php'), data: { fetch: 'getItem', itemType: itemType, itemSource: itemSource, checkReshare: checkReshare, checkShares: checkShares }, async: false, success: function(result) { $.ajax({type: 'GET', url: OC.filePath('core', 'ajax', 'share.php'), data: { fetch: 'getItem', itemType: itemType, itemSource: itemSource, checkReshare: checkReshare, checkShares: checkShares }, async: false, success: function(result) {
if (result && result.status === 'success') { if (result && result.status === 'success') {
@ -228,23 +228,23 @@ OC.Share={
}); });
} }
$('#shareWith').autocomplete({minLength: 1, source: function(search, response) { $('#shareWith').autocomplete({minLength: 1, source: function(search, response) {
// if (cache[search.term]) { // if (cache[search.term]) {
// response(cache[search.term]); // response(cache[search.term]);
// } else { // } else {
$.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getShareWith', search: search.term, itemShares: OC.Share.itemShares }, function(result) { $.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getShareWith', search: search.term, itemShares: OC.Share.itemShares }, function(result) {
if (result.status == 'success' && result.data.length > 0) { if (result.status == 'success' && result.data.length > 0) {
response(result.data); response(result.data);
} else { } else {
// Suggest sharing via email if valid email address // Suggest sharing via email if valid email address
// var pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i); // var pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i);
// if (pattern.test(search.term)) { // if (pattern.test(search.term)) {
// response([{label: t('core', 'Share via email:')+' '+search.term, value: {shareType: OC.Share.SHARE_TYPE_EMAIL, shareWith: search.term}}]); // response([{label: t('core', 'Share via email:')+' '+search.term, value: {shareType: OC.Share.SHARE_TYPE_EMAIL, shareWith: search.term}}]);
// } else { // } else {
response([t('core', 'No people found')]); response([t('core', 'No people found')]);
// } // }
} }
}); });
// } // }
}, },
focus: function(event, focused) { focus: function(event, focused) {
event.preventDefault(); event.preventDefault();

View File

@ -54,7 +54,7 @@ OC.Settings.Apps = OC.Settings.Apps || {
enableApp:function(appid, active, element) { enableApp:function(appid, active, element) {
console.log('enableApp:', appid, active, element); console.log('enableApp:', appid, active, element);
var appitem=$('#leftcontent li[data-id="'+appid+'"]'); var appitem=$('#leftcontent li[data-id="'+appid+'"]');
appData = appitem.data('app'); var appData = appitem.data('app');
appData.active = !active; appData.active = !active;
appitem.data('app', appData); appitem.data('app', appData);
element.val(t('settings','Please wait....')); element.val(t('settings','Please wait....'));

View File

@ -35,8 +35,9 @@ OC.Log={
$('#moreLog').show(); $('#moreLog').show();
// remove all non-remaining items // remove all non-remaining items
$('#log tr').slice(OC.Log.loaded).remove(); $('#log tr').slice(OC.Log.loaded).remove();
if(OC.Log.loaded <= 3) if(OC.Log.loaded <= 3) {
$('#lessLog').hide(); $('#lessLog').hide();
}
}, },
addEntries:function(entries){ addEntries:function(entries){
for(var i=0;i<entries.length;i++){ for(var i=0;i<entries.length;i++){

View File

@ -8,7 +8,7 @@
* Post the email address change to the server. * Post the email address change to the server.
*/ */
function changeEmailAddress(){ function changeEmailAddress(){
emailInfo = $('#email'); var emailInfo = $('#email');
if (emailInfo.val() === emailInfo.defaultValue){ if (emailInfo.val() === emailInfo.defaultValue){
return; return;
} }

View File

@ -171,7 +171,9 @@ var UserList = {
var c = Number(aa[x]), d = Number(bb[x]); var c = Number(aa[x]), d = Number(bb[x]);
if (c === aa[x] && d === bb[x]) { if (c === aa[x] && d === bb[x]) {
return c - d; return c - d;
} else return (aa[x] > bb[x]) ? 1 : -1; } else {
return (aa[x] > bb[x]) ? 1 : -1;
}
} }
} }
return aa.length - bb.length; return aa.length - bb.length;
@ -268,7 +270,7 @@ var UserList = {
if ($(element).find('option[value="' + group + '"]').length === 0 && select.data('msid') !== $(element).data('msid')) { if ($(element).find('option[value="' + group + '"]').length === 0 && select.data('msid') !== $(element).data('msid')) {
$(element).append('<option value="' + escapeHTML(group) + '">' + escapeHTML(group) + '</option>'); $(element).append('<option value="' + escapeHTML(group) + '">' + escapeHTML(group) + '</option>');
} }
}) });
}; };
var label; var label;
if (isadmin) { if (isadmin) {
@ -310,7 +312,7 @@ var UserList = {
if ($(element).find('option[value="' + group + '"]').length === 0) { if ($(element).find('option[value="' + group + '"]').length === 0) {
$(element).append('<option value="' + escapeHTML(group) + '">' + escapeHTML(group) + '</option>'); $(element).append('<option value="' + escapeHTML(group) + '">' + escapeHTML(group) + '</option>');
} }
}) });
}; };
element.multiSelect({ element.multiSelect({
createCallback: addSubAdmin, createCallback: addSubAdmin,
@ -475,7 +477,7 @@ $(document).ready(function () {
} }
OC.Notification.hide(); OC.Notification.hide();
}); });
UserList.useUndo = ('onbeforeunload' in window) UserList.useUndo = ('onbeforeunload' in window);
$(window).bind('beforeunload', function () { $(window).bind('beforeunload', function () {
UserList.finishDelete(null); UserList.finishDelete(null);
}); });