-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
31 lines (23 loc) · 948 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
let sliderElement = document.querySelector("#slider_password");
let buttonElement = document.querySelector("#button");
let sizePassword = document.querySelector("#value_password");
let password = document.querySelector("#random_password");
let containerPassword = document.querySelector("#container_password");
let charset = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ@#*&_-!"
let newPassword = "";
sizePassword.innerHTML = sliderElement.value;
sliderElement.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));
}
password.innerHTML = pass;
containerPassword.classList.remove("hide");
newPassword = pass;
}
function copyPassword(){
navigator.clipboard.writeText(newPassword);
}