Commit d4c2a501 authored by Victor friboulet's avatar Victor friboulet
Browse files

update des noms pour les mettre en français

parent 66f7e4fb
Loading
Loading
Loading
Loading
+18 −18
Original line number Diff line number Diff line
// Description: Classe WeatherCard
class WeatherCard{
    json;
    city;
    forecast;
    ville;
    prevision;
    constructor(CodeInsee) {
        this.CodeInsee = CodeInsee;
        this.json = null;
        this.city = null;
        this.forecast = null;
        this.ville = null;
        this.prevision = null;
    }

    async fetchData(jour) {
    async remplir(jour) {
        try {
            // Utilisez "await" pour attendre la réponse de la requête
            const response = await fetch(
@@ -23,8 +23,8 @@ class WeatherCard{
            // Parsez la réponse en JSON
            const data = await response.json();
            this.json = data;
            this.city = data.city;
            this.forecast = data.forecast;
            this.ville = data.city;
            this.prevision = data.forecast;

            /**
            console.log(this.json);
@@ -40,29 +40,29 @@ class WeatherCard{
        return this.json;
    }
    Ville(){
        return this.city["name"];
        return this.ville["name"];
    }
    probarain(){
        return this.forecast.probarain;
    pourcentPluie(){
        return this.prevision.probarain;
    }
    latitudeVille(){
        return this.city.latitude;
        return this.ville.latitude;
    }
    longitudeVille(){
        return this.city.longitude;
        return this.ville.longitude;
    }
    TempMin(){
        return this.forecast.tmin;
        return this.prevision.tmin;
    }
    TempMax(){
        return this.forecast.tmax;
        return this.prevision.tmax;
    }
    Sunhour(){
        return this.forecast.sun_hours;
    ensoleillement(){
        return this.prevision.sun_hours;
    }

    determineWeather(){
        let weather=this.forecast.weather;
    meteo(){
        let weather=this.prevision.weather;
        if (weather<0){
            return Error;
        }
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ let titre = document.getElementById("instantWeather")
let fond = document.getElementById("fond")

function actualiserArrierePlan(weatherCard){
    let typetemps = weatherCard.determineWeather()//methode Victor
    let typetemps = weatherCard.meteo()//methode Victor
    console.log(typetemps);
    if(typetemps == 'soleil'){
        fond.style.background = 'url("../image/theme_clair.jpg") no-repeat fixed'
+4 −6
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ function onSelectionneVille(){
    }

    const weatherCard = new WeatherCard(codeInsee);
    weatherCard.fetchData(0).then(() =>{
    weatherCard.remplir(0).then(() =>{
        afficherMeteo(weatherCard);
    })
}
@@ -86,16 +86,14 @@ function onSelectionneVille(){
function afficherMeteo(weatherCard){
    labelVille.textContent = weatherCard.Ville();
    
    //TODO remplir cette ligne
    //labelBref.textContent = "ensoleillé";
    labelBref.textContent = "Temps :" + weatherCard.meteo();
    
    labelTemperatureMin.textContent = `${weatherCard.TempMin()} °C`;
    labelTemperatureMax.textContent = `${weatherCard.TempMax()} °C`;

    //TODO probabilité de pluie
    // labelPluie.textContent = weatherCard.;
    labelPluie.textContent = weatherCard.pourcentPluie() + "%";
    
    labelEnsoleillement.textContent =  `${weatherCard.Sunhour()} heures`;
    labelEnsoleillement.textContent =  `${weatherCard.ensoleillement()} heures`;

    actualiserArrierePlan(weatherCard);