mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-03 05:29:12 +00:00
Show temporary status message when copied to clipboard
This commit is contained in:
@@ -15,11 +15,19 @@
|
||||
let chatOptions = [];
|
||||
function copyProgrammaticOutput(event) {
|
||||
// Remove the first 4 characters which are the "Copy" button
|
||||
const originalCopyText = event.target.parentNode.textContent.trim().slice(0, 4);
|
||||
const programmaticOutput = event.target.parentNode.textContent.trim().slice(4);
|
||||
navigator.clipboard.writeText(programmaticOutput).then(() => {
|
||||
console.log("Programmatic output copied to clipboard");
|
||||
event.target.textContent = "✅ Copied to clipboard!";
|
||||
setTimeout(() => {
|
||||
event.target.textContent = originalCopyText;
|
||||
}, 1000);
|
||||
}).catch((error) => {
|
||||
console.error("Error copying programmatic output to clipboard:", error);
|
||||
event.target.textContent = "⛔️ Failed to copy!";
|
||||
setTimeout(() => {
|
||||
event.target.textContent = originalCopyText;
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user