(js) Fix possible errors (help from jsjint)

This commit is contained in:
Francis Lachapelle
2015-07-24 16:14:53 -04:00
parent e064dc4a46
commit dc9a0896e5
27 changed files with 166 additions and 157 deletions

View File

@@ -61,8 +61,8 @@
list = this.$calendars;
sibling = _.find(list, function(o) {
return (o.id != 'personal'
&& o.name.localeCompare(calendar.name) === 1);
return (o.id != 'personal' &&
o.name.localeCompare(calendar.name) === 1);
});
i = sibling ? _.indexOf(_.pluck(list, 'id'), sibling.id) : 1;
list.splice(i, 0, calendar);
@@ -103,11 +103,11 @@
Calendar.$get = function(id) {
var calendar;
calendar = _.find(Calendar.$calendars, function(o) { return o.id == id });
calendar = _.find(Calendar.$calendars, function(o) { return o.id == id; });
if (!calendar)
calendar = _.find(Calendar.$subscriptions, function(o) { return o.id == id });
calendar = _.find(Calendar.$subscriptions, function(o) { return o.id == id; });
if (!calendar)
calendar = _.find(Calendar.$webcalendars, function(o) { return o.id == id });
calendar = _.find(Calendar.$webcalendars, function(o) { return o.id == id; });
return calendar;
};

View File

@@ -25,9 +25,9 @@
$scope.$watch(
function() {
return _.union(
_.map(Calendar.$calendars, function(o) { return _.pick(o, ['id', 'active', 'color']) }),
_.map(Calendar.$subscriptions, function(o) { return _.pick(o, ['id', 'active', 'color']) }),
_.map(Calendar.$webcalendars, function(o) { return _.pick(o, ['id', 'active', 'color']) })
_.map(Calendar.$calendars, function(o) { return _.pick(o, ['id', 'active', 'color']); }),
_.map(Calendar.$subscriptions, function(o) { return _.pick(o, ['id', 'active', 'color']); }),
_.map(Calendar.$webcalendars, function(o) { return _.pick(o, ['id', 'active', 'color']); })
);
},
function(newList, oldList) {
@@ -213,7 +213,7 @@
if (user.uid == vm.selectedUser.uid)
vm.selectedUser = null;
}, function(data, status) {
Dialog.alert(l('Warning'), l('An error occured please try again.'))
Dialog.alert(l('Warning'), l('An error occured please try again.'));
});
}
@@ -234,9 +234,9 @@
vm.selectedUser = user;
vm.selectedUser.$rights();
}
};
};
};
}
}
}
// Callback of sgSubscribe directive
function subscribeToFolder(calendarData) {

View File

@@ -282,8 +282,8 @@
var type = (_this.type == 'appointment')? 'Events' : 'Tasks';
// Set default values from user's defaults
_this.classification = _this.classification
|| Component.$Preferences.defaults['SOGoCalendar' + type + 'DefaultClassification'].toLowerCase();
_this.classification = _this.classification ||
Component.$Preferences.defaults['SOGoCalendar' + type + 'DefaultClassification'].toLowerCase();
});
if (this.startDate)
@@ -665,8 +665,8 @@
// Update recurrence definition depending on selections
if (this.$hasCustomRepeat) {
if (this.repeat.frequency == 'monthly' && this.repeat.month.type && this.repeat.month.type == 'byday'
|| this.repeat.frequency == 'yearly' && this.repeat.year.byday) {
if (this.repeat.frequency == 'monthly' && this.repeat.month.type && this.repeat.month.type == 'byday' ||
this.repeat.frequency == 'yearly' && this.repeat.year.byday) {
// BYDAY mask for a monthly or yearly recurrence
delete component.repeat.monthdays;
component.repeat.days = [{ day: this.repeat.month.day, occurrence: this.repeat.month.occurrence.toString() }];

View File

@@ -97,7 +97,7 @@
function addAttachUrl() {
var i = vm.component.addAttachUrl('');
focus('attachUrl_' + i);
};
}
function toggleRecurrenceEditor() {
vm.showRecurrenceEditor = !vm.showRecurrenceEditor;
@@ -113,16 +113,13 @@
var index, indexResult, card;
if ($query) {
AddressBook.$filterAll($query).then(function(results) {
var compareIds = function(result) {
return this.id == result.id;
};
// Remove cards that no longer match the search query
for (index = vm.cardResults.length - 1; index >= 0; index--) {
card = vm.cardResults[index];
indexResult = _.findIndex(results, function(result) {
return _.find(card.emails, function(data) {
return _.find(result.emails, function(resultData) {
return resultData.value == data.value;
});
});
});
indexResult = _.findIndex(results, compareIds, card);
if (indexResult >= 0)
results.splice(indexResult, 1);
else