-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp_google.html
99 lines (86 loc) · 3.19 KB
/
temp_google.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
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Temperature and humidity</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>-->
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/parse-1.2.8.min.js"></script>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type="text/javascript">
Parse.initialize("ZKO8dy1AE8bESiGKEtoV2WzayMX023OpCabQ3ijl", "fgKvOnZvBjqIfbWL10I3ZRHILpujZURKnnoYZaeS");
var temperature = 0;
var humidity = 20;
google.load('visualization', '1', {packages:['gauge']});
google.setOnLoadCallback(drawChart);
//google.setOnLoadCallback(feedData);
function sendDataToParse(thData) {
var THObject = Parse.Object.extend("THObject");
var obj = new THObject();
var temp = thData[0];
var hum = thData[1];
obj.save({temperature: thData[0], humidity: thData[1]}, {
success: function(object) {
//alert("yay! it worked");
},
error: function(object, error) {
alert('error');
}
});
}
function feedData() {
$.getJSON('index.py?json=1', function(jd) {
temperature = parseFloat(jd.temperature);
humidity = parseFloat(jd.humidity);
var data = google.visualization.arrayToDataTable([
['Label', 'Value'],
['Temperature', temperature],
['Humidity', humidity],
]);
drawChart(data);
});
}
function drawChart(data) {
setTimeout(feedData, 300000);
/*$.getJSON('index.py?json=1', function(jd) {
temperature = parseFloat(jd.temperature);
humidity = parseFloat(jd.humidity);
var data = google.visualization.arrayToDataTable([
['Label', 'Value'],
['Temperature', temperature],
['Humidity', humidity],
]);
var options = {
width: 800, height: 180,
redFrom: 90, redTo: 100,
yellowFrom:75, yellowTo: 90,
minorTicks: 5
};
var chart = new google.visualization.Gauge(document.getElementById('chart_div'));
chart.draw(data, options);*/
//thData = [temperature, humidity];
//sendDataToParse(thData);
//});
var options = {
width: 800, height: 180,
redFrom: 90, redTo: 100,
yellowFrom:75, yellowTo: 90,
minorTicks: 5
};
if(!(typeof data.target === 'undefined')){
var data = google.visualization.arrayToDataTable([
['Label', 'Value'],
['Temperature', temperature],
['Humidity', humidity],
]);
feedData();
}
var chart = new google.visualization.Gauge(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id='chart_div'></div>
</body>
</html>