From 438c3ba8b23bf4dede88cd7df95454cd847a19b0 Mon Sep 17 00:00:00 2001 From: HediMjid Date: Wed, 20 Oct 2021 11:35:52 +0200 Subject: [PATCH] js accordeon --- scripts/films.js | 68 ++++++++++++++++++-------------- scripts/people.js | 94 +++++++++++++++++++++++++++------------------ scripts/planetes.js | 84 ++++++++++++++++++++++------------------ 3 files changed, 142 insertions(+), 104 deletions(-) diff --git a/scripts/films.js b/scripts/films.js index cc162f3..b0a4314 100644 --- a/scripts/films.js +++ b/scripts/films.js @@ -27,41 +27,42 @@ async function getMovies() { // Boucle pour parser les films document.getElementById('container').innerHTML += `
-

${TITRE}

+

${TITRE}

+ +
+
+

Episode ID :

+

${EPISODE}

+
-
-

Episode ID :

-

${EPISODE}

-
+
+

Opening Crawl :

+

${OPENING}

+
-
-

Opening Crawl :

-

${OPENING}

-
+
+

Director :

+

${DIRECTOR}

+
-
-

Director :

-

${DIRECTOR}

-
+
+

Producer(s) :

+

${PRODUCER}

+
-
-

Producer(s) :

-

${PRODUCER}

-
+
+

Release Date :

+

${DATE}

+
-
-

Release Date :

-

${DATE}

-
+
+ +
+
-
- -
-
- -
- -
+
+ +
+
`; @@ -84,6 +85,15 @@ async function getMovies() { getSpecies(BUTTON1.value,BUTTON1.nextElementSibling.id); }); } + + const accordion = document.getElementsByClassName('etendre'); + for (i=0; i -

Name : ${this.name}

+ +

${this.name}

+

Né sur :

@@ -67,6 +68,10 @@ async function getPeople() { const peoples = await fetch(API_URL+pageEnCours); const people = await peoples.json(); const total_pages = people.count/people.results.length; + tableau_perso = []; + + + // on vide le div document.getElementById('container').innerHTML = ""; @@ -88,6 +93,7 @@ async function getPeople() { // console.log(film.title); // movies += `

${film.title}

`; // } + tableau_perso.push({name:people.results[i].name,height:people.results[i].height,mass:people.results[i].mass,hair_color:people.results[i].hair_color,skin_color:people.results[i].skin_color,eye_color:people.results[i].eye_color,birth_year:people.results[i].birth_year,gender:people.results[i].gender,homeworld:planet.name,index:i,films:people.results[i].films}); const perso = new People(people.results[i].name,people.results[i].height,people.results[i].mass,people.results[i].hair_color,people.results[i].skin_color,people.results[i].eye_color,people.results[i].birth_year,people.results[i].gender,planet.name,i,people.results[i].films); perso.affichePeople(); } @@ -102,11 +108,13 @@ async function getPeople() { const accordion = document.getElementsByClassName('etendre'); for (i=0; i1){ - getSearch(query); - }else{ - getPeople(); - } - - //let result = array.filter(user=>user.name.includes(query)); - //console.log(result); - // document.getElementById('container').innerHTML = ""; - // for(i=0;i${result[i].name}

`; + // if(query.length>1){ + // getSearch(query); + // }else{ + // getPeople(); // } - } - - -async function getSearch(query) { + //console.log(tableau_perso); + let results = tableau_perso.filter(user=>user.name.includes(query)); + //console.log(result); document.getElementById('container').innerHTML = ""; - const searchs = await fetch("https://swapi.dev/api/people/?search="+query); - const search = await searchs.json(); - console.log(search); - for(i=0;i${result[i].name}

`; + const perso = new People(results[i].name,results[i].height,results[i].mass,results[i].hair_color,results[i].skin_color,results[i].eye_color,results[i].birth_year,results[i].gender,results[i].homeworld,i,results[i].films); + perso.affichePeople(); const accordion = document.getElementsByClassName('etendre'); for (i=0; i -

${PLANET_NAME}

-
-

Rotation :

-

${ROTATION_PERIOD}

-
-
-

ORBITAL :

-

${ORBITAL_PERIOD}

+

${PLANET_NAME}

+ +
+
+

Rotation :

+

${ROTATION_PERIOD}

-
-

Diameter :

-

${DIAMETER}

+
+

ORBITAL :

+

${ORBITAL_PERIOD}

+
+
+

Diameter :

+

${DIAMETER}

+
+
+

Climate :

+

${CLIMATE}

+
+
+

Gravity :

+

${GRAVITY}

+
+
+

Terrain :

+

${TERRAIN}

+
+
+

Surface water :

+

${SURFACE_WATER}

+
+
+

Population :

${POPULATION}

+
+
+ +
-
-

Climate :

-

${CLIMATE}

+
+ +
-
-

Gravity :

-

${GRAVITY}

-
-
-

Terrain :

-

${TERRAIN}

-
-
-

Surface water :

-

${SURFACE_WATER}

-
-
-

Population :

${POPULATION}

-
-
- -
-
-
- -
@@ -91,6 +93,14 @@ async function getPlanets() { }); } + const accordion = document.getElementsByClassName('etendre'); + for (i=0; i