feat(dl): page de téléchargements avec liens modifiables et copie

This commit is contained in:
2026-05-28 18:14:54 +02:00
parent e315b511ee
commit bca5626096
3 changed files with 198 additions and 0 deletions
+73
View File
@@ -0,0 +1,73 @@
document.addEventListener("DOMContentLoaded", () => {
const cards = Array.from(document.querySelectorAll(".download-card"));
function toast(message) {
const t = document.createElement("div");
t.className = "dl-toast";
t.textContent = message;
Object.assign(t.style, {
position: "fixed",
right: "1rem",
bottom: "1rem",
background: "rgba(2,6,23,0.9)",
color: "#fff",
padding: "0.6rem 0.9rem",
borderRadius: "6px",
boxShadow: "0 6px 20px rgba(2,6,23,0.5)",
zIndex: 9999,
});
document.body.appendChild(t);
setTimeout(() => t.remove(), 2200);
}
cards.forEach((card) => {
const key = `fws:download:${card.dataset.key}`;
const btn = card.querySelector(".download-btn");
const copyBtn = card.querySelector(".copy-btn");
const editBtn = card.querySelector(".edit-btn");
function setLink(url) {
if (!url) url = "#";
btn.href = url;
btn.dataset.link = url;
copyBtn.dataset.link = url;
localStorage.setItem(key, url);
}
const stored = localStorage.getItem(key);
if (stored) {
setLink(stored);
}
editBtn.addEventListener("click", () => {
const current = localStorage.getItem(key) || "";
const value = window.prompt("Collez l'URL de téléchargement pour ce fichier:", current);
if (value === null) return;
const trimmed = value.trim();
setLink(trimmed);
toast("Lien enregistré");
});
copyBtn.addEventListener("click", async () => {
const link = copyBtn.dataset.link || btn.href || "";
if (!link || link === "#") {
toast("Aucun lien défini — utilisez 'Modifier le lien'");
return;
}
try {
await navigator.clipboard.writeText(link);
toast("Lien copié dans le presse-papiers");
} catch (e) {
window.prompt("Copiez manuellement ce lien:", link);
}
});
btn.addEventListener("click", (ev) => {
const href = btn.getAttribute("href") || "";
if (!href || href === "#") {
ev.preventDefault();
toast("Aucun lien configuré — cliquez sur 'Modifier le lien' pour en ajouter un");
}
});
});
});
+37
View File
@@ -259,6 +259,43 @@ main[data-page-content] {
line-height: 1.65;
}
/* Styles page Téléchargements */
.downloads {
margin-top: 1.5rem;
}
.downloads-header h1 { margin: 0 0 0.35rem; }
.download-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 1rem;
margin-top: 1rem;
}
.download-card {
display: flex;
gap: 1rem;
align-items: stretch;
padding: 0.8rem;
border-radius: 0.75rem;
background: rgba(255,255,255,0.02);
border: 1px solid rgba(148,163,184,0.06);
}
.download-media { width: 220px; flex: 0 0 220px; overflow: hidden; border-radius: 0.5rem; }
.download-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.download-body { flex: 1 1 auto; display: flex; flex-direction: column; gap: 0.6rem; }
.download-actions { display: flex; gap: 0.6rem; margin-top: auto; }
@media (max-width: 880px) {
.download-grid { grid-template-columns: 1fr; }
.download-media { width: 140px; flex-basis: 140px; }
}
.features .card {
flex: 1 1 0;
min-width: 0;