1const copyToClipboard = str => { 2 const el = document.createElement('textarea'); // Create a <textarea> element 3 el.value = str; // Set its value to the string that you want copied 4 el.setAttribute('readonly', ''); // Make it readonly to be tamper-proof 5 el.style.position = 'absolute'; 6 el.style.left = '-9999px'; // Move outside the screen to make it invisible 7 document.body.appendChild(el); // Append the <textarea> element to the HTML document 8 const selected = 9 document.getSelection().rangeCount > 0 // Check if there is any content selected previously 10 ? document.getSelection().getRangeAt(0) // Store selection if found 11 : false; // Mark as false to know no selection existed before 12 el.select(); // Select the <textarea> content 13 document.execCommand('copy'); // Copy - only works as a result of a user action (e.g. click events) 14 document.body.removeChild(el); // Remove the <textarea> element 15 if (selected) { // If a selection existed before copying 16 document.getSelection().removeAllRanges(); // Unselect everything on the HTML document 17 document.getSelection().addRange(selected); // Restore the original selection 18 } 19};
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.