This commit is contained in:
thaaoblues 2024-09-13 14:13:42 +02:00
parent bc93ef40ed
commit 99a21e4673
3 changed files with 58 additions and 18 deletions

View file

@ -348,12 +348,11 @@ function generer_chronologie(){
global $conn; global $conn;
// on va choper les 10 derniers trucs televerses par les gens // 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); $res = $conn->execute_query($sql);
$i = 0;
$ensembles = array(); $ensembles = array();
while (($ens = $res->fetch_assoc()) && $i < 10){ while (($ens = $res->fetch_assoc())){
array_push($ensembles,$ens); array_push($ensembles,$ens);

View file

@ -144,7 +144,16 @@
height: auto; height: auto;
margin-bottom: 10px; margin-bottom: 10px;
border-radius: 7px; border-radius: 7px;
} }
.card textarea{
width: 100%;
height: auto;
margin-bottom: 10px;
border-radius: 7px;
}
.card embed{ .card embed{
width: 100%; width: 100%;
height: 50vw; height: 50vw;
@ -153,12 +162,14 @@
.card iframe { .card iframe {
width: 100%; width: 100%;
height: 50vw; /* Ajuster la hauteur selon vos besoins */ height: 50vw;
} }
.card video { .card video {
width: 100%; width: 100%;
height: auto; height: auto;
} }
.card div { .card div {
@ -171,7 +182,17 @@
margin-bottom: 10px; margin-bottom: 10px;
} }
.card a{
width: fit-content;
grid-column: auto;
}
.ligne-boutons{
}
.ligne-boutons #lien{
}
/* Styles pour les liens */ /* Styles pour les liens */

View file

@ -54,6 +54,9 @@ async function rechercher(){
titre_ensemble.setAttribute("onclick","document.location.href='ens.php?ensemble_id="+doc.ensemble_id.toString()+"'"); titre_ensemble.setAttribute("onclick","document.location.href='ens.php?ensemble_id="+doc.ensemble_id.toString()+"'");
card.appendChild(titre_ensemble); card.appendChild(titre_ensemble);
const buttonsDiv = document.createElement("div");
buttonsDiv.classList.add("ligne-boutons");
// fichiers spéciaux ? // fichiers spéciaux ?
@ -104,22 +107,27 @@ async function rechercher(){
text = xmlhttp.responseText; text = xmlhttp.responseText;
textarea.value = text; textarea.value = text;
card.appendChild(textarea) card.appendChild(textarea)
break;
default: default:
const unsupportedLink = document.createElement('a'); const unsupportedLink = document.createElement('a');
unsupportedLink.href = doc.upload_path; unsupportedLink.href = doc.upload_path;
unsupportedLink.classList.add('lien'); unsupportedLink.classList.add('lien');
unsupportedLink.textContent = 'Type de fichier non supporté.'; unsupportedLink.textContent = 'Type de fichier non supporté.';
unsupportedLink.target = '_blank'; unsupportedLink.target = '_blank';
card.appendChild(unsupportedLink); buttonsDiv.appendChild(unsupportedLink);
break; break;
} }
const ele = document.createElement("a"); 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.href = `ens.php?ensemble_id=${doc.ensemble_id}`;
ele.classList.add("lien") ele.classList.add("lien");
card.appendChild(ele)
buttonsDiv.appendChild(ele);
card.appendChild(buttonsDiv);
document.getElementById("liste_resultats").appendChild(card); 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 // vide d'abord les éléments présents dans la liste sur la page
document.getElementById("liste_resultats").innerHTML = ""; document.getElementById("liste_resultats").innerHTML = "";
// ensuite on ajoute un petit titre à la chronologie if(data.resultats.length > 0){
let titre = document.createElement("h1"); // ensuite on ajoute un petit titre à la chronologie
titre.innerText = "Documents récemment publiés"; let titre = document.createElement("h1");
document.getElementById("liste_resultats").appendChild(titre); 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é // et on remplis avec ce que l'api a généré
if(data.status == 1){ 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()+"'"); titre_ensemble.setAttribute("onclick","document.location.href='ens.php?ensemble_id="+doc.ensemble_id.toString()+"'");
card.appendChild(titre_ensemble); card.appendChild(titre_ensemble);
const buttonsDiv = document.createElement("div");
buttonsDiv.classList.add("ligne-boutons");
// fichiers spéciaux ? // fichiers spéciaux ?
@ -179,7 +195,7 @@ async function gen_chronologie(){
imageLink.classList.add('lien'); imageLink.classList.add('lien');
imageLink.textContent = 'Voir image'; imageLink.textContent = 'Voir image';
imageLink.target = '_blank'; imageLink.target = '_blank';
card.appendChild(imageLink); buttonsDiv.appendChild(imageLink);
break; break;
case 3: // pdf case 3: // pdf
const embed = document.createElement('embed'); const embed = document.createElement('embed');
@ -191,7 +207,7 @@ async function gen_chronologie(){
pdfLink.classList.add('lien'); pdfLink.classList.add('lien');
pdfLink.textContent = 'Voir PDF en grand'; pdfLink.textContent = 'Voir PDF en grand';
pdfLink.target = '_blank'; pdfLink.target = '_blank';
card.appendChild(pdfLink); buttonsDiv.appendChild(pdfLink);
break; break;
case 4: // video case 4: // video
const video = document.createElement('video'); const video = document.createElement('video');
@ -214,22 +230,26 @@ async function gen_chronologie(){
text = xmlhttp.responseText; text = xmlhttp.responseText;
textarea.value = text; textarea.value = text;
card.appendChild(textarea) card.appendChild(textarea)
break;
default: default:
const unsupportedLink = document.createElement('a'); const unsupportedLink = document.createElement('a');
unsupportedLink.href = doc.upload_path; unsupportedLink.href = doc.upload_path;
unsupportedLink.classList.add('lien'); unsupportedLink.classList.add('lien');
unsupportedLink.textContent = 'Type de fichier non supporté.'; unsupportedLink.textContent = 'Type de fichier non supporté.';
unsupportedLink.target = '_blank'; unsupportedLink.target = '_blank';
card.appendChild(unsupportedLink); buttonsDiv.appendChild(unsupportedLink);
break; break;
} }
const ele = document.createElement("a"); 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.href = `ens.php?ensemble_id=${doc.ensemble_id}`;
ele.classList.add("lien") ele.classList.add("lien");
card.appendChild(ele)
buttonsDiv.appendChild(ele);
card.appendChild(buttonsDiv);
document.getElementById("liste_resultats").appendChild(card); document.getElementById("liste_resultats").appendChild(card);