Skip to content

It is my homework #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
};
}