MCPcopy Create free account
hub / github.com/bywwcnll/StreamPanel / copyToClipboard

Function copyToClipboard

devtools/modules/utils.js:15–43  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

13}
14
15export async function copyToClipboard(text) {
16 try {
17 if (navigator.clipboard && window.isSecureContext) {
18 await navigator.clipboard.writeText(text);
19 return true;
20 }
21 } catch (err) {
22 console.warn('Clipboard API failed, falling back to execCommand:', err);
23 }
24
25 const textarea = document.createElement('textarea');
26 textarea.value = text;
27 textarea.style.position = 'fixed';
28 textarea.style.left = '-9999px';
29 textarea.style.top = '-9999px';
30 textarea.style.opacity = '0';
31 document.body.appendChild(textarea);
32 textarea.select();
33
34 try {
35 const successful = document.execCommand('copy');
36 document.body.removeChild(textarea);
37 return successful;
38 } catch (err) {
39 console.error('Failed to copy:', err);
40 document.body.removeChild(textarea);
41 return false;
42 }
43}
44
45export function formatTime(timestamp) {
46 const date = new Date(timestamp);

Callers 3

setupDetailHandlersFunction · 0.90
setupTextDecodeHandlersFunction · 0.90
showJsonFieldContextMenuFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected