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
206 changes: 109 additions & 97 deletions Password Generator/index.css
Original file line number Diff line number Diff line change
@@ -1,136 +1,148 @@
body{
box-sizing: border-box;
font-family:'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
background-color: #1F2937;
body {
box-sizing: border-box;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
background-color: #1F2937;
}

.container{
margin-left: 20%;
margin-right: 10%;
.container {
margin-left: 20%;
margin-right: 10%;
}

#headline {
color:#10B981;
#headline1 {
margin-top: 2em;
color: aliceblue;
font-weight: 800;
margin-bottom: 0;
font-size: 2.5rem;
}

#btn {
background-color: #10B981;
padding:.7em;
color: white;
font-size: medium;
font-weight: 500;
border: none;
margin-bottom: 1em;
margin-top: 1em;
cursor: pointer;
border-radius:.5rem;
#headline2 {
margin-top: 0em;
margin-bottom: 0;
font-size: 2.5em;
color: #55F991;
}

hr{
color: #273549;
position: absolute;

width: 30rem;
#line {
color: #D5D4D8;
}

#PassContainer{
border: 2px solid;
margin-top: 1.5em;
margin-right: 2em;
padding-bottom: 2.5rem;
width: 17em;
height: 3em;
line-height: normal;
display: block;
border-radius: .5rem;
background-color: #273549;
color:#000000;
}
.Password1{
color:#55F991;
#btn {
background-color: #10B981;
padding: 0.7em;
color: white;
font-size: medium;
font-weight: 500;
border: none;
margin-bottom: 1em;
margin-top: 1em;
cursor: pointer;
border-radius: 0.5rem;
}
.Password2{
color:#55F991;

hr {
color: #273549;
position: absolute;
width: 30rem;
}

#headline1{
margin-top: 2em;
color: aliceblue;
font-weight: 800;
margin-bottom: 0;
font-size: 2.5rem;
.password-container {
display: flex;
gap: 1em;
margin-top: 1em;
}

#headline2{
margin-top: 0em;
margin-bottom: 0;
font-size: 2.5em;
color:#55F991;
.password-box {
border: 2px solid;
padding: 0.5em 1em;
border-radius: 0.5rem;
background-color: #273549;
color: #55F991;
display: flex;
align-items: center;
justify-content: space-between;
width: 16em;
}

.copy-btn {
background-color: #10B981;
border: none;
color: white;
padding: 0.3em 0.6em;
border-radius: 0.3rem;
cursor: pointer;
font-size: 0.9em;
}
#line{
color: #D5D4D8;

.copy-btn:hover {
opacity: 0.85;
}

.password-container{
display: flex;

.theme-toggle {
margin-top: 1em;
display: flex;
align-items: center;
gap: 0.5em;
}

.switch{
margin-top: 1em;
margin-left:.5em;
position: relative;
display: inline-block;
width: 60px;
height: 34px;
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}

.switch input {
opacity: 0;
width: 0;
height: 0;
opacity: 0;
width: 0;
height: 0;
}

.slider{
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #273549;
-webkit-transition:.4s;
transition: .4s;
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #273549;
transition: 0.4s;
}

.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
transition: 0.4s;
}

input:checked + .slider{
background-color: #10B981;
input:checked + .slider {
background-color: #10B981;
}


input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
transform: translateX(26px);
}

.slider.round {
border-radius: 34px;
border-radius: 34px;
}

.slider.round:before {
border-radius: 50%;
}

.slider.round:before{
border-radius: 50%;
}
/* Make label text visible in both themes */
label {
color: #D5D4D8; /* default for dark mode */
font-weight: 500;
}

body.light-mode label {
color: #111827; /* darker text for light mode */
}
32 changes: 24 additions & 8 deletions Password Generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,36 @@
<h2 id="headline1">Generate a</h2>
<h2 id="headline2">random password</h2>
<p id="line">Never use an insecure password</p>

<!-- Password length input -->
<label for="lengthInput">Password length:</label>
<input type="number" id="lengthInput" min="6" max="32" value="12" />

<button id="btn">Generate Password</button>
<hr />

<div class="password-container">
<button id="PassContainer">
<div class="password-box">
<p class="Password1"></p>
<button id="PassContainer">
<button class="copy-btn" data-target="Password1">Copy</button>
</div>

<div class="password-box">
<p class="Password2"></p>
<button class="copy-btn" data-target="Password2">Copy</button>
</div>
</div>

<!-- Theme toggle with description -->
<div class="theme-toggle">
<label for="modeChanger">Toggle Theme</label>
<label class="switch" for="modeChanger">
<input type="checkbox" id="modeChanger" />
<span class="slider round"></span>
</label>
</div>
<label class="switch" for="modeChanger">
<input type="checkbox" id="modeChanger">
<span class="slider round"></span>
</label>

</div>

<script src="index.js"></script>
</body>
<script src="index.js"></script>
</html>
41 changes: 26 additions & 15 deletions Password Generator/index.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
let mode = document.querySelector("#modeChanger");
let headline = document.getElementById("headline1");
let headline2 = document.getElementById("headline2");
let body = document.querySelector("body");
let line = document.querySelector("#line");
let hr = document.querySelector("hr");
let headline2 = document.querySelector("#headline2");

mode.addEventListener("change", () => {
if (mode.checked) {
body.classList.add("light-mode");
headline.style.color = "#000000";
body.style.backgroundColor = "#ECFDF5"
line.style.color = "#6B7280"
hr.style.color = "#E8E7E9"
headline2.style.color = "#10B981"


body.style.backgroundColor = "#ECFDF5";
line.style.color = "#6B7280";
hr.style.color = "#E8E7E9";
headline2.style.color = "#10B981";
} else {
headline2.style.color = "#55F991"
body.classList.remove("light-mode");
headline2.style.color = "#55F991";
headline.style.color = "aliceblue";
body.style.backgroundColor = "#1F2937"
hr.style.color = "#273549"
body.style.backgroundColor = "#1F2937";
hr.style.color = "#273549";
}
});


const lowercaseChars = "abcdefghijklmnopqrstuvwxyz";
const uppercaseChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const numberChars = "0123456789";
Expand All @@ -40,10 +39,22 @@ const generatePassword = (length) => {
};

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

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

// Copy functionality
document.querySelectorAll(".copy-btn").forEach((btn) => {
btn.addEventListener("click", () => {
const targetClass = btn.getAttribute("data-target");
const text = document.querySelector(`.${targetClass}`).textContent;
if (text.trim()) {
navigator.clipboard.writeText(text);
btn.textContent = "Copied!";
setTimeout(() => (btn.textContent = "Copy"), 1500);
}
});
});