(fileName, link)
| 30 | } |
| 31 | |
| 32 | function openFileLinkResultModal(fileName, link) { |
| 33 | const existing = document.getElementById('fileLinkResultModal'); |
| 34 | if (existing) existing.remove(); |
| 35 | |
| 36 | const modal = document.createElement('div'); |
| 37 | modal.id = 'fileLinkResultModal'; |
| 38 | modal.className = 'modal'; |
| 39 | modal.innerHTML = ` |
| 40 | <div class="modal-content share-modal-content" style="max-width:560px;"> |
| 41 | <div class="modal-header"> |
| 42 | <h3>${t('link_file')}: ${escapeHTML(fileName)}</h3> |
| 43 | <span id="closeFileLinkResultModalX" title="${t('close')}" class="close-image-modal">×</span> |
| 44 | </div> |
| 45 | <div class="modal-body"> |
| 46 | <p style="margin-bottom:6px;">${t('shareable_link')}</p> |
| 47 | <input id="fileLinkResultInput" type="text" readonly style="width:100%;padding:6px;" /> |
| 48 | <div style="margin-top:12px;display:flex;gap:8px;flex-wrap:wrap;"> |
| 49 | <button id="copyFileLinkResultBtn" class="btn btn-primary">${t('copy_link')}</button> |
| 50 | <button id="closeFileLinkResultBtn" class="btn btn-secondary">${t('close')}</button> |
| 51 | </div> |
| 52 | </div> |
| 53 | </div> |
| 54 | `; |
| 55 | document.body.appendChild(modal); |
| 56 | modal.style.display = 'block'; |
| 57 | |
| 58 | const inputEl = document.getElementById('fileLinkResultInput'); |
| 59 | if (inputEl) { |
| 60 | inputEl.value = link; |
| 61 | inputEl.focus(); |
| 62 | inputEl.select(); |
| 63 | } |
| 64 | |
| 65 | const close = () => modal.remove(); |
| 66 | const closeX = document.getElementById('closeFileLinkResultModalX'); |
| 67 | const closeBtn = document.getElementById('closeFileLinkResultBtn'); |
| 68 | const copyBtn = document.getElementById('copyFileLinkResultBtn'); |
| 69 | |
| 70 | if (closeX) closeX.addEventListener('click', close); |
| 71 | if (closeBtn) closeBtn.addEventListener('click', close); |
| 72 | modal.addEventListener('click', (e) => { |
| 73 | if (e.target === modal) close(); |
| 74 | }); |
| 75 | |
| 76 | if (copyBtn && inputEl) { |
| 77 | copyBtn.addEventListener('click', async () => { |
| 78 | const ok = await copyTextToClipboard(inputEl.value); |
| 79 | showToast(ok ? t('link_copied') : t('unknown_error')); |
| 80 | }); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | async function createAuthFileLink(folder, file, sourceId = '') { |
| 85 | const resp = await fetch(withBase('/api/file/createAuthFileLink.php'), { |
no test coverage detected