Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Password Generator/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ hr{
width: 17em;
height: 3em;
line-height: normal;
display: block;
display: grid;
grid-template-columns: 4fr 1fr;
gap:5px;
border-radius: .5rem;
background-color: #273549;
color:#000000;
Expand All @@ -52,6 +54,19 @@ hr{
.Password2{
color:#55F991;
}
#copy-btn1{
display: none;
align-items: center;
padding: 2px 5px 5px 5px;
font-size: 25px;
}
#copy-btn2{
display: none;
align-items: center;
padding: 2px 5px 5px 5px;
font-size: 25px;
}


#headline1{
margin-top: 2em;
Expand Down
4 changes: 4 additions & 0 deletions Password Generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="index.css" />
<!-- Font Awesome CDN -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" integrity="sha512-2SwdPD6INVrV/lHTZbO2nodKhrnDdJK9/kg2XD1r9uGqPo1cUbujc+IYdlYdEErWNu69gVcYgdxlmVmzTWnetw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<title>Password Generator</title>
</head>
<body>
Expand All @@ -16,8 +18,10 @@ <h2 id="headline2">random password</h2>
<div class="password-container">
<button id="PassContainer">
<p class="Password1"></p>
<i class="fa-solid fa-copy" id="copy-btn1"></i>
<button id="PassContainer">
<p class="Password2"></p>
<i class="fa-solid fa-copy" id="copy-btn2"></i>
</div>
<label class="switch" for="modeChanger">
<input type="checkbox" id="modeChanger">
Expand Down
25 changes: 21 additions & 4 deletions Password Generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ mode.addEventListener("change", () => {
line.style.color = "#6B7280"
hr.style.color = "#E8E7E9"
headline2.style.color = "#10B981"


} else {
headline2.style.color = "#55F991"
headline.style.color = "aliceblue";
Expand All @@ -39,11 +39,28 @@ const generatePassword = (length) => {
return password;
};

let dPassword1 = document.querySelector(".Password1");
let dPassword2 = document.querySelector(".Password2");
let copyBtn1 = document.querySelector('#copy-btn1');
let copyBtn2 = document.querySelector('#copy-btn2');


function copyText(text) {
navigator.clipboard.writeText(text).then(() => {
alert("Copied");
})
}




const displayPassword = () => {
let dPassword1 = document.querySelector(".Password1");
dPassword1.textContent = generatePassword(13);
let dPassword2 = document.querySelector(".Password2");
dPassword2.textContent = generatePassword(12);
copyBtn1.style.display = "flex";
copyBtn2.style.display = "flex";
copyBtn1.addEventListener("click", () => copyText(dPassword1.innerText));
copyBtn2.addEventListener("click", () => copyText(dPassword2.innerText));
};

document.getElementById("btn").addEventListener("click", displayPassword);