|
579 | 579 | // Copy functions for Monaco editors |
580 | 580 | function copyDockerfile() { |
581 | 581 | const content = dockerfileEditor ? dockerfileEditor.getValue() : ''; |
582 | | - copyToClipboard(content, 'Dockerfile copied!'); |
| 582 | + const button = event.target.closest('button'); |
| 583 | + copyToClipboard(content, 'Dockerfile copied!', button); |
583 | 584 | } |
584 | 585 |
|
585 | 586 | function copyCompose() { |
586 | 587 | const content = composeEditor ? composeEditor.getValue() : ''; |
587 | | - copyToClipboard(content, 'Compose file copied!'); |
| 588 | + const button = event.target.closest('button'); |
| 589 | + copyToClipboard(content, 'Compose file copied!', button); |
588 | 590 | } |
589 | 591 |
|
590 | 592 | // WebSocket streaming functionality |
|
808 | 810 | {% endif %} |
809 | 811 |
|
810 | 812 | // Copy to clipboard functionality |
811 | | - async function copyToClipboard(text, successMessage) { |
| 813 | + async function copyToClipboard(text, successMessage, targetButton) { |
812 | 814 | try { |
813 | 815 | await navigator.clipboard.writeText(text); |
814 | | - // Show success feedback |
815 | | - const buttons = document.querySelectorAll('button'); |
816 | | - buttons.forEach(btn => { |
817 | | - if (btn.textContent.includes('Copy')) { |
818 | | - const originalText = btn.innerHTML; |
819 | | - btn.innerHTML = '✓ ' + (successMessage || 'Copied!'); |
820 | | - setTimeout(() => { |
821 | | - btn.innerHTML = originalText; |
822 | | - }, 2000); |
823 | | - } |
824 | | - }); |
| 816 | + // Show success feedback only on the specific button |
| 817 | + if (targetButton) { |
| 818 | + const originalText = targetButton.innerHTML; |
| 819 | + targetButton.innerHTML = '✓ ' + (successMessage || 'Copied!'); |
| 820 | + setTimeout(() => { |
| 821 | + targetButton.innerHTML = originalText; |
| 822 | + }, 2000); |
| 823 | + } |
825 | 824 | } catch (err) { |
826 | 825 | console.error('Failed to copy: ', err); |
827 | 826 | } |
|
0 commit comments