-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
103 lines (88 loc) · 2.65 KB
/
app.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
document.write("<html>");
document.write("<head>");
document.write("<meta http-equiv='refresh' content='180'/>");
document.write("</head>");
document.write("</html>");
var t = document.getElementById("t1");
var s = document.getElementById("t2");
var t3 = document.getElementById("t3");
var temp = document.getElementById("t4");
var tri = document.getElementById("tr");
function reset() {
var tmp = new Date().getDate();
var dat = tmp.toString();
firebase
.database()
.ref("id/date")
.set(dat);
window.location.reload();
}
var firebaseref1 = firebase
.database()
.ref()
.child("id/distance");
firebaseref1.on("value", function (datashot) {
var a = datashot.val();
var b = Number(a);
if (b < 20) {
t.value = "High";
tri.style.background = "#E74C3C";
} else if (b >= 20 && b < 80) {
t.value = "Medium";
tri.style.background = "#F7DC6F";
} else {
t.value = "Low";
tri.style.background = "#58D68D";
}
});
var firebaseref2 = firebase
.database()
.ref()
.child("id/location");
firebaseref2.on("value", function (datashot) {
s.value = datashot.val();
});
var firebaseref3 = firebase
.database()
.ref()
.child("id/date");
firebaseref3.on("value", function (datashot) {
var x = datashot.val();
var b = Number(x);
var tmp = new Date().getDate();
var dat = tmp.toString();
var a = Number(dat);
t4.value = a - b + " days ";
var diff = a - b;
if (diff > 2) {
tri.style.background = "#E74C3C";
}
});
// (function() {
// // Initialize Firebase
// var config = {
// apiKey: "AIzaSyAEaIeUPYF9xiQf_KSbmkc8-uYqs9llsqY",
// authDomain: "waste-disposal-management.firebaseapp.com",
// databaseURL: "https://waste-disposal-management.firebaseio.com",
// storageBucket: "waste-disposal-management.appspot.com"
// // messagingSenderId: "51965125444878"
// };
// firebase.initializeApp(config);
// /* var userDataRef = firebase.database().ref("distance");
// userDataRef.once("value").then(function(snapshot) {
// // childData will be the actual contents of the child
// var distance_val = childSnapshot.val().distance;
// // var id_val = childSnapshot.val().AssignedID;
// document.getElementById("distance").innerHTML = distance_val;
// // document.getElementById("id").innerHTML = id_val;
// });
// })();*/
// var userDataRef = firebase
// .database()
// .ref("UserData")
// .orderByKey();
// userDataRef.once("value").then(function(snapshot) {
// var distance_val = distance.val();
// $("#distance").append(distance_val);
// });
// })();