|
@@ -0,0 +1,75 @@
|
|
1
|
+<html>
|
|
2
|
+<head><title> Read, write, Update, Deleta Data Firebase JS</title></head>
|
|
3
|
+
|
|
4
|
+<body>
|
|
5
|
+ productId <input id="idbox" type="text"></input><br><br>
|
|
6
|
+ attribute <input id="attributebox" type="text"></input><br><br>
|
|
7
|
+ category <input id="categorybox" type="text"></input><br><br>
|
|
8
|
+ imageUrl <input id="imageUrlbox" type="text"></input><br><br>
|
|
9
|
+ marketPrice <input id="marketPricebox" type="text"></input><br><br>
|
|
10
|
+ name <input id="namebox" type="text"></input><br><br>
|
|
11
|
+ ourPrice <input id="ourPricebox" type="text"></input><br><br>
|
|
12
|
+ units <input id="unitsbox" type="text"></input><br><br>
|
|
13
|
+ <br><br>
|
|
14
|
+ <button id = "insert">INSERT</button>
|
|
15
|
+ <button id = "select">SELECT</button>
|
|
16
|
+ <button id = "update">UPDATE</button>
|
|
17
|
+ <button id = "delete">DELETE</button>
|
|
18
|
+
|
|
19
|
+ <script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-app.js"></script>
|
|
20
|
+ <script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-auth.js"></script>
|
|
21
|
+ <script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-database.js"></script>
|
|
22
|
+ <script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-analytics.js"></script>
|
|
23
|
+
|
|
24
|
+ <script id="MainScript">
|
|
25
|
+ var firebaseConfig = {
|
|
26
|
+ apiKey: "AIzaSyAilkN9V1yNMfqCvPGTeiovVLOBSx1w1cc",
|
|
27
|
+ authDomain: "comedoresescolares-82ede.firebaseapp.com",
|
|
28
|
+ databaseURL: "https://comedoresescolares-82ede-default-rtdb.firebaseio.com",
|
|
29
|
+ projectId: "comedoresescolares-82ede",
|
|
30
|
+ storageBucket: "comedoresescolares-82ede.appspot.com",
|
|
31
|
+ messagingSenderId: "182848144209",
|
|
32
|
+ appId: "1:182848144209:web:27dfc87c0c49d2f9534970",
|
|
33
|
+ measurementId: "G-4KK5ME3PJ5"
|
|
34
|
+ };
|
|
35
|
+ // Initialize Firebase
|
|
36
|
+ firebase.initializeApp(firebaseConfig);
|
|
37
|
+ firebase.analytics();
|
|
38
|
+
|
|
39
|
+ //var productV
|
|
40
|
+ var attributeV, categoryV, imageUrlV, marketPriceV, nameV, ourPriceV, unitsV;
|
|
41
|
+
|
|
42
|
+ function Ready(){
|
|
43
|
+ productV = document.getElementById('idbox').value;
|
|
44
|
+ attributeV = document.getElementById('attributebox').value;
|
|
45
|
+ categoryV = document.getElementById('categorybox').value;
|
|
46
|
+ imageUrlV = document.getElementById('imageUrlbox').value;
|
|
47
|
+ marketPriceV = document.getElementById('marketPricebox').value;
|
|
48
|
+ nameV = document.getElementById('namebox').value;
|
|
49
|
+ ourPriceV = document.getElementById('ourPricebox').value;
|
|
50
|
+ unitsV = document.getElementById('unitsbox').value;
|
|
51
|
+ }
|
|
52
|
+
|
|
53
|
+ document.getElementById('insert').onclick = function(){
|
|
54
|
+ Ready();
|
|
55
|
+ firebase.database().ref('products/'+ Math.random().toString(36).substring(2,9)).set ({
|
|
56
|
+ //productId: productV,
|
|
57
|
+ attribute: attributeV,
|
|
58
|
+ categoryId: categoryV,
|
|
59
|
+ imageUrl: imageUrlV,
|
|
60
|
+ marketPrice: marketPriceV,
|
|
61
|
+ name: nameV,
|
|
62
|
+ ourPrice: ourPriceV,
|
|
63
|
+ units: unitsV
|
|
64
|
+ })
|
|
65
|
+ }
|
|
66
|
+
|
|
67
|
+ document.getElementById('delete').onclick = function(){
|
|
68
|
+ Ready();
|
|
69
|
+ firebase.database().ref('Product/'+ productV).remove();
|
|
70
|
+ }
|
|
71
|
+
|
|
72
|
+ </script>
|
|
73
|
+
|
|
74
|
+</body>
|
|
75
|
+</html>
|