From a424e0d6f629b78d66d0ca0f89890a08e91ef7e3 Mon Sep 17 00:00:00 2001 From: Ilya Kharlamov Date: Thu, 19 Dec 2024 11:11:20 +0300 Subject: [PATCH 1/5] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F?= =?UTF-8?q?=D0=B5=D1=82=20=D1=80=D0=B5=D1=88=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=B4=D0=B0=D1=87=D0=B8=20"=D0=9E=D1=82=D1=80?= =?UTF-8?q?=D0=B8=D1=81=D1=83=D0=B9=20=D0=BC=D0=B5=D0=BD=D1=8F=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D0=BD=D0=BE=D1=81=D1=82=D1=8C=D1=8E"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 3 ++- js/main.js | 6 ++++-- js/thumbnails.js | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 js/thumbnails.js diff --git a/index.html b/index.html index 5504799..b1c5781 100644 --- a/index.html +++ b/index.html @@ -250,6 +250,7 @@

Не удалось загрузить данны - + + diff --git a/js/main.js b/js/main.js index 4886358..0b7120f 100644 --- a/js/main.js +++ b/js/main.js @@ -1,6 +1,8 @@ import {getRandomPhotoObjects} from './photos.js'; +import {showThumbnail} from './thumbnails.js'; const OBJECTS_COUNT = 26; -const generatedObjects = getRandomPhotoObjects(OBJECTS_COUNT); -console.log(generatedObjects); +const randomPhotoObjects = getRandomPhotoObjects(OBJECTS_COUNT); + +showThumbnail(randomPhotoObjects); diff --git a/js/thumbnails.js b/js/thumbnails.js new file mode 100644 index 0000000..5fe2a0a --- /dev/null +++ b/js/thumbnails.js @@ -0,0 +1,21 @@ +const thumbnailTemplate = document.querySelector('#picture').content.querySelector('.picture'); +const picturesContainer = document.querySelector('.pictures'); + +function showThumbnail(randomPhotoObjects) { + const fragment = document.createDocumentFragment(); + + randomPhotoObjects.forEach((object) => { + const newThumbnail = thumbnailTemplate.cloneNode(true); + + newThumbnail.querySelector('img').src = object.url; + newThumbnail.querySelector('img').alt = object.description; + newThumbnail.querySelector('.picture__comments').textContent = object.comments.length; + newThumbnail.querySelector('.picture__likes').textContent = object.likes; + + fragment.appendChild(newThumbnail); + }); + + picturesContainer.appendChild(fragment); +} + +export {showThumbnail}; From db878794a4b0037d13b4187dd1a5c703a2a5addf Mon Sep 17 00:00:00 2001 From: Ilya Kharlamov Date: Thu, 19 Dec 2024 11:14:54 +0300 Subject: [PATCH 2/5] =?UTF-8?q?=D0=9F=D1=80=D1=8F=D1=87=D0=B5=D1=82=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20"=D0=A4=D1=83?= =?UTF-8?q?=D0=BD=D0=BA=D1=86=D0=B8=D0=B8=20=D0=B2=D0=BE=D0=B7=D0=B2=D1=80?= =?UTF-8?q?=D0=B0=D1=89=D0=B0=D1=8E=D1=82=D1=81=D1=8F"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/functions.js | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/js/functions.js b/js/functions.js index 16c4846..d83501f 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1,24 +1,24 @@ //5.16. Функции возвращаются -function checkMeetingTimeframe (startWorkingDay, endWorkingDay, beginningMeeting, durationMeeting) { - const startWorkingDayInMinutes = convertToMinutes(startWorkingDay); - const endWorkingDayInMinutes = convertToMinutes(endWorkingDay); - const beginningMeetingInMinutes = convertToMinutes(beginningMeeting); - - const isMeetingAfterWorkStart = startWorkingDayInMinutes <= beginningMeetingInMinutes; - const isMeetingBeforeWorkEnd = (beginningMeetingInMinutes + durationMeeting) <= endWorkingDayInMinutes; - - return isMeetingAfterWorkStart && isMeetingBeforeWorkEnd; -} - -function convertToMinutes(inputValue) { - const [hours, minutes] = inputValue.split(':'); - - return (Number(hours) * 60) + Number(minutes); -} - -console.log(checkMeetingTimeframe('08:00', '17:30', '14:00', 90)); -console.log(checkMeetingTimeframe('8:0', '10:0', '8:0', 120)); -console.log(checkMeetingTimeframe('08:00', '14:30', '14:00', 90)); -console.log(checkMeetingTimeframe('14:00', '17:30', '08:0', 90)); -console.log(checkMeetingTimeframe('8:00', '17:30', '08:00', 900)); \ No newline at end of file +// function checkMeetingTimeframe (startWorkingDay, endWorkingDay, beginningMeeting, durationMeeting) { +// const startWorkingDayInMinutes = convertToMinutes(startWorkingDay); +// const endWorkingDayInMinutes = convertToMinutes(endWorkingDay); +// const beginningMeetingInMinutes = convertToMinutes(beginningMeeting); +// +// const isMeetingAfterWorkStart = startWorkingDayInMinutes <= beginningMeetingInMinutes; +// const isMeetingBeforeWorkEnd = (beginningMeetingInMinutes + durationMeeting) <= endWorkingDayInMinutes; +// +// return isMeetingAfterWorkStart && isMeetingBeforeWorkEnd; +// } +// +// function convertToMinutes(inputValue) { +// const [hours, minutes] = inputValue.split(':'); +// +// return (Number(hours) * 60) + Number(minutes); +// } +// +// console.log(checkMeetingTimeframe('08:00', '17:30', '14:00', 90)); +// console.log(checkMeetingTimeframe('8:0', '10:0', '8:0', 120)); +// console.log(checkMeetingTimeframe('08:00', '14:30', '14:00', 90)); +// console.log(checkMeetingTimeframe('14:00', '17:30', '08:0', 90)); +// console.log(checkMeetingTimeframe('8:00', '17:30', '08:00', 900)); From d48a2f6eee5fae0165e2cea1151a670413753a3c Mon Sep 17 00:00:00 2001 From: Ilya Kharlamov Date: Thu, 19 Dec 2024 12:54:52 +0300 Subject: [PATCH 3/5] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F?= =?UTF-8?q?=D0=B5=D1=82=20=D0=B4=D0=B5=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=82?= =?UTF-8?q?=D1=83=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/thumbnails.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/js/thumbnails.js b/js/thumbnails.js index 5fe2a0a..916c5f6 100644 --- a/js/thumbnails.js +++ b/js/thumbnails.js @@ -4,13 +4,13 @@ const picturesContainer = document.querySelector('.pictures'); function showThumbnail(randomPhotoObjects) { const fragment = document.createDocumentFragment(); - randomPhotoObjects.forEach((object) => { + randomPhotoObjects.forEach(({url, description, likes, comments }) => { const newThumbnail = thumbnailTemplate.cloneNode(true); - newThumbnail.querySelector('img').src = object.url; - newThumbnail.querySelector('img').alt = object.description; - newThumbnail.querySelector('.picture__comments').textContent = object.comments.length; - newThumbnail.querySelector('.picture__likes').textContent = object.likes; + newThumbnail.querySelector('img').src = url; + newThumbnail.querySelector('img').alt = description; + newThumbnail.querySelector('.picture__comments').textContent = comments.length; + newThumbnail.querySelector('.picture__likes').textContent = likes; fragment.appendChild(newThumbnail); }); From f441375882cdf3e2df4db64c2c251ba179ff5833 Mon Sep 17 00:00:00 2001 From: Ilya Kharlamov Date: Thu, 19 Dec 2024 14:48:18 +0300 Subject: [PATCH 4/5] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D1=8F=D0=B5=D1=82?= =?UTF-8?q?=20functions.js,=20=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D1=82=20?= =?UTF-8?q?=D0=BD=D0=B5=D0=B9=D0=BC=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 1 - js/functions.js | 24 ------------------------ js/thumbnails.js | 4 ++-- 3 files changed, 2 insertions(+), 27 deletions(-) delete mode 100644 js/functions.js diff --git a/index.html b/index.html index b1c5781..f29cb74 100644 --- a/index.html +++ b/index.html @@ -250,7 +250,6 @@

