Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions event.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Возвращает объект Event
*
* @param {Number|Date} start Начало события
* @param {Number|Date} end Конец события
* @param {String} [name="Событие"] Имя события
* @param {String} [description="Описание"] Описание события
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поехал код - проверь на табы и пробелы.

* @param {Number} [number=1] Рейтинг события
* @param {Boolean} [alarm=false] Нужно ли напоминание
*
* @example
* Event(new Date('2011-10-10T14:48:00'),
* new Date('2011-10-10T15:48:00'),
* "Совещание")
*
* @return {Object}
*/
function Event(start, end, name, description, rating, alarm) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Слишком много аргументов - подумай как уменьшить их число

if (typeof(alarm) === "boolean") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typeof - оператор, а не функция - от скобок смысла нет

var new_alarm = alarm;
} else {
var new_alarm = false;
}
if (typeof(rating) === "number") {
if (rating > 5 || rating < 1) {
var new_rating = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше var new_rating = (rating > 5 || rating < 1) ? 1 : rating; чем 2 раза var new_rating

} else {
var new_rating = rating;
}
}
return {
"start": +start,
"end": +end,
"name": name || "Событие",
"description": description || "Описание",
"rating": new_rating,
"alarm": new_alarm
};
}