| 1 |
/** |
| 2 |
* MetaSync error logs — copy to clipboard. |
| 3 |
* |
| 4 |
* Extracted from site-error-logs/class-metasync-error-logs.php (Phase 5, #887). |
| 5 |
*/ |
| 6 |
(function() { |
| 7 |
var button = document.getElementById('copy-log-btn'); |
| 8 |
if (!button) { |
| 9 |
return; |
| 10 |
} |
| 11 |
|
| 12 |
button.addEventListener('click', function() { |
| 13 |
var content = document.getElementById('error-log-content').textContent; |
| 14 |
var originalText = button.innerHTML; |
| 15 |
|
| 16 |
navigator.clipboard.writeText(content).then(function() { |
| 17 |
button.innerHTML = '<span class="dashicons dashicons-yes" style="font-size: 16px; width: 16px; height: 16px;"></span> Copied!'; |
| 18 |
button.style.background = '#00a32a'; |
| 19 |
button.style.color = '#ffffff'; |
| 20 |
button.style.borderColor = '#00a32a'; |
| 21 |
|
| 22 |
setTimeout(function() { |
| 23 |
button.innerHTML = originalText; |
| 24 |
button.style.background = ''; |
| 25 |
button.style.color = ''; |
| 26 |
button.style.borderColor = ''; |
| 27 |
}, 2000); |
| 28 |
}).catch(function(err) { |
| 29 |
console.error('Failed to copy log:', err); |
| 30 |
button.innerHTML = '<span class="dashicons dashicons-no" style="font-size: 16px; width: 16px; height: 16px;"></span> Failed'; |
| 31 |
button.style.background = '#dc3232'; |
| 32 |
button.style.color = '#ffffff'; |
| 33 |
button.style.borderColor = '#dc3232'; |
| 34 |
|
| 35 |
setTimeout(function() { |
| 36 |
button.innerHTML = originalText; |
| 37 |
button.style.background = ''; |
| 38 |
button.style.color = ''; |
| 39 |
button.style.borderColor = ''; |
| 40 |
}, 2000); |
| 41 |
}); |
| 42 |
}); |
| 43 |
})(); |
| 44 |
|