chun / citations.js
chaewanC's picture
Publish dataset guide with source mapping diagram and BibTeX citations
9577a43 verified
Raw History Blame Contribute Delete
750 Bytes
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.';
}
});
});