-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.html
57 lines (42 loc) · 1.68 KB
/
test.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test</title>
</head>
<body>
<script type="text/javascript" src='../model/io.js'></script>
<script type="text/javascript" src='../TestingLineChart/plot.js'></script>
<script src='https://cdn.firebase.com/js/client/2.3.0/firebase.js'></script>
<script type="text/javascript">
var merge_json = function(average, org_feature) {
var merged = new Array();
for (var i = 0; i < average.length; i++) {
var current_date = average[i].date;
var average_value = average[i].average;
var org_value = undefined;
for (var j = 0; j < org_feature.length; j++) {
if (org_feature[j].date === current_date) {
org_value = org_feature[j].value;
break;
}
}
if (org_value != undefined)
merged.push({'Date': current_date, 'Average': average_value, 'Company': org_value});
}
return merged;
}
var firebasepath = "https://ecaura.firebaseIO.com"
console.log("Starting request")
var myDataRef = new Firebase(firebasepath);
console.log("Connected")
myDataRef.on('value', function(snapshot) {
var average_data = get_average_series(firebasepath, 'water');
console.log(average_data);
var org_feature = get_org_feature(firebasepath, 'nyuad', 'electricity');
console.log(org_feature);
var merged_json = merge_json(average_data, org_feature);
});
</script>
</body>
</html>