Skip to content

Week 3#1

Open
vikashatalova wants to merge 6 commits intomainfrom
week-3
Open

Week 3#1
vikashatalova wants to merge 6 commits intomainfrom
week-3

Conversation

@vikashatalova
Copy link
Copy Markdown
Owner

No description provided.

@vikashatalova vikashatalova temporarily deployed to github-pages January 23, 2023 10:53 — with GitHub Pages Inactive
scripts/main.js Outdated
const hashtags = e.target.value;
const pattern = /^#([A-Za-z0-9_-]+)$/;

if (pattern.test(hashtags) && hashtags.length <= 200) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

200 в константу

scripts/main.js Outdated

if (pattern.test(postTextValue) && postTextValue.length <= count) {
textValidate.textContent = 'Данные введены корректно';
const sumsCounter = count - Number(postTextValue.length);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

postTextValue.length и так число

scripts/main.js Outdated
const textLength = e.target.value.length;
const postTextValue = e.target.value;
const pattern = /^([A-Za-z0-9_-]+)$/;
const count = 2000;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это константа, а они пишутся капсом

scripts/main.js Outdated
} else if (postTextValue === '') {
textValidate.textContent = 'Поле обязательно для заполнения';
postPublishButton.disabled = true;
} else if (postTextValue.length === 2000) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно вынести в константу и сослаться на нее

scripts/main.js Outdated
textValidate.textContent = 'Поле обязательно для заполнения';
postPublishButton.disabled = true;
} else if (postTextValue.length === 2000) {
const sumsCounter = count - Number(postTextValue.length);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

postTextValue.length уже число

scripts/utils.js Outdated

const timer = setTimeout(() => {
clonMessage.remove();
}, 2000);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В константу

scripts/utils.js Outdated
const timer = setTimeout(() => {
clonMessage.remove();
}, 2000);
return timer
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ты возвращаешь значение, но нигде не используешь его. Нужно ли возвращать?

scripts/utils.js Outdated

export const createElement = (content) => {
const {image, text, tags, created_at, likes, comments, id} = content;
const randomAvatar = `https://avatars.dicebear.com/api/avataaars/${(Math.random() + 1)}.svg`;
Copy link
Copy Markdown

@PolinaShneider PolinaShneider Jan 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Константы капсом

scripts/utils.js Outdated
const newDateComments = dateCommnents.toLocaleDateString("ru", optionsComments);

const commentsItem = document.createElement('div');
commentsItem.className = 'comments__item';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Определись, ты либо используешь classList, либо className

scripts/utils.js Outdated
.finally(() => {
closePreviewPostModal();
})
return response
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Возвращаемое значение не используется

scripts/utils.js Outdated
}
})
.catch(() => showMessage(messageFail, 'Ошибка', 'Повторите попытку снова'))
return response
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

И тут

photoCount.textContent = data.length;
photosContent.innerHTML = '';
data.forEach((content) => {
const elementHTML = createElement(content);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Множественная вставка в DOM без фрагмента


const toggleLoader = () => {
const loader = document.querySelector('#loader');
loader.classList.remove('hidden');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем сначала убирать класс hidden и тут же его добавлять? Прямо сразу же

@vikashatalova vikashatalova temporarily deployed to github-pages January 25, 2023 22:45 — with GitHub Pages Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants