From ea269654e3d08e9529c3042cd27eb8b977fae712 Mon Sep 17 00:00:00 2001 From: joniboy74prog Date: Fri, 8 Dec 2023 04:29:35 +0100 Subject: [PATCH] =?UTF-8?q?enlever=20les=20grosses=20usines=20=C3=A0=20gaz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/fonctions.js | 39 +-------------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/back/fonctions.js b/back/fonctions.js index 8de8c21..fc09671 100644 --- a/back/fonctions.js +++ b/back/fonctions.js @@ -155,44 +155,7 @@ function getImg2(categorie, indice){ // function for random index of a function -async function getQuestionByCategorie2(category) { - try { - const response = await fetch(`./${category}.json`); - - if (!response.ok) { - throw new Error(`Erreur de chargement du fichier JSON : ${response.status}`); - } - - const objetJson = await response.json(); - const questions = objetJson.questions; - - console.log(questions); - return questions; - - } catch (error) { - console.error('Erreur lors du chargement du fichier JSON :', error.message); - alert('Erreur lors du chargement du fichier JSON. Consultez la console pour les détails.'); - throw error; // Re-throw the error for further handling - } - } - - - console.log(getQuestionByCategorie2("transport")) - - function shuffleArray(array) { - const shuffledArray = [...array]; - for (let i = shuffledArray.length - 1; i > 0; i--) { - const j = Math.floor(Math.random() * (i + 1)); - [shuffledArray[i], shuffledArray[j]] = [shuffledArray[j], shuffledArray[i]]; - } - return shuffledArray; - } - - function createShuffledIndicesArray(array) { - const indicesArray = Array.from({ length: array.length }, (_, index) => index); - return shuffleArray(indicesArray); - } - + function getNextIndex(indicesArray) { if (indicesArray.length === 0) { // Si tous les indices ont été utilisés, réinitialiser le tableau d'indices