feat: data-backed rate limits, concurrency limiter, copy button fix (BUG-025, BUG-022)

This commit is contained in:
OpenClaw 2026-02-15 08:14:39 +00:00
parent 922230c108
commit f5a85c6fc3
5 changed files with 222 additions and 17 deletions

View file

@ -239,17 +239,56 @@ function doCopy(text, btn) {
btn.textContent = '\u2713 Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 2000);
}
function showFailed() {
btn.textContent = 'Failed';
setTimeout(function() { btn.textContent = 'Copy'; }, 2000);
}
try {
navigator.clipboard.writeText(text).then(showCopied).catch(function() {
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(text).then(showCopied).catch(function() {
// Fallback to execCommand
try {
var ta = document.createElement('textarea');
ta.value = text;
ta.style.position = 'fixed';
ta.style.opacity = '0';
ta.style.top = '-9999px';
ta.style.left = '-9999px';
document.body.appendChild(ta);
ta.focus();
ta.select();
var success = document.execCommand('copy');
document.body.removeChild(ta);
if (success) {
showCopied();
} else {
showFailed();
}
} catch (err) {
showFailed();
}
});
} else {
// Direct fallback for non-secure contexts
var ta = document.createElement('textarea');
ta.value = text; ta.style.position = 'fixed'; ta.style.opacity = '0';
document.body.appendChild(ta); ta.select();
document.execCommand('copy');
ta.value = text;
ta.style.position = 'fixed';
ta.style.opacity = '0';
ta.style.top = '-9999px';
ta.style.left = '-9999px';
document.body.appendChild(ta);
ta.focus();
ta.select();
var success = document.execCommand('copy');
document.body.removeChild(ta);
showCopied();
});
if (success) {
showCopied();
} else {
showFailed();
}
}
} catch(e) {
showCopied();
showFailed();
}
}