Loading js/interface.js +11 −0 Original line number Diff line number Diff line Loading @@ -6,9 +6,16 @@ const boutonRechercheCodePostal = document.getElementById("recherche"); const listeDeroulanteVilles = document.getElementById("villeListe"); const checkboxLocalisation = document.getElementById("localisation"); onLocalisation(); const checkboxNiveauDePluie = document.getElementById("niveau_pluie"); onNiveauDePluie(); const checkboxVentMoyen = document.getElementById("vent_moyen"); onVentMoyen(); const checkboxDirectionDuVent = document.getElementById("direction_vent"); onDirectionvent(); console.log(typeof(checkboxLocalisation)) Loading @@ -32,6 +39,10 @@ const labelTemperatureMin = document.getElementById("WCTemperatureMin"); const labelTemperatureMax = document.getElementById("WCTemperatureMax"); const labelPluie = document.getElementById("WCPluie"); // Probabilité de pluie const labelEnsoleillement = document.getElementById("WCEnsoleillement"); // Nombres d'heures d'ensoleillement const labelLocalisation = document.getElementById("WCLocalisation"); // emplacement géographique de la region const labelNiveauDePluie = document.getElementById("WCNiveauPluie"); // niveau de pluie const labelVentMoyen = document.getElementById("WCVentMoyen"); // la force du vent const labelDirectionDuVent = document.getElementById("WCDirectionVent"); // la direction du vent let villes_insee = new Map(); Loading js/script.js 0 → 100644 +51 −0 Original line number Diff line number Diff line const barreRechercheCodePostal = document.getElementById("codePostalInput"); const boutonRechercheCodePostal = document.getElementById("recherche"); let villes = []; boutonRechercheCodePostal.addEventListener("click", onRechercher); function onRechercher(){ let valeurS = barreRechercheCodePostal.value; let valeurN = Number.parseInt(valeurS); console.log(valeurS.length); if(isNaN(valeurN)){ onErreurDeSaisie("Le code postal contient des caractères non numériques."); return; } if(valeurS.length != 5){ onErreurDeSaisie("Le code postal doit contenir 5 caractères."); return; } } function onErreurDeSaisie(message){ alert(message); } const setVilles = async codepostal => { return fetch("https://geo.api.gouv.fr/communes?codePostal="+codepostal) .then(res =>{ if(!res.ok){ throw new Error("gofuckyourself") } return res.json(); }) .then(data =>{ villes = []; for(i = 0; i < data.length; i++){ villes[i] = data[i].nom; } }) } const getVilles = () => { return villes; } setVilles(14000).then(() => { //la manip que vous voulez faire }) No newline at end of file Loading
js/interface.js +11 −0 Original line number Diff line number Diff line Loading @@ -6,9 +6,16 @@ const boutonRechercheCodePostal = document.getElementById("recherche"); const listeDeroulanteVilles = document.getElementById("villeListe"); const checkboxLocalisation = document.getElementById("localisation"); onLocalisation(); const checkboxNiveauDePluie = document.getElementById("niveau_pluie"); onNiveauDePluie(); const checkboxVentMoyen = document.getElementById("vent_moyen"); onVentMoyen(); const checkboxDirectionDuVent = document.getElementById("direction_vent"); onDirectionvent(); console.log(typeof(checkboxLocalisation)) Loading @@ -32,6 +39,10 @@ const labelTemperatureMin = document.getElementById("WCTemperatureMin"); const labelTemperatureMax = document.getElementById("WCTemperatureMax"); const labelPluie = document.getElementById("WCPluie"); // Probabilité de pluie const labelEnsoleillement = document.getElementById("WCEnsoleillement"); // Nombres d'heures d'ensoleillement const labelLocalisation = document.getElementById("WCLocalisation"); // emplacement géographique de la region const labelNiveauDePluie = document.getElementById("WCNiveauPluie"); // niveau de pluie const labelVentMoyen = document.getElementById("WCVentMoyen"); // la force du vent const labelDirectionDuVent = document.getElementById("WCDirectionVent"); // la direction du vent let villes_insee = new Map(); Loading
js/script.js 0 → 100644 +51 −0 Original line number Diff line number Diff line const barreRechercheCodePostal = document.getElementById("codePostalInput"); const boutonRechercheCodePostal = document.getElementById("recherche"); let villes = []; boutonRechercheCodePostal.addEventListener("click", onRechercher); function onRechercher(){ let valeurS = barreRechercheCodePostal.value; let valeurN = Number.parseInt(valeurS); console.log(valeurS.length); if(isNaN(valeurN)){ onErreurDeSaisie("Le code postal contient des caractères non numériques."); return; } if(valeurS.length != 5){ onErreurDeSaisie("Le code postal doit contenir 5 caractères."); return; } } function onErreurDeSaisie(message){ alert(message); } const setVilles = async codepostal => { return fetch("https://geo.api.gouv.fr/communes?codePostal="+codepostal) .then(res =>{ if(!res.ok){ throw new Error("gofuckyourself") } return res.json(); }) .then(data =>{ villes = []; for(i = 0; i < data.length; i++){ villes[i] = data[i].nom; } }) } const getVilles = () => { return villes; } setVilles(14000).then(() => { //la manip que vous voulez faire }) No newline at end of file