Skip to content

Commit 3ef2f07

Browse files
Add Password Forge web game functionality
1 parent d7ab5cd commit 3ef2f07

1 file changed

Lines changed: 101 additions & 0 deletions

File tree

web-app/js/projects.js

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function getProjectHTML(projectName) {
2121
'morse-code': getMorseCodeHTML(),
2222
'tower-of-hanoi': getTowerOfHanoiHTML(),
2323
'snake-game': getsnakeGameHTML(),
24+
'password-forge': getPasswordForgeHTML(),
2425
};
2526

2627
return projects[projectName] || '<h2>Project Coming Soon!</h2>';
@@ -4722,3 +4723,103 @@ function initSnakeGame() {
47224723
}
47234724

47244725
// Call initSnakeGame() after you inject getsnakeGameHTML() into your page.
4726+
// ============================================
4727+
// PASSWORD FORGE
4728+
// ============================================
4729+
4730+
function getPasswordForgeHTML() {
4731+
return `
4732+
<div class="project-content">
4733+
<h2>🔐 Password Forge</h2>
4734+
4735+
<div class="game-container">
4736+
<p class="game-text">
4737+
Create a password that satisfies all firewall rules!
4738+
</p>
4739+
4740+
<input
4741+
type="text"
4742+
id="passwordInput"
4743+
placeholder="Enter password..."
4744+
class="password-input"
4745+
>
4746+
4747+
<button id="checkPasswordBtn" class="btn-check">
4748+
Check Password
4749+
</button>
4750+
4751+
<div id="rulesContainer" class="rules-container">
4752+
<p>❌ Must contain at least 8 characters</p>
4753+
<p>❌ Must contain a number</p>
4754+
<p>❌ Must contain an uppercase letter</p>
4755+
<p>❌ Must contain a special character</p>
4756+
</div>
4757+
4758+
<div id="passwordResult" class="result-message"></div>
4759+
</div>
4760+
</div>
4761+
4762+
<style>
4763+
.game-container {
4764+
text-align: center;
4765+
padding: 2rem;
4766+
}
4767+
4768+
.password-input {
4769+
width: 80%;
4770+
padding: 1rem;
4771+
border-radius: 10px;
4772+
border: 2px solid var(--border-color);
4773+
margin-top: 1rem;
4774+
font-size: 1rem;
4775+
}
4776+
4777+
.btn-check {
4778+
margin-top: 1rem;
4779+
padding: 0.8rem 1.5rem;
4780+
border: none;
4781+
border-radius: 10px;
4782+
background: var(--primary-color);
4783+
color: white;
4784+
cursor: pointer;
4785+
font-size: 1rem;
4786+
}
4787+
4788+
.btn-check:hover {
4789+
transform: scale(1.05);
4790+
}
4791+
4792+
.rules-container {
4793+
margin-top: 1.5rem;
4794+
text-align: left;
4795+
display: inline-block;
4796+
}
4797+
4798+
.result-message {
4799+
margin-top: 1.5rem;
4800+
font-size: 1.2rem;
4801+
font-weight: bold;
4802+
}
4803+
</style>
4804+
`;
4805+
}
4806+
4807+
function initPasswordForge() {
4808+
const checkBtn = document.getElementById('checkPasswordBtn');
4809+
4810+
checkBtn.addEventListener('click', () => {
4811+
const password = document.getElementById('passwordInput').value;
4812+
const result = document.getElementById('passwordResult');
4813+
4814+
const hasLength = password.length >= 8;
4815+
const hasNumber = /\d/.test(password);
4816+
const hasUpper = /[A-Z]/.test(password);
4817+
const hasSpecial = /[!@#$%^&*]/.test(password);
4818+
4819+
if (hasLength && hasNumber && hasUpper && hasSpecial) {
4820+
result.textContent = "✅ Strong Password!";
4821+
} else {
4822+
result.textContent = "❌ Password does not meet all rules!";
4823+
}
4824+
});
4825+
}

0 commit comments

Comments
 (0)