1const COPIED_LABEL_RESET_DELAY_MS = 2000; 2 3for (const copyBtn of document.querySelectorAll('[data-km-share-copy]')) { 4 const section = copyBtn.closest('.km-share-modal__section'); 5 const copyFields = section ? section.querySelectorAll('.km-share-modal__copy-field') : []; 6 7 copyBtn.addEventListener('click', async () => { 8 const originalLabel = copyBtn.textContent; 9 10 try { 11 await navigator.clipboard.writeText(copyBtn.dataset.url); 12 copyBtn.textContent = copyBtn.dataset.copiedLabel || originalLabel; 13 for (const copyField of copyFields) {copyField.classList.add('km-share-modal__copy-field--copied');} 14 15 setTimeout(() => { 16 copyBtn.textContent = originalLabel; 17 for (const copyField of copyFields) {copyField.classList.remove('km-share-modal__copy-field--copied');} 18 }, COPIED_LABEL_RESET_DELAY_MS); 19 } catch { 20 // Clipboard access denied or unavailable; no-op. 21 } 22 }); 23} 24 25// Fallback for browsers without native command/commandfor support. 26const openButtons = document.querySelectorAll('[data-km-share-open]'); 27if (openButtons[0] && !('commandForElement' in openButtons[0])) { 28 for (const btn of openButtons) { 29 const dialog = document.querySelector(`#${btn.getAttribute('commandfor')}`); 30 btn.addEventListener('click', () => { 31 if (dialog) {dialog.showModal();} 32 }); 33 } 34 35 for (const btn of document.querySelectorAll('[data-km-share-close]')) { 36 const dialog = document.querySelector(`#${btn.getAttribute('commandfor')}`); 37 btn.addEventListener('click', () => { 38 if (dialog) {dialog.close();} 39 }); 40 } 41}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.