(link)
| 66 | } |
| 67 | |
| 68 | function openFolderShareResultModal(link) { |
| 69 | const existing = document.getElementById("folderShareResultModal"); |
| 70 | if (existing) existing.remove(); |
| 71 | |
| 72 | const modal = document.createElement("div"); |
| 73 | modal.id = "folderShareResultModal"; |
| 74 | modal.className = "modal"; |
| 75 | modal.innerHTML = ` |
| 76 | <div class="modal-content share-modal-content" style="max-width:560px;"> |
| 77 | <div class="modal-header"> |
| 78 | <h3>${t("share_link_generated")}</h3> |
| 79 | <span id="closeFolderShareResultModal" title="${t("close")}" class="close-image-modal">×</span> |
| 80 | </div> |
| 81 | <div class="modal-body"> |
| 82 | <p style="margin-bottom:6px;">${t("shareable_link")}</p> |
| 83 | <input id="folderShareResultLinkInput" type="text" readonly style="width:100%;padding:6px;" /> |
| 84 | <div style="margin-top:12px;display:flex;gap:8px;flex-wrap:wrap;"> |
| 85 | <button id="copyFolderShareResultBtn" class="btn btn-primary">${t("copy_link")}</button> |
| 86 | <button id="closeFolderShareResultBtn" class="btn btn-secondary">${t("close")}</button> |
| 87 | </div> |
| 88 | </div> |
| 89 | </div> |
| 90 | `; |
| 91 | document.body.appendChild(modal); |
| 92 | modal.style.display = "block"; |
| 93 | |
| 94 | const inputEl = document.getElementById("folderShareResultLinkInput"); |
| 95 | if (inputEl) { |
| 96 | inputEl.value = link; |
| 97 | inputEl.focus(); |
| 98 | inputEl.select(); |
| 99 | } |
| 100 | |
| 101 | const close = () => modal.remove(); |
| 102 | const closeX = document.getElementById("closeFolderShareResultModal"); |
| 103 | const closeBtn = document.getElementById("closeFolderShareResultBtn"); |
| 104 | const copyBtn = document.getElementById("copyFolderShareResultBtn"); |
| 105 | |
| 106 | if (closeX) closeX.addEventListener("click", close); |
| 107 | if (closeBtn) closeBtn.addEventListener("click", close); |
| 108 | modal.addEventListener("click", (e) => { |
| 109 | if (e.target === modal) close(); |
| 110 | }); |
| 111 | |
| 112 | if (copyBtn && inputEl) { |
| 113 | copyBtn.addEventListener("click", async () => { |
| 114 | try { |
| 115 | const ok = await copyTextToClipboard(inputEl.value); |
| 116 | showToast(ok ? t("link_copied") : t("unknown_error")); |
| 117 | } catch (e) { |
| 118 | showToast(t("unknown_error")); |
| 119 | } |
| 120 | }); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | export function openFolderShareModal(folder) { |
| 125 | // Remove any existing modal |
no test coverage detected