-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes.js
44 lines (33 loc) · 1.2 KB
/
notes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* jshint esversion: 6 */
let ref = firebase.database().ref('/notes/');
let cards = document.getElementById('cards');
ref.once('value').then((snapshot)=>{
console.log(snapshot.val());
for (const key in snapshot.val()) {
let note = snapshot.val()[key];
cards.appendChild(creatNoteCard(note, key));
}
});
var creatNoteCard = function(note, id){
var container = document.createElement("DIV");
var header = document.createElement("DIV");
var icon = document.createElement("I");
var cardbody = document.createElement("DIV");
var notes = document.createElement("P");
container.className = "card algo-card";
header.className = "card-header";
icon.className = "fa fa-edit float-right icon-button";
cardbody.className = "card-body";
header.innerHTML = note.title;
var notesText = note.notemessage.replace(/\n/g, "<br />");
notes.innerHTML = notesText;
icon.addEventListener('click', () => {
sessionStorage.setItem('editNotesId', id);
window.location = "addnotes.html";
});
header.appendChild(icon);
cardbody.append(notes);
container.append(header);
container.append(cardbody);
return container;
};