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

Function showNotes

assets/js/note-app.js:75–118  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

73
74// this function show our notes
75function showNotes(){
76 let notes = localStorage.getItem('notes');
77 let notesObj;
78
79 if(notes == null){
80 notesObj = [];
81 }
82 else{
83 notesObj = JSON.parse(notes);
84 }
85
86 let addNote = "";
87
88 //This list contains the classes for favorite/not-favorite cards
89 const favorite_class = ["noteCard m-2 card favorite","noteCard m-2 card not-favorite"]
90
91 notesObj.forEach((element, index) => {
92 addNote += `<div class="${element.favorite ? favorite_class[0]:favorite_class[1]}" style="width: auto;">
93 <div class="card-body">
94 <div class="row mb-3">
95 <div class="col">
96 <h2 class="card-title" id="noteTitle">${element.title}</h2>
97 <p class="card-text" id="noteText">${element.text}</p>
98 </div>
99 <div class="col-2">
100 <span class="iconify" data-icon=${element.favorite ? "bi:star-fill":"bi:star"} data-inline="false" data-width="24" data-height="24" style=${element.favorite ? "color:gold":"color:black"} onclick=favoriteNote(${index})></span>
101 </div>
102 </div>
103 <button id="${index}" onclick="deleteNote(this.id)" class="btn btn-large jsBtn">Delete Note</button>
104 <button onclick="editNote(${index})" class="btn btn-large jsBtn">Edit Note</button>
105
106 </div>
107 </div>`
108 });
109
110 let notesEle = document.getElementById('notes');
111 if(notesObj.length != 0){
112 notesEle.innerHTML = addNote;
113 }
114 else{
115 notesEle.innerHTML = `<div class="container lead text-white">You haven't add any note yet. Try to to add some note using above section and then press "Add Note" button.</div>`
116 }
117
118}
119// this is edit function
120function editNote(index){
121 let saveindex = document.getElementById('saveindex')

Callers 3

note-app.jsFile · 0.70
deleteNoteFunction · 0.70
favoriteNoteFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected