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
9 changes: 9 additions & 0 deletions Password Generator/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,13 @@ input:checked + .slider:before {

.slider.round:before{
border-radius: 50%;
}
#length1{
background-color: #10B981;
}
#length2{
background-color: #10B981;
}
.length-label{
color:white;
}
6 changes: 6 additions & 0 deletions Password Generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
<h2 id="headline1">Generate a</h2>
<h2 id="headline2">random password</h2>
<p id="line">Never use an insecure password</p>
<label for="length1" class="length-label">Password 1 Length:</label>
<input type="number" min="4" max="50" id="length1">
<br>
<label for="length2" class="length-label">Password 2 Length:</label>
<input type="number" min="4" max="50" id="length2">
<br>
<button id="btn">Generate Password</button>
<hr />
<div class="password-container">
Expand Down
16 changes: 12 additions & 4 deletions Password Generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ mode.addEventListener("change", () => {
line.style.color = "#6B7280"
hr.style.color = "#E8E7E9"
headline2.style.color = "#10B981"


document.querySelectorAll(".length-label").forEach(label => {
label.style.color = "#000000";
});
} else {
headline2.style.color = "#55F991"
headline.style.color = "aliceblue";
Expand All @@ -29,6 +30,7 @@ const numberChars = "0123456789";
const specialChars = "!@#$%^&*";

const generatePassword = (length) => {

const allChars = `${lowercaseChars}${uppercaseChars}${numberChars}${specialChars}`;
let password = "";

Expand All @@ -40,10 +42,16 @@ const generatePassword = (length) => {
};

const displayPassword = () => {
const length1 = parseInt(
document.getElementById("length1").value
);
const length2 = parseInt(
document.getElementById("length2").value
);
let dPassword1 = document.querySelector(".Password1");
dPassword1.textContent = generatePassword(13);
dPassword1.textContent = generatePassword(length1);
let dPassword2 = document.querySelector(".Password2");
dPassword2.textContent = generatePassword(12);
dPassword2.textContent = generatePassword(length2);
};

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