()
| 54 | |
| 55 | // this function show our notes |
| 56 | function showNotes(){ |
| 57 | let notes = localStorage.getItem('notes'); |
| 58 | let notesObj; |
| 59 | |
| 60 | if(notes == null){ |
| 61 | notesObj = []; |
| 62 | } |
| 63 | else{ |
| 64 | notesObj = JSON.parse(notes); |
| 65 | } |
| 66 | |
| 67 | let addNote = ""; |
| 68 | |
| 69 | //This list contains the classes for favorite/not-favorite cards |
| 70 | const favorite_class = ["noteCard m-2 card favorite","noteCard m-2 card not-favorite"] |
| 71 | |
| 72 | notesObj.forEach((element, index) => { |
| 73 | addNote += `<div class="${element.favorite ? favorite_class[0]:favorite_class[1]}" style="width: 18rem;"> |
| 74 | <div class="card-body"> |
| 75 | <div class="row mb-3"> |
| 76 | <div class="col"> |
| 77 | <h2 class="card-title" style="height:80px;">${element.title}</h2> |
| 78 | <img class="card-text"src="${element.text}" style="height:250px;width:240px;" > |
| 79 | </div> |
| 80 | <div class="col-2"> |
| 81 | <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> |
| 82 | </div> |
| 83 | </div> |
| 84 | <button id="${index}" onclick="deleteNote(this.id)" class="btn btn-danger">Delete</button> |
| 85 | <button onclick="editNote(${index})" class="btn btn-primary">Edit</button> |
| 86 | |
| 87 | </div> |
| 88 | </div>` |
| 89 | }); |
| 90 | |
| 91 | let notesEle = document.getElementById('notes'); |
| 92 | if(notesObj.length != 0){ |
| 93 | notesEle.innerHTML = addNote; |
| 94 | } |
| 95 | else{ |
| 96 | notesEle.innerHTML = `You haven't add any note yet. Try to to add some note using above section and then press "Add Note" button.` |
| 97 | } |
| 98 | |
| 99 | } |
| 100 | // this is edit function |
| 101 | function editNote(index){ |
| 102 | let saveindex = document.getElementById('saveindex') |
no outgoing calls
no test coverage detected