mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 21:29:11 +00:00
Show temporary status message when copied to clipboard
This commit is contained in:
@@ -15,11 +15,19 @@
|
|||||||
let chatOptions = [];
|
let chatOptions = [];
|
||||||
function copyProgrammaticOutput(event) {
|
function copyProgrammaticOutput(event) {
|
||||||
// Remove the first 4 characters which are the "Copy" button
|
// 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);
|
const programmaticOutput = event.target.parentNode.textContent.trim().slice(4);
|
||||||
navigator.clipboard.writeText(programmaticOutput).then(() => {
|
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) => {
|
}).catch((error) => {
|
||||||
console.error("Error copying programmatic output to clipboard:", error);
|
console.error("Error copying programmatic output to clipboard:", error);
|
||||||
|
event.target.textContent = "⛔️ Failed to copy!";
|
||||||
|
setTimeout(() => {
|
||||||
|
event.target.textContent = originalCopyText;
|
||||||
|
}, 1000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,19 @@ To get started, just start typing below. You can also type / to see a list of co
|
|||||||
let chatOptions = [];
|
let chatOptions = [];
|
||||||
function copyProgrammaticOutput(event) {
|
function copyProgrammaticOutput(event) {
|
||||||
// Remove the first 4 characters which are the "Copy" button
|
// 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);
|
const programmaticOutput = event.target.parentNode.textContent.trim().slice(4);
|
||||||
navigator.clipboard.writeText(programmaticOutput).then(() => {
|
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) => {
|
}).catch((error) => {
|
||||||
console.error("Error copying programmatic output to clipboard:", 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