Не удалось загрузить данны - diff --git a/js/functions.js b/js/functions.js deleted file mode 100644 index d83501f..0000000 --- a/js/functions.js +++ /dev/null @@ -1,24 +0,0 @@ -//5.16. Функции возвращаются - -// function checkMeetingTimeframe (startWorkingDay, endWorkingDay, beginningMeeting, durationMeeting) { -// const startWorkingDayInMinutes = convertToMinutes(startWorkingDay); -// const endWorkingDayInMinutes = convertToMinutes(endWorkingDay); -// const beginningMeetingInMinutes = convertToMinutes(beginningMeeting); -// -// const isMeetingAfterWorkStart = startWorkingDayInMinutes <= beginningMeetingInMinutes; -// const isMeetingBeforeWorkEnd = (beginningMeetingInMinutes + durationMeeting) <= endWorkingDayInMinutes; -// -// return isMeetingAfterWorkStart && isMeetingBeforeWorkEnd; -// } -// -// function convertToMinutes(inputValue) { -// const [hours, minutes] = inputValue.split(':'); -// -// return (Number(hours) * 60) + Number(minutes); -// } -// -// console.log(checkMeetingTimeframe('08:00', '17:30', '14:00', 90)); -// console.log(checkMeetingTimeframe('8:0', '10:0', '8:0', 120)); -// console.log(checkMeetingTimeframe('08:00', '14:30', '14:00', 90)); -// console.log(checkMeetingTimeframe('14:00', '17:30', '08:0', 90)); -// console.log(checkMeetingTimeframe('8:00', '17:30', '08:00', 900)); diff --git a/js/thumbnails.js b/js/thumbnails.js index 916c5f6..2c73c0e 100644 --- a/js/thumbnails.js +++ b/js/thumbnails.js @@ -1,11 +1,11 @@ -const thumbnailTemplate = document.querySelector('#picture').content.querySelector('.picture'); +const pictureTemplateElement = document.querySelector('#picture').content.querySelector('.picture'); const picturesContainer = document.querySelector('.pictures'); function showThumbnail(randomPhotoObjects) { const fragment = document.createDocumentFragment(); randomPhotoObjects.forEach(({url, description, likes, comments }) => { - const newThumbnail = thumbnailTemplate.cloneNode(true); + const newThumbnail = pictureTemplateElement.cloneNode(true); newThumbnail.querySelector('img').src = url; newThumbnail.querySelector('img').alt = description; From 6d02f53a37df601db803bef26083599452476a27 Mon Sep 17 00:00:00 2001 From: Ilya Kharlamov Date: Thu, 19 Dec 2024 14:58:02 +0300 Subject: [PATCH 5/5] =?UTF-8?q?=D0=92=D0=BD=D0=BE=D1=81=D0=B8=D1=82=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=B2=20=D0=BD=D0=B5?= =?UTF-8?q?=D0=B9=D0=BC=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/thumbnails.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/js/thumbnails.js b/js/thumbnails.js index 2c73c0e..a9b9d85 100644 --- a/js/thumbnails.js +++ b/js/thumbnails.js @@ -5,14 +5,14 @@ function showThumbnail(randomPhotoObjects) { const fragment = document.createDocumentFragment(); randomPhotoObjects.forEach(({url, description, likes, comments }) => { - const newThumbnail = pictureTemplateElement.cloneNode(true); + const pictureElement = pictureTemplateElement.cloneNode(true); - newThumbnail.querySelector('img').src = url; - newThumbnail.querySelector('img').alt = description; - newThumbnail.querySelector('.picture__comments').textContent = comments.length; - newThumbnail.querySelector('.picture__likes').textContent = likes; + pictureElement.querySelector('img').src = url; + pictureElement.querySelector('img').alt = description; + pictureElement.querySelector('.picture__comments').textContent = comments.length; + pictureElement.querySelector('.picture__likes').textContent = likes; - fragment.appendChild(newThumbnail); + fragment.appendChild(pictureElement); }); picturesContainer.appendChild(fragment);