Removed Switch toDo sur weatherRequest
This commit is contained in:
parent
8d11d1b804
commit
1739942c61
@ -2,37 +2,26 @@
|
|||||||
/* Fonctions Principales */
|
/* Fonctions Principales */
|
||||||
|
|
||||||
// Requête à l'API openweathermap.org
|
// Requête à l'API openweathermap.org
|
||||||
function weatherRequest(url,toDo) {
|
function weatherRequest(url) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : url,
|
url : url,
|
||||||
dataType : "json",
|
dataType : "json",
|
||||||
success: function (json) {
|
success: function (json) {
|
||||||
let city = json.name;
|
let city = json.name;
|
||||||
let showDateTimeValue = timeZone(json);
|
let showDateTimeValue = timeZone(json);
|
||||||
switch (toDo) {
|
if(city === 'Moscou')
|
||||||
case 'time':
|
{
|
||||||
$('.results').html("La date et l'heure de " + city + " : " + showDateTimeValue);
|
$('.results').html(`🌎 Position : <a href='https://www.google.com/maps/place/${city}/' class="yellow-color" target="_blank">${city}, RU</a><br>⏰ Date et heure : ${showDateTimeValue}<br>☁️ Météo : ${capitalize(json.weather[0].description)}<br> 🌡️ Température : ${json.main.temp} °C<br> 💧 Humidité : ${json.main.humidity}% <br> <img src="https://openweathermap.org/img/wn/${json.weather[0].icon}@2x.png"/>`);
|
||||||
$("#cityName, #submitWeatherRequest").click(function() {
|
$("#cityName, #submitWeatherRequest").click(function() {
|
||||||
document.location.replace("../../views/function-views/weatherRequest.php");
|
document.location.replace("../../views/function-views/weatherRequest.php");
|
||||||
});
|
});
|
||||||
break;
|
}
|
||||||
case 'weather':
|
else
|
||||||
if(city === 'Moscou')
|
{
|
||||||
{
|
$('.results').html(`🌎 Position : <a href='https://www.google.com/maps/place/${city}/' class="yellow-color" target="_blank">${city}, ${json.sys.country}</a><br>⏰ Date et heure : ${showDateTimeValue}<br>☁️ Météo : ${capitalize(json.weather[0].description)}<br> 🌡️ Température : ${json.main.temp} °C<br> 💧 Humidité : ${json.main.humidity}% <br> <img src="https://openweathermap.org/img/wn/${json.weather[0].icon}@2x.png"/>`);
|
||||||
$('.results').html(`🌎 Position : <a href='https://www.google.com/maps/place/${city}/' class="yellow-color" target="_blank">${city}, RU</a><br>⏰ Date et heure : ${showDateTimeValue}<br>☁️ Météo : ${capitalize(json.weather[0].description)}<br> 🌡️ Température : ${json.main.temp} °C<br> 💧 Humidité : ${json.main.humidity}% <br> <img src="https://openweathermap.org/img/wn/${json.weather[0].icon}@2x.png"/>`);
|
$("#cityName, #submitWeatherRequest").click(function() {
|
||||||
$("#cityName, #submitWeatherRequest").click(function() {
|
document.location.replace("../../views/function-views/weatherRequest.php");
|
||||||
document.location.replace("../../views/function-views/weatherRequest.php");
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$('.results').html(`🌎 Position : <a href='https://www.google.com/maps/place/${city}/' class="yellow-color" target="_blank">${city}, ${json.sys.country}</a><br>⏰ Date et heure : ${showDateTimeValue}<br>☁️ Météo : ${capitalize(json.weather[0].description)}<br> 🌡️ Température : ${json.main.temp} °C<br> 💧 Humidité : ${json.main.humidity}% <br> <img src="https://openweathermap.org/img/wn/${json.weather[0].icon}@2x.png"/>`);
|
|
||||||
$("#cityName, #submitWeatherRequest").click(function() {
|
|
||||||
document.location.replace("../../views/function-views/weatherRequest.php");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
statusCode: {
|
statusCode: {
|
||||||
|
@ -22,7 +22,7 @@ $(function () {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
let url = "https://api.openweathermap.org/data/2.5/weather?q=" + cityName + "&lang=fr&units=metric&appid=" + config.APIkeyWeather + "";
|
let url = "https://api.openweathermap.org/data/2.5/weather?q=" + cityName + "&lang=fr&units=metric&appid=" + config.APIkeyWeather + "";
|
||||||
weatherRequest(url, 'weather');
|
weatherRequest(url);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user