MCPcopy Create free account
hub / github.com/CodeClash-ai/CodeClash / fallbackCopy

Function fallbackCopy

codeclash/viewer/static/js/clipboard.js:36–75  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34 }
35
36 function fallbackCopy() {
37 try {
38 const textArea = document.createElement("textarea");
39 textArea.value = text;
40 textArea.style.position = "fixed";
41 textArea.style.left = "-9999px";
42 textArea.style.top = "-9999px";
43 document.body.appendChild(textArea);
44 textArea.focus();
45 textArea.select();
46
47 const successful = document.execCommand("copy");
48 document.body.removeChild(textArea);
49
50 if (successful) {
51 showSuccessMessage();
52 console.log("Copied to clipboard (fallback):", text);
53 } else {
54 console.error("Failed to copy text with fallback method");
55 if (button) {
56 button.textContent = "✗ Failed";
57 button.style.color = "red";
58 setTimeout(() => {
59 button.textContent = button.getAttribute("title") || "Copy";
60 button.style.color = "";
61 }, 1500);
62 }
63 }
64 } catch (err) {
65 console.error("Fallback copy failed:", err);
66 if (button) {
67 button.textContent = "✗ Failed";
68 button.style.color = "red";
69 setTimeout(() => {
70 button.textContent = button.getAttribute("title") || "Copy";
71 button.style.color = "";
72 }, 1500);
73 }
74 }
75 }
76}
77
78// Download file function

Callers 1

copyToClipboardFunction · 0.85

Calls 1

showSuccessMessageFunction · 0.85

Tested by

no test coverage detected