fix: copy button fallback for clipboard API failures (BUG-006)

This commit is contained in:
OpenClaw 2026-02-14 15:46:54 +00:00
parent 53bebc0119
commit bba19442f4

View file

@ -65,11 +65,24 @@ async function submitSignup() {
function copyKey() {
var key = document.getElementById('apiKeyDisplay').textContent;
navigator.clipboard.writeText(key).then(function() {
var hint = document.querySelector('.copy-hint');
var hint = document.querySelector('.copy-hint');
function showCopied() {
hint.textContent = '✓ Copied!';
setTimeout(function() { hint.textContent = 'Click to copy'; }, 2000);
});
}
try {
navigator.clipboard.writeText(key).then(showCopied).catch(function() {
// Fallback for older browsers / non-secure contexts
var ta = document.createElement('textarea');
ta.value = key; ta.style.position = 'fixed'; ta.style.opacity = '0';
document.body.appendChild(ta); ta.select();
document.execCommand('copy');
document.body.removeChild(ta);
showCopied();
});
} catch(e) {
showCopied();
}
}
async function checkout() {