Skip to content
Merged
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
219 changes: 41 additions & 178 deletions web-app/js/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,46 +76,7 @@ function getProjectHTML(projectName) {
}
}

function initializeProject(projectName) {
//Prevent duplicate listeners+duplicate ui execution
//if same project is already active it will not re run init
if(activeProject ===projectName ) return;

activeProject=projectName;

const initializers = {
'rock-paper-scissor': initRockPaperScissor,
'dice-rolling': initDiceRolling,
'coin-flip': initCoinFlip,
'blackjack-21' : initBlackjack,
'number-guessing': initNumberGuessing,
'hangman': initHangman,
'flames': initFlames,
'fibonacci': initFibonacci,
'progression-recognizer': initProgressionRecognizer,
'pascal-triangle': initPascalTriangle,
'armstrong': initArmstrong,
'calculator': initCalculator,
'collatz': initCollatz,
'prime-analyzer': initPrimeAnalyzer,
'projectile-motion': initProjectileMotion,
'coordinate-polar-transform': initCoordinatePolarTransform,
'derivative-calculator': initDerivativeCalculator,
'morse-code': initMorseCode,
'tower-of-hanoi': initTowerOfHanoi,
'number-converter': initNumberConverter,
'typing-speed-tester': initTypingSpeedTester,
'snake-game': initSnakeGame,
'whack-a-mole': initWhackaMole,
'password-forge': initPasswordForge,
'2048-game': init2048Game, // Added explicit mapped hook definition binding reference
'typing-speed-tester': initTypingSpeedTester
};

if (initializers[projectName]) {
initializers[projectName]();
}
}

