-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
executable file
·54 lines (40 loc) · 1.38 KB
/
script.js
File metadata and controls
executable file
·54 lines (40 loc) · 1.38 KB
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
$(document).ready(function() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
$.getJSON("https://api.darksky.net/forecast/ba71549f97e07b21bb1614407e38ffd5/"+ position.coords.latitude+","+ position.coords.longitude + "?callback=?", function(json) {
console.log(json)
var tempf= json.currently.apparentTemperature;
measurementSystem="fahrenheit";
var tempc= ((tempf-32)*5)/9;
htmlTempF= tempf.toFixed(0)+ "℉<br><br><a style=\"font-size: 24px\">" + json.minutely.summary + "</a>"
htmlTempC= tempc.toFixed(0)+ "℃<br><br><a style=\"font-size: 24px\">" + json.minutely.summary + "</a>"
var icon=json.currently.icon;
if (icon=="cloudy")
{
$(".cardIcon").html("<i class=\"wi wi-day-cloudy-high\"></i>");
}
else if (icon=="rain")
{
$(".cardIcon").html("<i class=\"wi wi-day-rain\"></i>");
}
else if (icon=="snow")
{
$(".cardIcon").html("<i class=\"wi wi-snow\"></i>");
}
else
{
$(".cardIcon").html("<i class=\"wi wi-day-sunny\"></i>");
}
$(".cardData").html(htmlTempF);
});
});
}
$("#measure").on("click", function(){
if (this.checked) {
inCorF=htmlTempF;
} else {
inCorF=htmlTempC;
}
$(".cardData").html(inCorF);
});
});