-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweather.html
100 lines (60 loc) · 2.65 KB
/
weather.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
100
<html>
<head>
<title>Weather</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script>
var getLocation = function() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showWeather);
} else {
x.innerHTML = "Geolocation is required for this app to work.";
}
}
var chimeUser = {
userLocation: '',
wxicon: '',
desc: '',
temp: '',
iconSrc: 'https://profile.weather.com/img/wxicons/52/',
iconType: '.png'
}
var showWeather = function(position) {
// var url = [ 'http://api.wunderground.com/api/5f12c0c5ef78f0dc/geolookup/conditions/q/', position.coords.latitude, ',', position.coords.longitude, '.json'].join('');
var url = ["http://dsx-dev.weather.com/wxd/{MORecord;loc}/",
position.coords.latitude.toFixed(2),
',',
position.coords.longitude.toFixed(2)
].join('');
var updateChimeUser = function(data) {
var icon = data.body[0].doc.MOData.sky;
var userLocation = data.body[1].doc.prsntNm;
var desc = data.body[0].doc.MOData.wx;
var temp = data.body[0].doc.MOData.tmpF;
chimeUser.wxicon = icon;
chimeUser.userLocation = userLocation;
chimeUser.desc = desc;
chimeUser.temp = temp;
alert('geolocarted');
$('#chimeUserInfo').html('chimeUser: ' + JSON.stringify(chimeUser));
}
$.ajax(url, {
type: 'GET',
dataType: "jsonp",
jsonp: 'jsonp',
success: function(responseData, textStatus, jqXHR) {
updateChimeUser(responseData);
console.debug('reposnce: ', responseData);
},
// url: "http://dsx-dev.weather.com/wxd/%7BMORecord;loc%7D33.89,-84.46",
error: function(responseData, textStatus, errorThrown) {
// alert('POST failed.');
}
});
}
</script>
</head>
<body onload="getLocation()">
<h1>Weather</h1>
<p id="chimeUserInfo"></p>
</body>
</html>