refonte arborescence + correction des chemins
This commit is contained in:
58
prestations/js/voir_avant_apres.js
Normal file
58
prestations/js/voir_avant_apres.js
Normal file
@@ -0,0 +1,58 @@
|
||||
// ===============================
|
||||
// Données simulées (à remplacer plus tard par BDD / API)
|
||||
// ===============================
|
||||
let galleryPairs = [
|
||||
{
|
||||
id: 1,
|
||||
titre: "Petit chien poils longs",
|
||||
type: "Chien",
|
||||
avant: "../../img/avant1.jpg",
|
||||
apres: "../../img/apres1.jpg"
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
titre: "Coupe ciseaux",
|
||||
type: "Chat",
|
||||
avant: "../../img/avant2.jpg",
|
||||
apres: "../../img/apres2.jpg"
|
||||
}
|
||||
];
|
||||
|
||||
// Sélecteurs
|
||||
const titleEl = document.getElementById("pairTitle");
|
||||
const beforePreview = document.getElementById("beforePreview");
|
||||
const afterPreview = document.getElementById("afterPreview");
|
||||
const errorMsg = document.getElementById("errorMsg");
|
||||
const detailsSection = document.getElementById("detailsSection");
|
||||
|
||||
// ===============================
|
||||
// Récup ID dans l'URL
|
||||
// ===============================
|
||||
function getIdFromUrl() {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
return parseInt(params.get("id"));
|
||||
}
|
||||
|
||||
// ===============================
|
||||
// Charger les infos de la paire
|
||||
// ===============================
|
||||
function loadPairDetails() {
|
||||
const id = getIdFromUrl();
|
||||
const pair = galleryPairs.find(p => p.id === id);
|
||||
|
||||
if (!pair) {
|
||||
errorMsg.classList.remove("d-none");
|
||||
detailsSection.classList.add("d-none");
|
||||
return;
|
||||
}
|
||||
|
||||
// Affichage du titre
|
||||
titleEl.textContent = pair.titre;
|
||||
|
||||
// Affichage des images
|
||||
beforePreview.src = pair.avant;
|
||||
afterPreview.src = pair.apres;
|
||||
}
|
||||
|
||||
// Initialisation
|
||||
loadPairDetails();
|
||||
Reference in New Issue
Block a user