Fix copy buttons doing nothing over plain HTTP
navigator.clipboard is undefined in non-secure contexts, so the direct
writeText() call threw synchronously and the execCommand fallback in its
.catch() never ran. _copyText() now feature-detects the API, falls back
to execCommand('copy'), then to a prompt() for manual copying. log.js
reuses the helper; _getShareBaseUrl() caches the LAN-IP lookup so token
Copy buttons stay within the click gesture execCommand requires.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
652031b31d
commit
35e767b506
4 files changed
+36
-15
No files matched your search
+3
-4
@@ -161,10 +161,9 @@ function copyLog() {
|
||||
document.querySelectorAll('#logPanel .log-line:not(#logLive)').forEach(function(d) {
|
||||
lines.push(d.textContent);
|
||||
});
|
||||
navigator.clipboard.writeText(lines.join('\n')).then(function() {
|
||||
const btn = document.querySelector('.log-copy-btn');
|
||||
if (btn) { btn.textContent = '✓ Copied'; setTimeout(function(){ btn.textContent = '⎘ Copy'; }, 1500); }
|
||||
}).catch(function() {});
|
||||
const btn = document.querySelector('.log-copy-btn');
|
||||
// _copyText (viewer.js) handles HTTP contexts where navigator.clipboard is undefined.
|
||||
if (btn) window._copyText(lines.join('\n'), btn);
|
||||
}
|
||||
|
||||
function _restoreLog() {
|
||||
|
||||
Reference in new issue
Block a user