-
Notifications
You must be signed in to change notification settings - Fork 1
Надо подкачаться #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Надо подкачаться #12
Conversation
|
♻️ Я собрал ваш пулреквест. Посмотреть можно здесь. |
|
♻️ Я собрал ваш пулреквест. Посмотреть можно здесь. |
|
♻️ Я собрал ваш пулреквест. Посмотреть можно здесь. |
js/api.js
Outdated
| @@ -0,0 +1,35 @@ | |||
| //import {showErrorGet} from './response.js'; | |||
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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();
js/img-form-uploader.js
Outdated
| isCommentValid(inputText.value); | ||
| }; | ||
|
|
||
| /* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
надо убрать код, если он не используется
js/img-form-uploader.js
Outdated
| inputText.addEventListener('input', handleTextChange); | ||
|
|
||
| imgUploadForm.addEventListener('submit', validateFormSubmit); | ||
| //imgUploadForm.addEventListener('submit', validateFormSubmit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
код не требуется
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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'; | |||
|
|
|||
There was a problem hiding this comment.
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 = () => { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Скорее всего, это ненужный код
🎓 Надо подкачаться
💥 https://htmlacademy-javascript.github.io/2607777-kekstagram-2/12/