File size: 750 Bytes
9577a43 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | document.querySelectorAll('.copy-bibtex').forEach((button) => {
button.hidden = false;
button.addEventListener('click', async () => {
const code = document.getElementById(button.dataset.copy);
const status = button.closest('.citation-box').querySelector('.copy-status');
if (!code) return;
try {
await navigator.clipboard.writeText(code.textContent);
status.textContent = 'Copied.';
} catch {
const selection = window.getSelection();
if (selection) {
const range = document.createRange();
range.selectNodeContents(code);
selection.removeAllRanges();
selection.addRange(range);
}
status.textContent = 'Select and copy the citation manually.';
}
});
});
|