@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');
html{
font-family: 'Poppins', sans-serif;
}
.code-container {
width: 450px;
max-width: 100%;
padding: 15px;
box-shadow: 0px 0px 10px #00000029;
margin: 20px;
border-radius: 10px;
}
.copy-btn {
outline: none;
background: transparent;
border: none;
box-shadow: none;
}
//Password Generator function
const stringGenrator = (e) => {
e.preventDefault()
let passwordType = Number(e.target.passwordType.value)
let passwordLength = Number(e.target.passwordLength.value)
let ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
let alpha = 'abcdefghijklmnopqrstuvwxyz';
let Num = '1234567890';
let symbol = '~@#%^&*()_-=+}{[]:?/*';
let output = '';
let characters = '';
if(passwordType == 1){
characters = ALPHA+alpha+Num
}else if(passwordType == 2){
characters = Num;
}else if(passwordType == 3){
characters = ALPHA;
}else if(passwordType == 4){
characters = alpha;
}else if(passwordType == 5){
characters = symbol
}else if(passwordType == 6){
characters = ALPHA+alpha+Num+symbol
}else{
characters = ALPHA+alpha+Num+symbol
}
const charactersLength = characters.length;
let counter = 0;
while (counter < passwordLength) {
output += characters.charAt(Math.floor(Math.random() * charactersLength));
counter += 1;
}
document.querySelector("#output").value = output
document.querySelector(".copy-btn").classList.remove("d-none")
}
const form = document.getElementById("genratePassword");
form.addEventListener("submit", stringGenrator);
//Copy Passwprd
const copyPassword = () => {
let output = document.querySelector("#output");
output.select();
output.setSelectionRange(0, 99999);
navigator.clipboard.writeText(output.value);
alert("Copied the password: " + output.value);
}