From f4ea2a29b75df97e52f38a56eaf2a23341806161 Mon Sep 17 00:00:00 2001 From: Vladimir Gankin Date: Tue, 17 Dec 2024 18:42:31 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F?= =?UTF-8?q?=D0=B5=D1=82=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8E=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=B2=D1=85=D0=BE=D0=B6=D0=B4=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=B2=D1=81=D1=82=D1=80=D0=B5=D1=87=D0=B8=20=D0=B2=20=D1=80?= =?UTF-8?q?=D0=B0=D0=BC=D0=BA=D0=B8=20=D1=80=D0=B0=D0=B1=D0=BE=D1=87=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=20=D0=B4=D0=BD=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 3 ++- js/data-generator.js | 6 +++--- js/functions.js | 14 +++++++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 360460d..b371ea1 100644 --- a/index.html +++ b/index.html @@ -234,6 +234,7 @@

Не удалось загрузить данны - + + diff --git a/js/data-generator.js b/js/data-generator.js index c979826..63a881c 100644 --- a/js/data-generator.js +++ b/js/data-generator.js @@ -44,7 +44,7 @@ const createIdGenerator = function(min, max) { let lastGeneratedId = getRandomInteger(min, max); if(previousValues.length >= (max - min + 1)) { - console.log('Закончились уникальные идентификаторы'); + console.error('Закончились уникальные идентификаторы'); return null; } @@ -61,7 +61,7 @@ const generateCommentId = createIdGenerator(1, PHOTO_OBJECTS_AMOUNT * MAX_COMMEN const createCommentObject = () => ({ id: generateCommentId(), - avatar: 'img/avatar-' + getRandomInteger(1, 6) + '.svg', + avatar: `img/avatar-${getRandomInteger(1, 6)}.svg`, message: getRandomArrayElement(MESSAGES), name: getRandomArrayElement(NAMES), }); @@ -69,7 +69,7 @@ const createCommentObject = () => ({ const createPhotoObject = (_, index) => ({ id: index, - url: 'photos/' + index++ + '.jpg', + url: `photos/${index++}.jpg`, description: getRandomArrayElement(DESCRIPTIONS), likes: getRandomInteger(MIN_LIKES, MAX_LIKES), comments: Array.from({length: getRandomInteger(MIN_COMMENTS, MAX_COMMENTS)}, createCommentObject) diff --git a/js/functions.js b/js/functions.js index 47f6aad..68e9d34 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1,6 +1,4 @@ -function isLesserOrEqual(string, maxLength) { - return string.length <= maxLength; -} +const isLesserOrEqual = (string, maxLength) => string.length <= maxLength; function isPalindrome(string) { const normalizedString = string.replaceAll(' ', '').toLowerCase(); @@ -22,3 +20,13 @@ function toPositiveNumber(string) { return parseInt(result, 10); } +const timeToMinutesNumber = (arr) => Number(arr[0]) * 60 + Number(arr[1]); + + +function isMeetingInWorkingHours(timeStart, timeEnd, meetingTime, meetingDuration) { + const timeStartNormalized = timeToMinutesNumber(timeStart.split(':')); + const timeEndNormalized = timeToMinutesNumber(timeEnd.split(':')); + const meetingTimeNormalized = timeToMinutesNumber(meetingTime.split(':')); + + return (meetingTimeNormalized >= timeStartNormalized && (meetingTimeNormalized + meetingDuration) <= timeEndNormalized); +}