-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
59 lines (44 loc) · 1.97 KB
/
main.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
$(document).ready(function () {
var lat;
var long;
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
lat = position.coords.latitude;
long = position.coords.longitude;
var api = 'https://fcc-weather-api.glitch.me/api/current?lat=' + lat + '&lon=' + long + '';
$.getJSON(api, function (res) {
var celsius = res.main.temp;
var farenheit = (celsius * 1.8) + 32;
var location = res.name;
$('.weather-location').html(location);
$('.temp').html(Math.floor(celsius));
$('.weather-description').html(res.weather[0].description);
$('.weatherType').attr('id', res.weather[0].main);
$('.row2').on('click', function () {
if ($('.temp').html() == (Math.floor(celsius))) {
$('.temp').html(Math.floor(farenheit));
$('.temp-type').html('°F');
} else {
$('.temp').html(Math.floor(celsius));
$('.temp-type').html('°C');
}
});
//SETTING UP THE ICON
var icons = new Skycons({
"color": "white"
});
icons.set("Clear-day", Skycons.CLEAR_DAY);
icons.set("Clear-night", Skycons.CLEAR_NIGHT);
icons.set("Partly-cloudy-day", Skycons.PARTLY_CLOUDY_DAY);
icons.set("Partly-cloudy-night", Skycons.PARTLY_CLOUDY_NIGHT);
icons.set("Clouds", Skycons.CLOUDY);
icons.set("Rain", Skycons.RAIN);
icons.set("Sleet", Skycons.SLEET);
icons.set("Snow", Skycons.SNOW);
icons.set("Wind", Skycons.WIND);
icons.set("Fog", Skycons.FOG);
icons.play();
});
});
}
});