18 lines
511 B
JavaScript
18 lines
511 B
JavaScript
|
function copyToClipboard(element, text, description) {
|
||
|
navigator.clipboard.writeText(text).then(function() {
|
||
|
showToast("Copied " + description);
|
||
|
}).catch(function(error) {
|
||
|
console.error("Copy failed!", error);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
// Function to show the toast notification
|
||
|
function showToast(message) {
|
||
|
let toast = document.getElementById("toast");
|
||
|
toast.innerText = message;
|
||
|
toast.classList.add("show");
|
||
|
|
||
|
setTimeout(() => {
|
||
|
toast.classList.remove("show");
|
||
|
}, 2000);
|
||
|
}
|