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
45 changes: 45 additions & 0 deletions event.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Возвращает объект Event
*
* @param {Object} requiredParams Обязательные параметры
Copy link
Member

Choose a reason for hiding this comment

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

Судя по этой схеме JSDoc могут быть любые хэши. Конкретизируй если ты ожидаешь какие-то определенные параметры.

* @param {Object} optionalParams Дополнительные параметры
*
* @example
* var required = {
* start: new Date('10-26-2012 02:12'),
* end: new Date('10-27-2012'),
* name: 'Поездка на озеро Тургояк',
* isNotify: 'true',
* notify: new Date('10-26-2012')
* };
* var optional = {
* description: 'Отличная возможность отдохнуть и насладиться природой',
* place: 'Озеро Тургояк',
* importance: 'h',
* url: 'http://www.turgoyak.com/'
* };
* getEvent(required, optional);
*
* @return {Object}
*/
function getEvent(required, optional) {
Copy link
Member

Choose a reason for hiding this comment

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

А ты через JSLint не прогонял?

"use strict";
if (requiredParams.start > requiredParams.end) {
throw new Error("Время начала мероприятия не может быть позже времени окончания!");
}
var imp = optionalParams.importance;
if (!(imp == 'h' || imp == 'l' || imp == 'm')) {
Copy link
Member

Choose a reason for hiding this comment

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

Лучше так и назвать importance imp === http://img361.imageshack.us/img361/996/heroesvidcardsinferno01imp4lf.jpg

imp = 'm';
}
return {
start: new Date(+requiredParams.start),
end: new Date(+requiredParams.end),
name: requiredParams.name || "Событие",
isNotify: !!requiredParams.isNotify || false,
notify: +requiredParams.notify,
description: optionalParams.description || "",
place: optionalParams.place || "",
importance: imp,
url: optionalParams.url
};
}