Skip to content

Commit ff1bae6

Browse files
authored
Merge #6 from arya_dev
popupScript.js : bug fix => copy to clipboard not working
2 parents d11640e + 15c84a6 commit ff1bae6

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

popupScript.js

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,30 +54,16 @@ generatePasswordButton.addEventListener('click', () => {
5454
passwordTextarea.value = password;
5555
});
5656

57-
// Get the copy button element
58-
const copyButton = document.getElementById('copy-button');
59-
60-
// Add an event listener to the copy button
61-
copyButton.addEventListener('click', function() {
62-
// Get the password element
63-
const passwordElement = document.getElementById('password');
6457

65-
// Create a temporary input element
66-
const input = document.createElement('input');
67-
input.value = passwordElement.innerText;
68-
document.body.appendChild(input);
58+
const copyButton = document.getElementById('copy-button');
59+
const confirmationMessage = document.getElementById('confirmation-message');
6960

70-
// Select and copy the password to the clipboard
71-
input.select();
61+
copyButton.addEventListener('click', () => {
62+
passwordTextarea.select();
7263
document.execCommand('copy');
73-
74-
// Remove the temporary input element
75-
document.body.removeChild(input);
76-
77-
// Show a confirmation message
78-
const confirmationMessage = document.getElementById('confirmation-message');
7964
confirmationMessage.style.display = 'block';
80-
setTimeout(function() {
65+
setTimeout(() => {
8166
confirmationMessage.style.display = 'none';
82-
}, 3000);
67+
}, 2000);
8368
});
69+

0 commit comments

Comments
 (0)