-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui-functions.js
50 lines (46 loc) · 1.58 KB
/
ui-functions.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
40
41
42
43
44
45
46
47
48
49
50
//declaring Node variables
const addFormNode = document.querySelector('#add-form');
const addFormInputNode = document.querySelector('#add-form input');
const editFormNode = document.querySelector('#edit-form');
const editFormInputNode = document.querySelector('#edit-form input');
const editButton = document.querySelector('.edit');
const cancelButton = document.querySelector('.cancel');
const singleNoteNode = document.querySelector('.single-note');
const notesContainer = document.querySelector('#notes-container');
const addNoteField = document.querySelector('#add-note');
const editNoteField = document.querySelector('#edit-note');
function createNoteNode(text, noteId) {
const html = `
<div class="single-note" data-id="${noteId}">
<p class="note-text">${text}</p>
<div class="note-buttons">
<div class="edit-note" onclick="handleEditSingleNote('${noteId}','${text}')">
<i class="material-icons">
edit
</i>
</div>
<div class="delete-note" onclick="handleDeleteNote('${noteId}')">
<i class="material-icons">
delete
</i>
</div>
</div>
</div>`;
return html;
}
function createLoadingNode() {
const node = document.createElement('h3');
node.id = 'loading';
node.innerText = 'Loading...';
return node;
}
function showEditField() {
editNoteField.style.display = 'block';
editNoteField.style.opacity = 1;
addNoteField.setAttribute('disabled', 'true');
}
function hideEditField() {
addNoteField.removeAttribute('disabled');
editNoteField.style.opacity = 0;
editNoteField.style.display = 'none';
}