function showWeather(e){$.getJSON("https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22"+e.city+"%2C%20"+e.countryCode+"%22)and%20u%3D'c'&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys",function(e){switch($(".temp-p").append("Temperature: "+e.query.results.channel.item.condition.temp+" &deg;C"),$(".visibility-p").append("Visibility: "+e.query.results.channel.atmosphere.visibility+" km"),$(".humidity-p").append("Humidity: "+e.query.results.channel.atmosphere.humidity+" %"),$(".weather-condition-p").append("Condition: "+e.query.results.channel.item.condition.text),$(".wind-p").append("Wind speed: "+e.query.results.channel.wind.speed+" km/h"),e.query.results.channel.item.condition.text){case"Partly Cloudy":case"Mostly Clear":case"Mostly Sunny":case"Sunny":case"Fair":case"Clear":case"Partly Cloud":case"Cloudy":$("#sky-condition").toggleClass("blue-sky"),$("#weather-condition").toggleClass("good-weather");break;default:function t(){$("#sky-condition").toggleClass("grey-sky"),$("#weather-condition").toggleClass("bad-weather")}t()}var a=$("#weather-icon"),s=e.query.results.channel.item.condition.text;switch(s){case"Partly Cloud":case"Partly Cloudy":a.toggleClass("partly-cloudy");break;case"Sunny":case"Fair":case"Clear":case"Mostly Sunny":case"Mostly Clear":a.toggleClass("sun");break;case"Cloudy":case"Mostly Cloudy":a.toggleClass("clouds");break;case"Isolated Thunderstorms":case"Thundershowers":case"Heavy Thunderstorms":case"PM Thunderstorms":case"Light Rain with Thunder":case"Scattered Thunderstorms":a.toggleClass("thunder-storm");break;case"Rain":case"AM Rain":case"PM Rain":case"Showers":case"Heavy Rain":case"Light Rain":case"AM Showers":case"Scattered Showers":case"PM Showers":a.toggleClass("rain");break;default:console.log(s)}var o=!1,n=e.query.results.channel.item.condition.temp,i=function(e){return 1.8*e+32}(n).toFixed(1);$(".temp-button").click(function(e){!1===o?((e=$(".temp-p")).empty(),e.append("Temperature: "+i+" &deg;F"),o=!0):((e=$(".temp-p")).empty(),e.append("Temperature: "+n+" &deg;C"),o=!1)})})}function showLocation(e){showWeather(e)}$(document).ready(function(){$.getJSON("https://ipapi.co/json/",function(e){console.log(e),$(".city-p").append("Location : "+e.city+", "+e.country),showLocation(e)})});
function showWeather(e){$.getJSON("https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22"+e.city+"%2C%20"+e.countryCode+"%22)and%20u%3D'c'&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys",function(e){switch($(".temp-p").append("Temperature: "+e.query.results.channel.item.condition.temp+" &deg;C"),$(".visibility-p").append("Visibility: "+e.query.results.channel.atmosphere.visibility+" km"),$(".humidity-p").append("Humidity: "+e.query.results.channel.atmosphere.humidity+" %"),$(".weather-condition-p").append("Condition: "+e.query.results.channel.item.condition.text),$(".wind-p").append("Wind speed: "+e.query.results.channel.wind.speed+" km/h"),e.query.results.channel.item.condition.text){case"Partly Cloudy":case"Mostly Clear":case"Mostly Sunny":case"Sunny":case"Fair":case"Clear":case"Partly Cloud":case"Cloudy":$("#sky-condition").toggleClass("blue-sky"),$("#weather-condition").toggleClass("good-weather");break;default:function t(){$("#sky-condition").toggleClass("grey-sky"),$("#weather-condition").toggleClass("bad-weather")}t()}var s=$("#weather-icon"),a=e.query.results.channel.item.condition.text;switch(a){case"Partly Cloud":case"Partly Cloudy":s.toggleClass("partly-cloudy");break;case"Sunny":case"Fair":case"Clear":case"Mostly Sunny":case"Mostly Clear":s.toggleClass("sun");break;case"Cloudy":case"Mostly Cloudy":s.toggleClass("clouds");break;case"Isolated Thunderstorms":case"Thundershowers":case"Heavy Thunderstorms":case"PM Thunderstorms":case"Light Rain with Thunder":case"Scattered Thunderstorms":s.toggleClass("thunder-storm");break;case"Rain":case"AM Rain":case"PM Rain":case"Showers":case"Heavy Rain":case"Light Rain":case"AM Showers":case"Scattered Showers":case"PM Showers":s.toggleClass("rain");break;default:console.log(a)}var o=!1,n=e.query.results.channel.item.condition.temp,r=function(e){return 1.8*e+32}(n).toFixed(1);$(".temp-button").click(function(e){!1===o?((e=$(".temp-p")).empty(),e.append("Temperature: "+r+" &deg;F"),o=!0):((e=$(".temp-p")).empty(),e.append("Temperature: "+n+" &deg;C"),o=!1)})})}function showLocation(e){showWeather(e)}$(document).ready(function(){$.getJSON("https://freegeoip.net/json/",function(e){console.log(e),$(".city-p").append("Location : "+e.city+", "+e.country_code),showLocation(e)})});
Update repository 13/09/2017