<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
        fetch("https://www.7timer.info/bin/civil.php?lon="+longitude+"&lat="+latitude+"&unit=metric&output=json&tzshift=0").then(
            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

