tracebin / static /app.js
lvwerra's picture
lvwerra HF Staff
oauth-restricted traces, download + agent-prompt buttons
6b41207 verified
Raw History Blame Contribute Delete
795 Bytes
document.addEventListener("click", function (event) {
var button = event.target.closest("[data-copy]");
if (!button) return;
var field = document.getElementById(button.dataset.copy);
if (!field) return;
function done() {
var original = button.textContent;
button.textContent = "Copied";
setTimeout(function () {
button.textContent = original;
}, 1500);
}
field.select();
field.setSelectionRange(0, field.value.length); // iOS needs the explicit range
if (navigator.clipboard) {
navigator.clipboard.writeText(field.value).then(done, function () {
if (document.execCommand("copy")) done();
});
} else if (document.execCommand("copy")) {
// Older browsers, and any context the async clipboard API is unavailable in.
done();
}
});