MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / addNewNote

Function addNewNote

assets/js/google_keep.js:18–69  ·  view source on GitHub ↗
(text = '')

Source from the content-addressed store, hash-verified

16}
17
18const addNewNote = (text = '') =>{
19
20 const note = document.createElement('div');
21 note.classList.add('note');
22
23 const htmlData =`
24 <div class="operation">
25 <button class="edit"><i class="fas fa-edit"></i></button>
26 <button class="delete"><i class="fas fa-trash-alt"></i></i></button>
27 </div>
28
29 <div class="main ${text ? "" : "hidden"}"></div>
30 <textarea class="" ${text ? "hidden" : ""}></textarea> `;
31
32 note.insertAdjacentHTML('afterbegin',htmlData);
33 console.log(note);
34
35 const editButton = note.querySelector('.edit');
36 const delButton = note.querySelector('.delete');
37 const maindiv = note.querySelector('.main');
38 const textArea = note.querySelector('textarea');
39
40 // deleting note
41 delButton.addEventListener('click', () =>{
42 note.remove();
43 updateLSData();
44 });
45
46 // edit button
47 textArea.value = text;
48 maindiv.innerHTML = text;
49
50
51 editButton.addEventListener('click', () =>{
52 maindiv.classList.toggle('hidden');
53 textArea.classList.toggle('hidden');
54 })
55
56 textArea.addEventListener('change', (event) => {
57 const value = event.target.value;
58 // console.log(value);
59 maindiv.innerHTML = value;
60
61 updateLSData();
62 })
63
64
65
66
67 document.body.appendChild(note);
68
69}
70
71// gettin json data
72

Callers 1

google_keep.jsFile · 0.85

Calls 1

updateLSDataFunction · 0.85

Tested by

no test coverage detected