-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
36 lines (26 loc) · 944 Bytes
/
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
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 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!';
let 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));
}
console.log(pass)
containerPassword.classList.remove("hide");
password.innerHTML = pass;
novaSenha = pass;
}
function copyPassword(){
navigator.clipboard.writeText(novaSenha).then(function (){
alert("Senha copiada com sucesso!")
});
}