-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
44 lines (30 loc) · 1 KB
/
script.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
33
34
35
36
37
38
39
40
41
42
let sliderElement = document.querySelector("#slider");
let buttonElement = document.querySelector("#button");
let sizePassword = document.querySelector("#valor");
let password = document.querySelector("#password");
let containerPassword = document.querySelector("#container-password");
let charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSWXYZ0123456789!@";
novaSenha = "";
sizePassword.innerHTML = sliderElement.value;
slider.oninput = function(){
sizePassword.innerHTML = this.value;
}
function generatePassword(){
let pass = "";
for(let i = 0, n = charset.length; i < sliderElement.value; ++i){
pass += charset.charAt(Math.floor(Math.random() * n));
}
containerPassword.classList.remove("hide");
password.innerHTML = pass;
novaSenha = pass;
}
function copyPassword(){
navigator.clipboard
.writeText(novaSenha)
.then(() => {
alert("Senha Copiada com Sucesso!");
})
.catch(() => {
alert("Ops! Algo deu Errado.");
});
}