forked from GlebkaF/webdev-dom-homework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderForm.js
39 lines (38 loc) · 1.16 KB
/
renderForm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { name, token } from './main.js';
import { renderLogin } from './renderLogin.js';
export const renderForm = () => {
const container = document.querySelector('.form');
container.innerHTML = token
? `<div class="add-form">
<input
type="text"
id="add-form-name"
class="add-form-name"
placeholder="Введите ваше имя"
value=${name}
readonly
/>
<textarea
id="add-form-text"
type="textarea"
class="add-form-text"
placeholder="Введите ваш коментарий"
rows="4"
></textarea>
<div class="add-form-row">
<button
class="add-form-button"
id="add-form-button"
>
Написать
</button>
</div>`
: `<div class="entryForm">Чтобы оставить комментарий, <button class="entryButton" >авторизуйтесь</button></div>`;
const entryButton = document.querySelector('.entryButton');
if (entryButton) {
entryButton.addEventListener('click', (event) => {
event.preventDefault();
renderLogin();
});
}
};