diff --git a/css/main.css b/css/main.css index 721e8d3..e9d80b7 100644 --- a/css/main.css +++ b/css/main.css @@ -16,4 +16,8 @@ #why-next-min-info { color: #007bff; cursor: pointer; +} + +.hover-pointer { + cursor: pointer; } \ No newline at end of file diff --git a/index.html b/index.html index 37e5f7e..3a3d12f 100644 --- a/index.html +++ b/index.html @@ -29,11 +29,18 @@

Simple Weather Overlay

City
- + +
+ + + + + +
Country
-
@@ -150,5 +157,6 @@ integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"> + diff --git a/js/GeoPosition.js b/js/GeoPosition.js new file mode 100644 index 0000000..d3d3392 --- /dev/null +++ b/js/GeoPosition.js @@ -0,0 +1,11 @@ +function ShowPositionValues(position){ + let pos = position.coords; + console.log("lat: " + pos.latitude); + console.log("long: " + pos.longitude); + $(".place_field").attr("disabled", true); + $("#city_input").val("Using geolocation info"); +} + +function GetPosition(){ + navigator.geolocation.getCurrentPosition(ShowPositionValues); +} \ No newline at end of file diff --git a/js/OpenWeather.js b/js/OpenWeather.js index 172cdc6..693513a 100644 --- a/js/OpenWeather.js +++ b/js/OpenWeather.js @@ -41,17 +41,32 @@ $(document).ready(function(){ var tempMin; var tempMax; var midday = GetMidday(); + if (parameters.lat != null){ + placeCoordinates.lat = parameters.lat; + placeCoordinates.lon = parameters.lon; + } function PlaceData() { - $.ajax({ - url: "https://api.openweathermap.org/data/2.5/weather", - data: { + let params = {}; + if (placeCoordinates.lat != null){ + params = { + "lat": placeCoordinates.lat, + "lon": placeCoordinates.lon, + "appid": API_key + } + } + else{ + params = { "q": place, "APPID": API_key, "units": units, "lang": lang - }, + } + } + $.ajax({ + url: "https://api.openweathermap.org/data/2.5/weather", + data: params, type: "GET", dataType: "json" })