MCPcopy Create free account
hub / github.com/error311/FileRise / openFileLinkResultModal

Function openFileLinkResultModal

public/js/fileLink.js:32–82  ·  view source on GitHub ↗
(fileName, link)

Source from the content-addressed store, hash-verified

30}
31
32function 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">&times;</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
84async function createAuthFileLink(folder, file, sourceId = '') {
85 const resp = await fetch(withBase('/api/file/createAuthFileLink.php'), {

Callers 1

openFileLinkModalFunction · 0.85

Calls 5

tFunction · 0.85
escapeHTMLFunction · 0.85
closeFunction · 0.70
copyTextToClipboardFunction · 0.70
showToastFunction · 0.70

Tested by

no test coverage detected