-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdweet.html
52 lines (43 loc) · 2.27 KB
/
dweet.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
<html>
<head>
<meta charset='UTF-8'>
<title>dweetio</title>
<script src="http://code.jquery.com/jquery-1.5.js"></script>
<script type='text/javascript'>
function getData() {
$.getJSON('http://dweet.io/get/latest/dweet/for/kuchyn', function(data) {
//{"this":"succeeded","by":"getting","the":"dweets","with":[{"thing":"kuchyn","created":"2015-12-14T22:00:51.833Z","content":{"temperature":27.3,"humidity":32.8}}]}
//console.log(data); //uncomment this for debug
//console.log(data.this + " " + data.with[0].created + " " + data.with[0].content.temperature + " " + data.with[0].content.humidity ); //further debug
var created = data.with[0].created;
var temperature = data.with[0].content.temperature/1;
var humidity = data.with[0].content.humidity/1;
console.log(created,temperature,humidity);
document.getElementById('value1').innerHTML = created + " " + temperature + "\260C " + humidity + "%";
});
$.getJSON('http://dweet.io/get/latest/dweet/for/kravak', function(data) {
//{"this":"succeeded","by":"getting","the":"dweets","with":[{"thing":"kuchyn","created":"2015-12-14T22:00:51.833Z","content":{"temperature":27.3,"humidity":32.8}}]}
//console.log(data); //uncomment this for debug
//console.log(data.this + " " + data.with[0].created + " " + data.with[0].content.temperature + " " + data.with[0].content.humidity ); //further debug
var created = data.with[0].created;
var temperature = data.with[0].content.temperature/1;
var humidity = data.with[0].content.humidity/1;
console.log(created,temperature,humidity);
document.getElementById('value2').innerHTML = created + " " + temperature + "\260C " + humidity + "%";
});
}
getData();
setInterval('getData()', 60000); // refresh interval in milliseconds (60000 = 60 seconds)
</script>
</head>
<style type="text/css">
/*body { background-color: #ddd; }*/
</style>
<body>
<h1>Meteostanice</h1>
<h2>Kuchyň</h2>
<div id='value1'></div>
<h2>Kravák</h2>
<div id='value2'></div>
</body>
</html>