()
| 34 | } |
| 35 | |
| 36 | function fallbackCopy() { |
| 37 | try { |
| 38 | const textArea = document.createElement("textarea"); |
| 39 | textArea.value = text; |
| 40 | textArea.style.position = "fixed"; |
| 41 | textArea.style.left = "-9999px"; |
| 42 | textArea.style.top = "-9999px"; |
| 43 | document.body.appendChild(textArea); |
| 44 | textArea.focus(); |
| 45 | textArea.select(); |
| 46 | |
| 47 | const successful = document.execCommand("copy"); |
| 48 | document.body.removeChild(textArea); |
| 49 | |
| 50 | if (successful) { |
| 51 | showSuccessMessage(); |
| 52 | console.log("Copied to clipboard (fallback):", text); |
| 53 | } else { |
| 54 | console.error("Failed to copy text with fallback method"); |
| 55 | if (button) { |
| 56 | button.textContent = "✗ Failed"; |
| 57 | button.style.color = "red"; |
| 58 | setTimeout(() => { |
| 59 | button.textContent = button.getAttribute("title") || "Copy"; |
| 60 | button.style.color = ""; |
| 61 | }, 1500); |
| 62 | } |
| 63 | } |
| 64 | } catch (err) { |
| 65 | console.error("Fallback copy failed:", err); |
| 66 | if (button) { |
| 67 | button.textContent = "✗ Failed"; |
| 68 | button.style.color = "red"; |
| 69 | setTimeout(() => { |
| 70 | button.textContent = button.getAttribute("title") || "Copy"; |
| 71 | button.style.color = ""; |
| 72 | }, 1500); |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | // Download file function |
no test coverage detected