Skip to content

Commit 48184e5

Browse files
committed
copy bibtex to clipboard
1 parent 7a8b5d0 commit 48184e5

1 file changed

Lines changed: 105 additions & 3 deletions

File tree

content/_index.md

Lines changed: 105 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,116 @@ Details about LUCCa's computational overhead (~0.3 ms per planning step) and its
7373

7474
# BibTeX <small><small>(cite this!)</small></small>
7575

76-
```
77-
@misc{marques2024quantifyingaleatoricepistemicdynamics,
76+
<div class="bibtex-copy-container">
77+
<button id="bibtex-copy-button" type="button" aria-label="Copy BibTeX to clipboard">
78+
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
79+
<path d="M16 1H4a2 2 0 0 0-2 2v12h2V3h12V1zm3 4H8a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2zm0 16H8V7h11v14z"/>
80+
</svg>
81+
<span>Copy to clipboard</span>
82+
</button>
83+
<pre id="bibtex-content"><code>@misc{marques2024quantifyingaleatoricepistemicdynamics,
7884
title={Quantifying Aleatoric and Epistemic Dynamics Uncertainty via Local Conformal Calibration},
7985
author={Luís Marques and Dmitry Berenson},
8086
year={2024},
8187
eprint={2409.08249},
8288
archivePrefix={arXiv},
8389
primaryClass={cs.RO},
8490
url={https://arxiv.org/abs/2409.08249},
91+
}</code></pre>
92+
</div>
93+
94+
<script>
95+
(() => {
96+
const copyButton = document.getElementById("bibtex-copy-button");
97+
const bibtexContent = document.getElementById("bibtex-content");
98+
if (!copyButton || !bibtexContent) return;
99+
100+
const defaultText = "Copy to clipboard";
101+
const setButtonLabel = (label) => {
102+
const textSpan = copyButton.querySelector("span");
103+
if (textSpan) textSpan.textContent = label;
104+
};
105+
106+
copyButton.addEventListener("click", () => {
107+
const bibtexText = bibtexContent.textContent ?? "";
108+
if (!navigator.clipboard || !navigator.clipboard.writeText) {
109+
setButtonLabel("Clipboard not available");
110+
setTimeout(() => setButtonLabel(defaultText), 3000);
111+
return;
112+
}
113+
114+
navigator.clipboard.writeText(bibtexText).then(() => {
115+
setButtonLabel("Copied!");
116+
setTimeout(() => setButtonLabel(defaultText), 3000);
117+
}).catch(() => {
118+
setButtonLabel("Copy failed");
119+
setTimeout(() => setButtonLabel(defaultText), 3000);
120+
});
121+
});
122+
})();
123+
</script>
124+
125+
<style>
126+
.bibtex-copy-container {
127+
position: relative;
85128
}
86-
```
129+
130+
.bibtex-copy-container pre {
131+
margin-top: 0;
132+
padding-top: 0.9rem;
133+
padding-right: 11.2rem;
134+
overflow-x: auto;
135+
white-space: pre;
136+
}
137+
138+
.bibtex-copy-container code {
139+
font-size: 0.86rem;
140+
line-height: 1.35;
141+
}
142+
143+
#bibtex-copy-button {
144+
position: absolute;
145+
top: 0.9rem;
146+
right: 0.6rem;
147+
display: inline-flex;
148+
align-items: center;
149+
gap: 0.4rem;
150+
border: 1px solid #d0d7de;
151+
border-radius: 6px;
152+
background: #f6f8fa;
153+
color: #24292f;
154+
padding: 0.35rem 0.6rem;
155+
font-size: 0.85rem;
156+
cursor: pointer;
157+
z-index: 1;
158+
}
159+
160+
#bibtex-copy-button:hover {
161+
background: #eef2f6;
162+
}
163+
164+
#bibtex-copy-button svg {
165+
width: 1rem;
166+
height: 1rem;
167+
fill: currentColor;
168+
}
169+
170+
@media screen and (max-width: 768px) {
171+
#bibtex-copy-button {
172+
top: 0.45rem;
173+
right: 0.45rem;
174+
font-size: 0.78rem;
175+
padding: 0.3rem 0.5rem;
176+
}
177+
178+
.bibtex-copy-container pre {
179+
padding-top: 0.75rem;
180+
padding-right: 9.7rem;
181+
}
182+
183+
.bibtex-copy-container code {
184+
font-size: 0.73rem;
185+
line-height: 1.28;
186+
}
187+
}
188+
</style>

0 commit comments

Comments
 (0)