Skip to content

Conversation

@PAVLUXAN
Copy link
Contributor

@PAVLUXAN PAVLUXAN commented Jul 22, 2025

@keksobot keksobot changed the title feat:create funtions api Надо подкачаться Jul 22, 2025
keksobot pushed a commit that referenced this pull request Jul 22, 2025
@keksobot
Copy link
Contributor

♻️ Я собрал ваш пулреквест. Посмотреть можно здесь.

@keksobot
Copy link
Contributor

♻️ Я собрал ваш пулреквест. Посмотреть можно здесь.

keksobot pushed a commit that referenced this pull request Jul 23, 2025
@keksobot
Copy link
Contributor

♻️ Я собрал ваш пулреквест. Посмотреть можно здесь.

keksobot pushed a commit that referenced this pull request Jul 23, 2025
js/api.js Outdated
@@ -0,0 +1,35 @@
//import {showErrorGet} from './response.js';

Choose a reason for hiding this comment

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

Если код не нужен - его лучше убрать

js/api.js Outdated
}
throw new Error(`${response.status} - ${response.statusText}`);
})
.then((response) => response.json())

Choose a reason for hiding this comment

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

надо объединить с предыдущей секцией. Обсуждали, что код в ней синхронный

js/api.js Outdated
.then((response) => {
if (response.ok) {
onSuccess();
} else {

Choose a reason for hiding this comment

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

else очень неудобный элемент для чтения и предполагает, что две ветки объединяются в для дальнейшего вычисления. А если вычисления нет - завершаем работу:

if (response.ok) {
   onSuccess();
   return;
}
onError();

isCommentValid(inputText.value);
};

/*

Choose a reason for hiding this comment

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

надо убрать код, если он не используется

inputText.addEventListener('input', handleTextChange);

imgUploadForm.addEventListener('submit', validateFormSubmit);
//imgUploadForm.addEventListener('submit', validateFormSubmit);

Choose a reason for hiding this comment

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

код не требуется

Choose a reason for hiding this comment

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

Управляем кнопкой через слушателя изменений на форме

form.addEventListener('input', () => {
  const isValid = pristine.validate();
  submitButton.disabled = !isValid;
});
submitButton.disabled = !pristine.validate();

Строки убираем - они не функциональны:

const handleTagChange = () => {
  isHashtagsValid(inputHashtag.value);
};
const handleTextChange = () => {
  isCommentValid(inputText.value);
};

inputHashtag.addEventListener('input', handleTagChange);
inputText.addEventListener('input', handleTextChange);

js/main.js Outdated
import './img-form-uploader.js';
renderPhoto();
import { getData } from './api.js';
//import {showAlert} from './util.js';

Choose a reason for hiding this comment

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

Лучше чистить от комментариев сразу

@@ -0,0 +1,87 @@
import { isEscapeKey } from './util.js';
//import {showAlert} from './util.js';

Copy link

@ILokalin ILokalin Jul 23, 2025

Choose a reason for hiding this comment

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

Название файла не соответствует содержимому - больше подходит alert или notifications

js/response.js Outdated

};

export const showErrorSend = () => {

Choose a reason for hiding this comment

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

процесс обычно с ing окончанием:

showErrorGetting
showErrorSending

Полезно проверить со словарем. Сейчас название функции переводится как "показать ошибку получить"

js/response.js Outdated

};

const TIMEOUT = 5000;

Choose a reason for hiding this comment

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

Константы модуля ожидаются после импортов

const errorFragment = document.createDocumentFragment();
const errorElement = errorTemplateSend.cloneNode(true);

errorFragment.append(errorElement);

Choose a reason for hiding this comment

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

Большая часть функции повторяется в showSuccess - будет удобнее реализовать одну функцию для навешивания событий и передавать ей соответсвующий темплейт

js/util.js Outdated
};

export {getRandomNumber, getRandomItem, isEscapeKey, selectWordByCount};
/*const showAlert = (message) => {

Choose a reason for hiding this comment

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

Скорее всего, это ненужный код

@keksobot keksobot merged commit a25a21b into htmlacademy-javascript:master Jul 24, 2025
1 check passed
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.

3 participants