-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBackEndObjects.html
More file actions
61 lines (56 loc) · 1.59 KB
/
BackEndObjects.html
File metadata and controls
61 lines (56 loc) · 1.59 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/qdIsm.css">
</head>
<body>
<h1>Please Enter Your Information Below</h1>
<input>
<button id="add">Submit</button>
<button id="clear">Clear Database</button>
<ol>
</ol>
<script src="https://www.gstatic.com/firebasejs/3.7.3/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyBZCedSSmWw8zgbJ_IE9mJDjYbepZgsR94",
authDomain: "hacktospons-3cbeb.firebaseapp.com",
databaseURL: "https://hacktospons-3cbeb.firebaseio.com",
storageBucket: "hacktospons-3cbeb.appspot.com",
messagingSenderId: "523367268259"
};
firebase.initializeApp(config);
</script>
<script>
var list = document.querySelector("ol");
var input = document.querySelector("input");
var submit = document.getElementById("add");
var database = firebase.database();
var reference = database.ref();
// sending
submit.onclick = function() {
reference.push(input.value);
input.value = "";
};
input.addEventListener("keyup", function(event) {
if (event.which == 13) {
reference.push(input.value);
input.value = "";
}
});
clear.onclick = function() {
reference.remove();
};
//receiving
reference.on("value", function(snapshot) {
var todo = snapshot.val();
list.innerHTML = "";
for (var key in todo) {
var value = todo[key];
list.innerHTML += '<li>' + value + '</li>';
}
})
</script>
</body>
</html>