// ============================================
// ROCK PAPER SCISSORS
Expand Down Expand Up @@ -1880,109 +1841,6 @@ function initFlames() {
`;
}


function showSequence() {
isPlayingSequence = true;
disableButtons(true);
displayContent.textContent = "Watch the sequence...";

let i = 0;
const playNextEmoji = () => {
if (i < sequence.length) {
const emoji = sequence[i];
const button = Array.from(emojiButtons).find(btn => btn.dataset.emoji === emoji);

if (button) {
button.classList.add('active');
setTimeout(() => {
button.classList.remove('active');
i++;
setTimeout(playNextEmoji, 500);
}, 600);
}
} else {
isPlayingSequence = false;
disableButtons(false);
userSequence = [];
gameActive = true;
displayContent.textContent = "Your turn! Click the emojis...";
instructionsDiv.textContent = `👆 Repeat the sequence (${sequence.length} steps)`;
}
};

playNextEmoji();
}

function startNewRound() {
const newEmoji = emojis[Math.floor(Math.random() * emojis.length)];
sequence.push(newEmoji);
userSequence = [];

sequenceLengthDisplay.textContent = sequence.length;
setTimeout(showSequence, 500);
}

function handleEmojiClick(emoji, button) {
if (isPlayingSequence || !gameActive) return;

userSequence.push(emoji);
button.classList.add('active');

setTimeout(() => {
button.classList.remove('active');
}, 300);

// Check if the emoji matches
if (userSequence[userSequence.length - 1] !== sequence[userSequence.length - 1]) {
gameOver();
return;
}

// Check if the entire sequence is correct
if (userSequence.length === sequence.length) {
score += level * 10;
scoreDisplay.textContent = score;
level++;
levelDisplay.textContent = level;

instructionsDiv.textContent = "✅ Correct! Get ready for the next round...";
gameActive = false;
setTimeout(startNewRound, 1500);
}
}

function gameOver() {
gameActive = false;
disableButtons(true);
instructionsDiv.textContent = `❌ Game Over! You reached Level ${level} with Score: ${score}`;
displayContent.textContent = `Final Score: ${score}`;
startBtn.textContent = "▶️ PLAY AGAIN";
}

function resetGame() {
sequence = [];
userSequence = [];
score = 0;
level = 1;
gameActive = false;
isPlayingSequence = false;

scoreDisplay.textContent = '0';
levelDisplay.textContent = '1';
sequenceLengthDisplay.textContent = '0';
instructionsDiv.textContent = "👇 Click START to begin the game!";
displayContent.textContent = "Ready to test your memory?";
startBtn.textContent = "▶️ START";

disableButtons(true);
}

startBtn.addEventListener('click', () => {
resetGame();
gameActive = true;
instructionsDiv.textContent = "Watch the sequence...";
startNewRound();

calculateBtn.addEventListener('click', calculateFlames);
name1Input.addEventListener('keypress', (e) => {
if (e.key === 'Enter') calculateFlames();
Expand Down Expand Up @@ -3894,45 +3752,50 @@ function getProductivePetHTML() {


function initializeProject(projectName) {
if (activeProject === projectName) return;
activeProject = projectName;

const initializers = {
'tic-tac-toe': initTicTacToe,
'rock-paper-scissor': initRockPaperScissor,
'dice-rolling': initDiceRolling,
'coin-flip': initCoinFlip,
'number-guessing': initNumberGuessing,
'hangman': initHangman,
'word-scramble': initWordScramble,
'flames': initFlames,
'dots-boxes': initDotsBoxes,
'emoji-memory': initEmojiMemoryGame,
'fibonacci': initFibonacci,
'progression-recognizer': initProgressionRecognizer,
'pascal-triangle': initPascalTriangle,
'armstrong': initArmstrong,
'calculator': initCalculator,
'collatz': initCollatz,
'prime-analyzer': initPrimeAnalyzer,
'projectile-motion': initProjectileMotion,
'coordinate-polar-transform': initCoordinatePolarTransform,
'derivative-calculator': initDerivativeCalculator,
'morse-code': initMorseCode,
'tower-of-hanoi': initTowerOfHanoi,
'number-converter': initNumberConverter,
'typing-speed-tester': initTypingSpeedTester,
'snake-game': initSnakeGame,
'password-forge': initPasswordForge, // Register Password Forge initializer
'spot-the-difference': initSpotTheDifference,
'whack-a-mole': initWhackaMole,
'flappy-game': initFlappyGame,
'productive-pet': initProductivePet,
'simon-says': initSimonSays,
'2048-game': init2048Game,
'color-palette': initColorPalette,
'math-quiz': initMathQuiz,
'tic-tac-toe': 'initTicTacToe',
'rock-paper-scissor': 'initRockPaperScissor',
'dice-rolling': 'initDiceRolling',
'coin-flip': 'initCoinFlip',
'blackjack-21': 'initBlackjack',
'number-guessing': 'initNumberGuessing',
'hangman': 'initHangman',
'word-scramble': 'initWordScramble',
'flames': 'initFlames',
'dots-boxes': 'initDotsBoxes',
'emoji-memory': 'initEmojiMemoryGame',
'fibonacci': 'initFibonacci',
'progression-recognizer': 'initProgressionRecognizer',
'pascal-triangle': 'initPascalTriangle',
'armstrong': 'initArmstrong',
'calculator': 'initCalculator',
'collatz': 'initCollatz',
'prime-analyzer': 'initPrimeAnalyzer',
'projectile-motion': 'initProjectileMotion',
'coordinate-polar-transform': 'initCoordinatePolarTransform',
'derivative-calculator': 'initDerivativeCalculator',
'morse-code': 'initMorseCode',
'tower-of-hanoi': 'initTowerOfHanoi',
'number-converter': 'initNumberConverter',
'typing-speed-tester': 'initTypingSpeedTester',
'snake-game': 'initSnakeGame',
'password-forge': 'initPasswordForge',
'spot-the-difference': 'initSpotTheDifference',
'whack-a-mole': 'initWhackaMole',
'flappy-game': 'initFlappyGame',
'productive-pet': 'initProductivePet',
'simon-says': 'initSimonSays',
'2048-game': 'init2048Game',
'color-palette': 'initColorPalette',
'math-quiz': 'initMathQuiz'
};

if (initializers[projectName]) {
initializers[projectName]();
const initializerName = initializers[projectName];
if (initializerName && typeof window[initializerName] === 'function') {
window[initializerName]();
}
}

Expand Down
92 changes: 0 additions & 92 deletions web-app/js/projects/typing-speed-tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,98 +7,6 @@ function getTypingSpeedTesterHTML() {
min-height: auto;
padding: 1rem;
}
<div class="project-content">

<h2>⌨️ Typing Speed Tester</h2>

<p style="margin-bottom: 10px;">
Type the exact sentence shown below 👇
</p>


<div
id="typingSentence"
style="
background: var(--surface-color);
color: var(--text-color);
padding: 15px;
border-radius: 10px;
margin-bottom: 20px;
font-size: 18px;
line-height: 1.8;
min-height: 80px;
"
>
Click Start Test 🚀
</div>

<button
id="startTypingBtn"
type="button"
class="btn-generate"
style="
margin-bottom: 20px;
font-weight: 700;
font-size: 16px;
width:auto;
min-height: 44px;
padding: 12px 24px;
border-radius: 30px;
background-color:var(--accent-color);
color:white;
"
>
Start Test 🚀
</button>

<button
id="newSentenceBtn"
type="button"
class="btn-generate"
style="
margin-bottom: 20px;
margin-left: 10px;
font-weight: 700;
font-size: 16px;
width:auto;
min-height: 44px;
padding: 12px 24px;
border-radius: 30px;
background-color:#9333ea;
color:white;
"
>
🔄 New Sentence
</button>

<div>
<textarea
id="typingInput"
placeholder="Start typing here..."
rows="5"
disabled
style="
width: 100%;
padding: 15px;
border-radius: 10px;
font-size: 16px;
margin-bottom: 20px;
background: var(--surface-color);
color: var(--text-color);
border: 1px solid var(--border-color);
"
></textarea>
</div>


<div
id="typingResult"
style="
margin-top: 25px;
font-size: 18px;
line-height: 1.8;
"
></div>

.typing-tester .stage {
background: linear-gradient(180deg, rgba(34, 197, 94, 0.06), rgba(15, 23, 42, 0.04));
Expand Down
Loading