2021-04-08 19:28:11 +00:00
|
|
|
<script>
|
|
|
|
|
|
|
|
$: latitude = ""
|
|
|
|
$: longitude = ""
|
|
|
|
$: temp = ""
|
|
|
|
$: weather = ""
|
|
|
|
$: wind = ""
|
|
|
|
$: answer = "???"
|
|
|
|
|
|
|
|
if (!navigator.geolocation) {
|
|
|
|
alert("Geolocation is not supported in this browser.");
|
|
|
|
answer = "\"Fuck it, this asshole didn't allow me to check\" "
|
|
|
|
} else {
|
|
|
|
navigator.geolocation.getCurrentPosition(
|
|
|
|
(position) => {
|
|
|
|
console.log(position.coords)
|
|
|
|
latitude = position.coords.latitude
|
|
|
|
longitude = position.coords.longitude
|
2021-04-08 19:38:50 +00:00
|
|
|
fetch("https://www.7timer.info/bin/civil.php?lon="+longitude+"&lat="+latitude+"&unit=metric&output=json&tzshift=0").then(
|
2021-04-08 19:28:11 +00:00
|
|
|
response => response.json()
|
|
|
|
).then(
|
|
|
|
data => {
|
|
|
|
temp = data.dataseries[0].temp2m
|
|
|
|
weather = data.dataseries[0].weather
|
|
|
|
wind = data.dataseries[0].wind10m.speed
|
|
|
|
if (temp < 17 || wind > 7){
|
|
|
|
answer = "Pants"
|
|
|
|
} else {
|
|
|
|
answer = "Shorts"
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
(error) => {
|
|
|
|
answer = "\"Fuck it, this asshole didn't allow me to check\" "
|
|
|
|
console.log(error);
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!-- Location: {latitude} {longitude} <br>
|
|
|
|
Temp : {temp} <br>
|
|
|
|
Weather : {weather} <br>
|
|
|
|
WindSpeed : {wind} <br> -->
|
|
|
|
|
|
|
|
<h1>It's {answer} Weather</h1> <br>
|
|
|
|
|
|
|
|
Nannal 2021
|
|
|
|
|