Skip to content

Commit

Permalink
исправляет экспорт, убирает лишнее и пробует исправить ошибки
Browse files Browse the repository at this point in the history
  • Loading branch information
KateSolodchuk committed Dec 14, 2024
1 parent 7f216e3 commit c2bfc78
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
8 changes: 4 additions & 4 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import './util.js';
import {createPhotoList} from './data.js';
import {renderThumbnails, picturesContainer} from './render-thumbnails.js';
import {renderThumbnails} from './render-thumbnails.js';
import {initClickListener} from './open-full-picture.js';

const data = createPhotoList();
const picturesDataList = createPhotoList();

renderThumbnails(data);
initClickListener(data);
renderThumbnails(picturesDataList);
initClickListener(picturesDataList);



Check failure on line 12 in js/main.js

View workflow job for this annotation

GitHub Actions / Check

Too many blank lines at the end of file. Max of 2 allowed

Check failure on line 12 in js/main.js

View workflow job for this annotation

GitHub Actions / Check

Too many blank lines at the end of file. Max of 2 allowed
9 changes: 4 additions & 5 deletions js/open-full-picture.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ const onClickButtonClose = (evt) => {
closeFullPicture();
};


const openFullPicture = (pictureId, data) => {
const currentPhoto = data.find((photo) => photo.id === Number(pictureId));
const openFullPicture = (pictureId, picturesDataList) => {
const currentPhoto = picturesDataList.find((photo) => photo.id === Number(pictureId));

document.querySelector('body').classList.add('modal-open');
fullPicture.classList.remove('hidden');
Expand All @@ -42,12 +41,12 @@ function closeFullPicture() {
document.removeEventListener('keydown', onDocumentKeydown);
}

const initClickListener = (data) => {
const initClickListener = (picturesDataList) => {
picturesContainer.addEventListener('click', (evt) => {
const currentPicture = evt.target.closest('.picture');

if (currentPicture) {
openFullPicture(currentPicture.dataset.pictureId, data);
openFullPicture(currentPicture.dataset.pictureId, picturesDataList);
}
});
};
Expand Down
18 changes: 9 additions & 9 deletions js/render-comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,27 @@ const renderNextComments = () => {
commentsList.appendChild(commentsFragment);

commentCount.firstChild.textContent = `${renderedCommentsLength} из `;
commentCount.querySelector('.comments-count').textContent = comments.length;
document.querySelector('.social__comment-total-count').textContent = comments.length;

if (renderedCommentsLength >= comments.length) {
commentsLoader.classList.add('hidden');
commentsLoader.classList.add('.hidden');
}

shownComments += VISIBLE_COMMENTS;
};

const clearComments = () => {
shownComments = 0;
commentsList.innerHTML = '';
commentsLoader.classList.remove('hidden');
commentsLoader.removeEventListener('click', renderNextComments);
};

const renderComments = (currentPhotoComments) => {
comments = currentPhotoComments;
renderNextComments();

commentsLoader.addEventListener('click', renderNextComments);
};

const clearComments = () => {
shownComments = 0;
commentsList.innerHTML = '';
commentsLoader.classList.remove('hidden');
commentsLoader.removeEventListener('click', renderNextComments);
};

export {clearComments, renderComments};
3 changes: 1 addition & 2 deletions js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ const getRandomInteger = (a, b) => {

const isEscapeKey = (evt) => evt.key === 'Escape';

export {getRandomInteger};
export {isEscapeKey};
export {getRandomInteger, isEscapeKey};

0 comments on commit c2bfc78

Please sign in to comment.