20 lines
658 B
JavaScript
20 lines
658 B
JavaScript
// static/js/copy-url.js
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const copyUrlButton = document.getElementById('copy-url-button');
|
|
// Verifica si existe el botón en la página
|
|
if (!copyUrlButton) return;
|
|
|
|
copyUrlButton.addEventListener('click', function() {
|
|
navigator.clipboard.writeText(window.location.href)
|
|
.then(function() {
|
|
// Suponiendo que showToast está disponible globalmente
|
|
showToast('URL copied to clipboard!', 'bg-success');
|
|
})
|
|
.catch(function(err) {
|
|
console.error('Error copying URL:', err);
|
|
showToast('Failed to copy URL.', 'bg-danger');
|
|
});
|
|
});
|
|
});
|
|
|