PageSourceSearch

https://art.pcmtaylor.com/wp-content/themes/worksunit/js/copy.js?ver=1789547884

js pcmtaylor.com collected 2026-10-09 05:13:19 UTC 1,350 bytes, 61 lines download raw bytes

1/**
2 * Qwwwik
3 * ==============
4 * COPYRIGHT Patrick Taylor https://patricktaylor.com/
5 */
6
7// Fixed by Lynne ("sexy Cook"), 16 September 2026
8
9// Get the <pre> element
10const preTag = document.getElementById("myPreTag");
11
12if (preTag) {
13
14	// Create a copy button element
15	const copyButton = document.createElement("span");
16	copyButton.innerText = "Copy";
17	copyButton.classList.add("copy-button");
18
19	// Append the copy button to the <pre> tag
20	preTag.appendChild(copyButton);
21
22	// Add click event listener to the copy button
23	copyButton.addEventListener("click", () => {
24
25		// Hide the copy button temporarily
26		copyButton.style.display = "none";
27
28		// Create a range and select the text inside the <pre> tag
29		const range = document.createRange();
30		range.selectNode(preTag);
31		window.getSelection().removeAllRanges();
32		window.getSelection().addRange(range);
33
34		try {
35
36			// Copy the selected text to the clipboard
37			document.execCommand("copy");
38
39			// Alert the user that the text has been copied
40			copyButton.innerText = "Copied!";
41
42			setTimeout(function(){
43				copyButton.innerText = "Copy";
44			}, 2000);
45
46		} catch (err) {
47
48			console.error("Unable to copy text:", err);
49
50		} finally {
51
52			// Show the copy button again
53			copyButton.style.display = "inline";
54
55			// Deselect the text
56			window.getSelection().removeAllRanges();
57		}
58
59	});
60
61}

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.