(index)
| 247 | |
| 248 | //this function will change the favorite state of the note |
| 249 | function favoriteNote(index){ |
| 250 | |
| 251 | let notes = localStorage.getItem('notes'); |
| 252 | let notesObj; |
| 253 | |
| 254 | if(notes == null){ |
| 255 | notesObj = []; |
| 256 | } |
| 257 | else{ |
| 258 | notesObj = JSON.parse(notes); |
| 259 | } |
| 260 | |
| 261 | //we set the new favorite state |
| 262 | notesObj[index].favorite = !notesObj[index].favorite; |
| 263 | //Finally, we save it into the localstorage |
| 264 | localStorage.setItem('notes', JSON.stringify(notesObj)); |
| 265 | |
| 266 | showNotes(); |
| 267 | |
| 268 | //We check if the user was already watching only the favorites |
| 269 | if(showing_favs) showFavorites(); |
| 270 | |
| 271 | } |
| 272 | |
| 273 | /* |
| 274 | further features |
nothing calls this directly
no test coverage detected