Improve copy token button feedback with visual confirmation

parent 818836f4
...@@ -194,8 +194,16 @@ ...@@ -194,8 +194,16 @@
function copyTokenFromModal() { function copyTokenFromModal() {
const tokenText = document.getElementById('modalTokenText'); const tokenText = document.getElementById('modalTokenText');
const copyBtn = document.querySelector('#tokenModal .copy-btn');
const originalText = copyBtn.textContent;
navigator.clipboard.writeText(tokenText.textContent).then(function() { navigator.clipboard.writeText(tokenText.textContent).then(function() {
alert('Token copied to clipboard!'); copyBtn.textContent = 'Copied!';
copyBtn.style.background = '#10b981';
setTimeout(function() {
copyBtn.textContent = originalText;
copyBtn.style.background = '';
}, 2000);
}, function(err) { }, function(err) {
// Fallback for older browsers // Fallback for older browsers
const textArea = document.createElement('textarea'); const textArea = document.createElement('textarea');
...@@ -204,7 +212,12 @@ ...@@ -204,7 +212,12 @@
textArea.select(); textArea.select();
document.execCommand('copy'); document.execCommand('copy');
document.body.removeChild(textArea); document.body.removeChild(textArea);
alert('Token copied to clipboard!'); copyBtn.textContent = 'Copied!';
copyBtn.style.background = '#10b981';
setTimeout(function() {
copyBtn.textContent = originalText;
copyBtn.style.background = '';
}, 2000);
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment