()
| 41 | |
| 42 | // Function to show elements from localStorage |
| 43 | function showNotes() { |
| 44 | let notes = localStorage.getItem("notes"); |
| 45 | if (notes == null) { |
| 46 | notesObj = []; |
| 47 | } else { |
| 48 | notesObj = JSON.parse(notes); |
| 49 | } |
| 50 | let html = ""; |
| 51 | notesObj.forEach(function (element, index) { |
| 52 | if (element.radio1) { |
| 53 | html += ` |
| 54 | <div class="noteCard my-2 mx-2 card" style="width: 18rem;"> |
| 55 | <div class="card-body"> |
| 56 | <h5 class="card-title">${element.title}</h5> |
| 57 | <h6 class="card-text text-center my-3" style="color:rgb(0,220,0);font-weight:700;font-size:18px">Important Note</h6> |
| 58 | <p class="card-text">${element.text}</p> |
| 59 | <button id="${index}"onclick="deleteNote(this.id)" class="btn btn-danger">Delete This Note</button> |
| 60 | <h6 class="card-text text-center my-3">${element.time}</h6> |
| 61 | </div> |
| 62 | </div>`; |
| 63 | } |
| 64 | else if (element.radio2) { |
| 65 | html += ` |
| 66 | <div class="noteCard my-2 mx-2 card" style="width: 18rem;"> |
| 67 | <div class="card-body"> |
| 68 | <h5 class="card-title">${element.title}</h5> |
| 69 | <h6 class="card-text text-center my-3" style="color:red;font-weight:700;font-size:18px">Unimportant Note</h6> |
| 70 | <p class="card-text">${element.text}</p> |
| 71 | <button id="${index}"onclick="deleteNote(this.id)" class="btn btn-danger">Delete This Note</button> |
| 72 | <h6 class="card-text text-center my-3">${element.time}</h6> |
| 73 | </div> |
| 74 | </div>`; |
| 75 | } |
| 76 | else { |
| 77 | html += ` |
| 78 | <div class="noteCard my-2 mx-2 card" style="width: 18rem;"> |
| 79 | <div class="card-body"> |
| 80 | <h5 class="card-title">${element.title}</h5> |
| 81 | <h6 class="card-text text-center my-3" style="font-weight:700;font-size:18px">Note</h6> |
| 82 | <p class="card-text">${element.text}</p> |
| 83 | <button id="${index}"onclick="deleteNote(this.id)" class="btn btn-danger">Delete This Note</button> |
| 84 | <h6 class="card-text text-center my-3">${element.time}</h6> |
| 85 | </div> |
| 86 | </div>`; |
| 87 | } |
| 88 | }); |
| 89 | let notesElm = document.getElementById("notes"); |
| 90 | if (notesObj.length != 0) { |
| 91 | notesElm.innerHTML = html; |
| 92 | } |
| 93 | else { |
| 94 | notesElm.innerHTML = `Nothing To Show! Use "Add Your Note" Section Above To Add Your Notes.`; |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | // Function to delete a note |
| 99 | function deleteNote(index) { |
no test coverage detected