-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
27 lines (19 loc) · 778 Bytes
/
main.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
function getPassword(){
const chars =
'1234567890-=!@#$%&*()_+qwertyuiop[asdfghjkl~]zxcvbnm,.;{}:><QWERTYUIOPASDFGHJKLZXCVBNM';
var passWordLength = 16;
var password = "";
for(var i=0;i< passWordLength;i++){
var randomNumber = Math.floor(Math.random()* chars.length);
password +=chars.substring(randomNumber,randomNumber+1);
}
document.getElementById("password").value = password;
}
function copyPassword() {
if (document.getElementById("password").value === "") getPassword();
navigator.clipboard.writeText(document.getElementById("password").value);
document.getElementById("alert").classList.add("active");
setTimeout(()=>{
document.getElementById("alert").classList.remove("active");
},1000);
}