index-main/assets/js/share.js

22 lines
740 B
JavaScript
Raw Normal View History

2026-01-06 13:57:45 +01:00
export function copyLink() {
let buttons = document.querySelectorAll('.copy-link button');
buttons.forEach(function (button, index) {
2026-01-21 17:25:37 +01:00
let input = button.parentNode.querySelector("input");
let link = input.value;
2026-01-06 13:57:45 +01:00
button.addEventListener('click', function() {
navigator.clipboard.writeText(link).then(() => {
2026-01-21 17:25:37 +01:00
input.value = 'Lien copié !';
input.classList.add('is-copied');
2026-01-06 13:57:45 +01:00
setTimeout(() => {
2026-01-21 17:25:37 +01:00
input.value = link;
input.classList.remove('is-copied');
2026-01-06 13:57:45 +01:00
}, 1000);
}).catch(err => {
console.error('Erreur lors de la copie:', err);
});
});
});
}