Skip to content

Commit

Permalink
Merge pull request #6 from OlgaGulyakevich/module7-task1
Browse files Browse the repository at this point in the history
  • Loading branch information
keksobot authored Dec 12, 2024
2 parents d37b118 + 507d24e commit 72a5431
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 21 deletions.
4 changes: 2 additions & 2 deletions js/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ const generatePhotoDescription = () => ({
});

// Генерация массива описаний фотографий
const generateDataPhotoDescriptions = () => Array.from(
const generatePhotoDescriptions = () => Array.from(
{length: PHOTO_DESCRIPTION_COUNT},
generatePhotoDescription);

export {generateDataPhotoDescriptions};
export { generatePhotoDescriptions };
4 changes: 0 additions & 4 deletions js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ const isPolindrom = (text) => {
// Функция для извлечения всех цифр из строки.

const extractDigits = (inputChar) => {

Check failure on line 19 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'extractDigits' is assigned a value but never used

const nomalizedChars = inputChar.replaceAll(' ', '').split(''); /* Убирает пробелы и разбивает на символы */

let digits = ''; /* Переменная для хранения цифр */

for (const char of nomalizedChars) {
Expand All @@ -33,12 +31,10 @@ const extractDigits = (inputChar) => {
// Функция для проверки, укладывается ли встреча в рамки рабочего дня.

function isMeetingWithinWorkHours (workStart, workEnd, meetingStart, meetingDuration) {

Check failure on line 33 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'isMeetingWithinWorkHours' is defined but never used

const timeToMinutes = (time) => {
const [hours, minutes] = time.split(':').map(Number);
return hours * 60 + minutes;
};

const workStartMinutes = timeToMinutes(workStart);
const workEndMinutes = timeToMinutes(workEnd);
const meetingStartMinutes = timeToMinutes(meetingStart);
Expand Down
31 changes: 17 additions & 14 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import {generateDataPhotoDescriptions} from './data.js';
import './upload.js';
import './scale.js';
import './effects.js';
import './validation.js';
import './fetch.js';
import './thumbnails.js';
import './filters.js';
import './fullscreen.js';
import './feed.js';
import './form.js';
import './form-visability.js';
// import './upload.js';
// import './scale.js';
// import './effects.js';
// import './validation.js';
// import './fetch.js';
// import './filters.js';
// import './fullscreen.js';
// import './feed.js';
// import './form.js';
// import './form-visability.js';

const photoDescriptions = generateDataPhotoDescriptions();
console.log(photoDescriptions);
import {generatePhotoDescriptions} from './data.js';
import {renderDataPhotos} from './thumbnails.js';

const pictureContainer = document.querySelector('.pictures');
const dataPhotos = generatePhotoDescriptions();

renderDataPhotos(pictureContainer, dataPhotos);
24 changes: 24 additions & 0 deletions js/thumbnails.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const similarPhotoTemplate = document
.querySelector('#picture')
.content.querySelector('.picture');

const PhotoFragment = document.createDocumentFragment();

const renderDataPhotos = (container, dataPhotos) => {
dataPhotos.forEach(({url, description, likes, comments}) => {
const photoElement = similarPhotoTemplate.cloneNode(true);

const photoElementImg = photoElement.querySelector('.picture__img');
photoElementImg.src = url;
photoElement.alt = description;

photoElement.querySelector('.picture__likes').textContent = likes;
photoElement.querySelector('.picture__comments').textContent = comments.length;

PhotoFragment.append(photoElement);
});

container.append(PhotoFragment);
};

export { renderDataPhotos };
1 change: 0 additions & 1 deletion js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const getRandomInteger = (min, max) => {
return Math.floor(result);
};


// Получение случайного элемента массива
const getRandomArrayElement = (elements) => elements[getRandomInteger(0, elements.length - 1)];

Expand Down

0 comments on commit 72a5431

Please sign in to comment.