From 7358a0148a944f20898eddfcee59045829269823 Mon Sep 17 00:00:00 2001 From: Alexey Sotov Date: Sat, 27 Oct 2012 02:00:41 +0600 Subject: [PATCH 1/3] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=20?= =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB,=20=D0=BE=D0=BF=D1=80=D0=B5=D0=B4?= =?UTF-8?q?=D0=B5=D0=BB=D0=B5=D0=BD=20=D0=BD=D0=B0=D0=B1=D0=BE=D1=80=20?= =?UTF-8?q?=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D0=BE=D0=B2,?= =?UTF-8?q?=20=D0=BD=D0=B0=D1=87=D0=B0=D1=82=D0=B0=20=D1=84=D1=83=D0=BD?= =?UTF-8?q?=D0=BA=D1=86=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- event.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 event.js diff --git a/event.js b/event.js new file mode 100644 index 0000000..08a2c3c --- /dev/null +++ b/event.js @@ -0,0 +1,26 @@ +var requiredParams = { + start: new Date('27-10-2012T09:00:00'), + end: new Date('28-10-2012T22:00:00'), + name: 'Поездка на озеро Тургояк', + isNotify: 'true', + notify: new Date('26-10-2012T20:00:00) + }; +var optionalParams = { + description: 'Отличная возможность отдохнуть и насладиться природой', + place: 'Озеро Тургояк', + importance: 'h', + url: 'http://www.turgoyak.com/' + }; +function addEvent(requiredParams, optionalParams) { + "use strict"; + if (typeof requiredParams.start === 'Date') { + if (typeof requiredParams.end === 'Date') { + return { + start: requiredParams.start, + end: requiredParams.end, + name: requiredParams.name || "Событие", + isNotify: isNotify || "false" + + } + } + \ No newline at end of file From da04e65d0341f79c885273253882207d3fb16289 Mon Sep 17 00:00:00 2001 From: Alexey Sotov Date: Mon, 29 Oct 2012 01:26:50 +0600 Subject: [PATCH 2/3] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BF=D0=B8=D1=81?= =?UTF-8?q?=D0=B0=D0=BD=D1=8B=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D0=B5=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=BC=D0=B5=D1=80=D0=BE=D0=B2,=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B0=20=D1=84=D1=83=D0=BD?= =?UTF-8?q?=D0=BA=D1=86=D0=B8=D1=8F=20addEvent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- event.js | 54 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/event.js b/event.js index 08a2c3c..f905b4c 100644 --- a/event.js +++ b/event.js @@ -1,26 +1,34 @@ var requiredParams = { - start: new Date('27-10-2012T09:00:00'), - end: new Date('28-10-2012T22:00:00'), - name: 'Поездка на озеро Тургояк', - isNotify: 'true', - notify: new Date('26-10-2012T20:00:00) - }; + start: new Date('10-26-2012 02:12'), + end: new Date('10-27-2012'), + name: 'Поездка на озеро Тургояк', + isNotify: 'true', + notify: new Date('10-26-2012') + }; var optionalParams = { - description: 'Отличная возможность отдохнуть и насладиться природой', - place: 'Озеро Тургояк', - importance: 'h', - url: 'http://www.turgoyak.com/' - }; + description: 'Отличная возможность отдохнуть и насладиться природой', + place: 'Озеро Тургояк', + importance: 'h', + url: 'http://www.turgoyak.com/' + }; function addEvent(requiredParams, optionalParams) { - "use strict"; - if (typeof requiredParams.start === 'Date') { - if (typeof requiredParams.end === 'Date') { - return { - start: requiredParams.start, - end: requiredParams.end, - name: requiredParams.name || "Событие", - isNotify: isNotify || "false" - - } - } - \ No newline at end of file +"use strict"; +if (requiredParams.start > requiredParams.end) { + throw new Error("Время начала мероприятия не может быть позже времени окончания!"); + } +var imp = optionalParams.importance; +if (!(imp == 'h' || imp == 'l' || imp == 'm')) { + 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 + }; +} \ No newline at end of file From eb90c0d2a11a3d87acf98e97c1dbeb2530656cdc Mon Sep 17 00:00:00 2001 From: Alexey Sotov Date: Mon, 29 Oct 2012 01:51:17 +0600 Subject: [PATCH 3/3] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=BE=D0=BA=D1=83=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- event.js | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/event.js b/event.js index f905b4c..f02a072 100644 --- a/event.js +++ b/event.js @@ -1,17 +1,28 @@ -var requiredParams = { - start: new Date('10-26-2012 02:12'), - end: new Date('10-27-2012'), - name: 'Поездка на озеро Тургояк', - isNotify: 'true', - notify: new Date('10-26-2012') - }; -var optionalParams = { - description: 'Отличная возможность отдохнуть и насладиться природой', - place: 'Озеро Тургояк', - importance: 'h', - url: 'http://www.turgoyak.com/' - }; -function addEvent(requiredParams, optionalParams) { +/** + * Возвращает объект Event + * + * @param {Object} requiredParams Обязательные параметры + * @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) { "use strict"; if (requiredParams.start > requiredParams.end) { throw new Error("Время начала мероприятия не может быть позже времени окончания!");