-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
32 lines (26 loc) · 1.02 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
let passwordBox = document.querySelector('#password');
let img = document.querySelector('.img-1');
// let button = document.querySelector('#button-main');
let length = 9;
let uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
let lowercase = 'abcdefghijklmnopqrstuvwxyz';
let symbol = '!@#$%^&*()_+-=[]{}|;:<>,./?';
let number = '0123456789';
let allChars = uppercase + lowercase + number + symbol;
function generatePassword() {
let password = '';
password += uppercase[Math.floor(Math.random() * uppercase.length)];
password += lowercase[Math.floor(Math.random() * lowercase.length)];
password += number[Math.floor(Math.random() * number.length)];
password += symbol[Math.floor(Math.random() * symbol.length)];
while (length > password.length) {
password += allChars[Math.floor(Math.random() * allChars.length)];
}
passwordBox.value = password;
// console.log('work');
}
// img.addEventListener('Click',copyPassword)
function copyPassword() {
passwordBox.select();
document.execCommand('copy');
}