-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscripts.js
41 lines (36 loc) · 1.21 KB
/
scripts.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
(function (window) {
function renderWeather(data) {
$("#content-wrapper").removeClass("loading");
if (data.weather === "shorts") {
$("#content-wrapper").html($("#shortsday-true").html());
$("body").addClass("shorts-weather");
} else {
$("#content-wrapper").html($("#shortsday-false").html());
if (data.weather === "freezing") {
$("body").addClass("cold-weather");
} else if (data.weather === "pants") {
$("body").addClass("pants-weather");
} else if (data.weather === "rain") {
$("body").addClass("rain-weather");
$("#video-background").attr("src", "/videos/rain.mp4");
} else if (data.weather === "snow") {
$("body").addClass("snow-weather");
$("#video-background").attr("src", "/videos/snow.mp4");
}
}
}
function success(pos) {
var url =
"/api/forecast/" + pos.coords.latitude + "/" + pos.coords.longitude + "/";
$.getJSON(url, renderWeather);
}
function error() {
var url = "/api/forecast/59.9/10.7/";
$.getJSON(url, renderWeather);
}
var options = {
timeout: 5000,
maximumAge: 60000,
};
navigator.geolocation.getCurrentPosition(success, error, options);
})(window);