From 99a21e4673f6de811f6676962046a026b7f57481 Mon Sep 17 00:00:00 2001 From: thaaoblues Date: Fri, 13 Sep 2024 14:13:42 +0200 Subject: [PATCH] bug fix --- bdd.php | 5 ++--- css/index.css | 23 ++++++++++++++++++++++- js/index.js | 48 ++++++++++++++++++++++++++++++++++-------------- 3 files changed, 58 insertions(+), 18 deletions(-) diff --git a/bdd.php b/bdd.php index 4908c00..82b07e7 100644 --- a/bdd.php +++ b/bdd.php @@ -348,12 +348,11 @@ function generer_chronologie(){ global $conn; // on va choper les 10 derniers trucs televerses par les gens - $sql = "SELECT * FROM ensembles WHERE valide=1 ORDER BY date_televersement DESC "; + $sql = "SELECT * FROM ensembles WHERE valide=1 ORDER BY date_televersement DESC LIMIT 10"; $res = $conn->execute_query($sql); - $i = 0; $ensembles = array(); - while (($ens = $res->fetch_assoc()) && $i < 10){ + while (($ens = $res->fetch_assoc())){ array_push($ensembles,$ens); diff --git a/css/index.css b/css/index.css index a11743d..2cd959a 100644 --- a/css/index.css +++ b/css/index.css @@ -144,7 +144,16 @@ height: auto; margin-bottom: 10px; border-radius: 7px; + } + +.card textarea{ + width: 100%; + height: auto; + margin-bottom: 10px; + border-radius: 7px; +} + .card embed{ width: 100%; height: 50vw; @@ -153,12 +162,14 @@ .card iframe { width: 100%; - height: 50vw; /* Ajuster la hauteur selon vos besoins */ + height: 50vw; + } .card video { width: 100%; height: auto; + } .card div { @@ -171,7 +182,17 @@ margin-bottom: 10px; } +.card a{ + width: fit-content; + grid-column: auto; +} +.ligne-boutons{ +} + +.ligne-boutons #lien{ + +} /* Styles pour les liens */ diff --git a/js/index.js b/js/index.js index a24f6c9..4defd8a 100644 --- a/js/index.js +++ b/js/index.js @@ -54,6 +54,9 @@ async function rechercher(){ titre_ensemble.setAttribute("onclick","document.location.href='ens.php?ensemble_id="+doc.ensemble_id.toString()+"'"); card.appendChild(titre_ensemble); + + const buttonsDiv = document.createElement("div"); + buttonsDiv.classList.add("ligne-boutons"); // fichiers spéciaux ? @@ -104,22 +107,27 @@ async function rechercher(){ text = xmlhttp.responseText; textarea.value = text; card.appendChild(textarea) + break; default: const unsupportedLink = document.createElement('a'); unsupportedLink.href = doc.upload_path; unsupportedLink.classList.add('lien'); unsupportedLink.textContent = 'Type de fichier non supporté.'; unsupportedLink.target = '_blank'; - card.appendChild(unsupportedLink); + buttonsDiv.appendChild(unsupportedLink); break; } const ele = document.createElement("a"); - ele.innerText = "Voir ce que c'est"; + ele.innerText = "Voir tous les pdf de cet ensemble"; ele.href = `ens.php?ensemble_id=${doc.ensemble_id}`; - ele.classList.add("lien") - card.appendChild(ele) + ele.classList.add("lien"); + + buttonsDiv.appendChild(ele); + + card.appendChild(buttonsDiv); + document.getElementById("liste_resultats").appendChild(card); @@ -142,10 +150,15 @@ async function gen_chronologie(){ // vide d'abord les éléments présents dans la liste sur la page document.getElementById("liste_resultats").innerHTML = ""; - // ensuite on ajoute un petit titre à la chronologie - let titre = document.createElement("h1"); - titre.innerText = "Documents récemment publiés"; - document.getElementById("liste_resultats").appendChild(titre); + if(data.resultats.length > 0){ + // ensuite on ajoute un petit titre à la chronologie + let titre = document.createElement("h1"); + titre.innerText = "Documents récemment publiés"; + document.getElementById("liste_resultats").appendChild(titre); + }else{ + + } + // et on remplis avec ce que l'api a généré if(data.status == 1){ @@ -163,6 +176,9 @@ async function gen_chronologie(){ titre_ensemble.setAttribute("onclick","document.location.href='ens.php?ensemble_id="+doc.ensemble_id.toString()+"'"); card.appendChild(titre_ensemble); + + const buttonsDiv = document.createElement("div"); + buttonsDiv.classList.add("ligne-boutons"); // fichiers spéciaux ? @@ -179,7 +195,7 @@ async function gen_chronologie(){ imageLink.classList.add('lien'); imageLink.textContent = 'Voir image'; imageLink.target = '_blank'; - card.appendChild(imageLink); + buttonsDiv.appendChild(imageLink); break; case 3: // pdf const embed = document.createElement('embed'); @@ -191,7 +207,7 @@ async function gen_chronologie(){ pdfLink.classList.add('lien'); pdfLink.textContent = 'Voir PDF en grand'; pdfLink.target = '_blank'; - card.appendChild(pdfLink); + buttonsDiv.appendChild(pdfLink); break; case 4: // video const video = document.createElement('video'); @@ -214,22 +230,26 @@ async function gen_chronologie(){ text = xmlhttp.responseText; textarea.value = text; card.appendChild(textarea) + break; default: const unsupportedLink = document.createElement('a'); unsupportedLink.href = doc.upload_path; unsupportedLink.classList.add('lien'); unsupportedLink.textContent = 'Type de fichier non supporté.'; unsupportedLink.target = '_blank'; - card.appendChild(unsupportedLink); + buttonsDiv.appendChild(unsupportedLink); break; } const ele = document.createElement("a"); - ele.innerText = "Voir ce que c'est"; + ele.innerText = "Voir tous les pdf de cet ensemble"; ele.href = `ens.php?ensemble_id=${doc.ensemble_id}`; - ele.classList.add("lien") - card.appendChild(ele) + ele.classList.add("lien"); + + buttonsDiv.appendChild(ele); + + card.appendChild(buttonsDiv); document.getElementById("liste_resultats").appendChild(card);