From 0b77dedc1c7b0e0e0b7cfad3a018c57293a15624 Mon Sep 17 00:00:00 2001 From: HediMjid Date: Wed, 20 Oct 2021 12:25:27 +0200 Subject: [PATCH] modif des js --- scripts/films.js | 4 +-- scripts/people.js | 8 ++--- scripts/planetes.js | 78 +++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 81 insertions(+), 9 deletions(-) diff --git a/scripts/films.js b/scripts/films.js index b0a4314..821c89c 100644 --- a/scripts/films.js +++ b/scripts/films.js @@ -55,12 +55,12 @@ async function getMovies() {
- +
- +
diff --git a/scripts/people.js b/scripts/people.js index 00b6942..ce102d3 100644 --- a/scripts/people.js +++ b/scripts/people.js @@ -55,7 +55,7 @@ class People {

${this.gender}

- +
@@ -70,9 +70,6 @@ async function getPeople() { const total_pages = people.count/people.results.length; tableau_perso = []; - - - // on vide le div document.getElementById('container').innerHTML = ""; @@ -197,7 +194,8 @@ function searchPeople() { const accordion = document.getElementsByClassName('etendre'); for (i=0; i${POPULATION}

- +
- +
`; + + tableau_perso.push({name:PLANET_NAME,rotation:ROTATION_PERIOD,orbital:ORBITAL_PERIOD,diameter:DIAMETER,climate:CLIMATE,gravity:GRAVITY,terrain:TERRAIN,surface:SURFACE_WATER,population:POPULATION}); } const BUTTONS_FILMS = document.querySelectorAll('.films'); for(var i = 0;i < BUTTONS_FILMS.length;i++){ @@ -183,5 +187,75 @@ fetch(API_URL) }}); +document.getElementById('myInput').addEventListener("keyup", function() { + searchPeople(); +}); + +function searchPeople() { + // Declare variables + let query = myInput.value; + // if(query.length>1){ + // getSearch(query); + // }else{ + // getPeople(); + // } + //console.log(tableau_perso); + let results = tableau_perso.filter(user=>user.name.includes(query)); + console.log(results); + document.getElementById('container').innerHTML = ""; + for(i=0;i +

${results[i].name}

+ +
+
+

Rotation :

+

${results[i].rotation}

+
+
+

ORBITAL :

+

${results[i].orbital}

+
+
+

Diameter :

+

${results[i].diameter}

+
+
+

Climate :

+

${results[i].climate}

+
+
+

Gravity :

+

${results[i].gravity}

+
+
+

Terrain :

+

${results[i].terrain}

+
+
+

Surface water :

+

${results[i].surface}

+
+
+

Population :

${results[i].population}

+
+ +
+ + + `; + + const accordion = document.getElementsByClassName('etendre'); + for (i=0; i