(prompt, index, imageUrl)
| 305 | // ── Cards ──────────────────────────────────────────────────────────────────── |
| 306 | |
| 307 | function createMemeCard(prompt, index, imageUrl) { |
| 308 | const safeUrl = sanitizeUrl(imageUrl); |
| 309 | if (!safeUrl) return null; |
| 310 | |
| 311 | const card = document.createElement("div"); |
| 312 | card.className = "example-card"; |
| 313 | card.style.animationDelay = `${index * 0.1}s`; |
| 314 | |
| 315 | const img = document.createElement("img"); |
| 316 | img.src = safeUrl; |
| 317 | img.alt = prompt; |
| 318 | img.loading = "lazy"; |
| 319 | card.appendChild(img); |
| 320 | |
| 321 | const p = document.createElement("p"); |
| 322 | p.textContent = `"${prompt}"`; |
| 323 | card.appendChild(p); |
| 324 | |
| 325 | card.addEventListener("click", () => { |
| 326 | dom.userInput.value = prompt; |
| 327 | updateGenerateButtonState(); |
| 328 | scrollToGenerator(); |
| 329 | dom.userInput.focus(); |
| 330 | notify("Prompt loaded! Hit Generate 🎨"); |
| 331 | }); |
| 332 | |
| 333 | return card; |
| 334 | } |
| 335 | |
| 336 | function loadUserMemes() { |
| 337 | dom.yourMemesGrid.innerHTML = ""; |
no test coverage detected