Skip to content

Commit 49d132d

Browse files
Merge branch 'main' into feature/snake-game-pause-resume
2 parents ff2ae6d + 5e0f686 commit 49d132d

2 files changed

Lines changed: 41 additions & 271 deletions

File tree

web-app/js/projects.js

Lines changed: 41 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -52,46 +52,7 @@ function getProjectHTML(projectName) {
5252
}
5353
}
5454

55-
function initializeProject(projectName) {
56-
//Prevent duplicate listeners+duplicate ui execution
57-
//if same project is already active it will not re run init
58-
if(activeProject ===projectName ) return;
59-
60-
activeProject=projectName;
6155

62-
const initializers = {
63-
'rock-paper-scissor': initRockPaperScissor,
64-
'dice-rolling': initDiceRolling,
65-
'coin-flip': initCoinFlip,
66-
'blackjack-21' : initBlackjack,
67-
'number-guessing': initNumberGuessing,
68-
'hangman': initHangman,
69-
'flames': initFlames,
70-
'fibonacci': initFibonacci,
71-
'progression-recognizer': initProgressionRecognizer,
72-
'pascal-triangle': initPascalTriangle,
73-
'armstrong': initArmstrong,
74-
'calculator': initCalculator,
75-
'collatz': initCollatz,
76-
'prime-analyzer': initPrimeAnalyzer,
77-
'projectile-motion': initProjectileMotion,
78-
'coordinate-polar-transform': initCoordinatePolarTransform,
79-
'derivative-calculator': initDerivativeCalculator,
80-
'morse-code': initMorseCode,
81-
'tower-of-hanoi': initTowerOfHanoi,
82-
'number-converter': initNumberConverter,
83-
'typing-speed-tester': initTypingSpeedTester,
84-
'snake-game': initSnakeGame,
85-
'whack-a-mole': initWhackaMole,
86-
'password-forge': initPasswordForge,
87-
'2048-game': init2048Game, // Added explicit mapped hook definition binding reference
88-
'typing-speed-tester': initTypingSpeedTester
89-
};
90-
91-
if (initializers[projectName]) {
92-
initializers[projectName]();
93-
}
94-
}
9556

9657
// ============================================
9758
// ROCK PAPER SCISSORS
@@ -1856,110 +1817,6 @@ function initFlames() {
18561817
`;
18571818
}
18581819

1859-
1860-
function showSequence() {
1861-
isPlayingSequence = true;
1862-
disableButtons(true);
1863-
displayContent.textContent = "Watch the sequence...";
1864-
1865-
let i = 0;
1866-
const playNextEmoji = () => {
1867-
if (i < sequence.length) {
1868-
const emoji = sequence[i];
1869-
const button = Array.from(emojiButtons).find(btn => btn.dataset.emoji === emoji);
1870-
1871-
if (button) {
1872-
button.classList.add('active');
1873-
setTimeout(() => {
1874-
button.classList.remove('active');
1875-
i++;
1876-
setTimeout(playNextEmoji, 500);
1877-
}, 600);
1878-
}
1879-
} else {
1880-
isPlayingSequence = false;
1881-
disableButtons(false);
1882-
userSequence = [];
1883-
gameActive = true;
1884-
displayContent.textContent = "Your turn! Click the emojis...";
1885-
instructionsDiv.textContent = `👆 Repeat the sequence (${sequence.length} steps)`;
1886-
}
1887-
};
1888-
1889-
playNextEmoji();
1890-
}
1891-
1892-
function startNewRound() {
1893-
const newEmoji = emojis[Math.floor(Math.random() * emojis.length)];
1894-
sequence.push(newEmoji);
1895-
userSequence = [];
1896-
1897-
sequenceLengthDisplay.textContent = sequence.length;
1898-
setTimeout(showSequence, 500);
1899-
}
1900-
1901-
function handleEmojiClick(emoji, button) {
1902-
if (isPlayingSequence || !gameActive) return;
1903-
1904-
userSequence.push(emoji);
1905-
button.classList.add('active');
1906-
1907-
setTimeout(() => {
1908-
button.classList.remove('active');
1909-
}, 300);
1910-
1911-
// Check if the emoji matches
1912-
if (userSequence[userSequence.length - 1] !== sequence[userSequence.length - 1]) {
1913-
gameOver();
1914-
return;
1915-
}
1916-
1917-
// Check if the entire sequence is correct
1918-
if (userSequence.length === sequence.length) {
1919-
score += level * 10;
1920-
scoreDisplay.textContent = score;
1921-
level++;
1922-
levelDisplay.textContent = level;
1923-
1924-
instructionsDiv.textContent = "✅ Correct! Get ready for the next round...";
1925-
gameActive = false;
1926-
setTimeout(startNewRound, 1500);
1927-
}
1928-
}
1929-
1930-
function gameOver() {
1931-
gameActive = false;
1932-
disableButtons(true);
1933-
instructionsDiv.textContent = `❌ Game Over! You reached Level ${level} with Score: ${score}`;
1934-
displayContent.textContent = `Final Score: ${score}`;
1935-
startBtn.textContent = "▶️ PLAY AGAIN";
1936-
}
1937-
1938-
function resetGame() {
1939-
sequence = [];
1940-
userSequence = [];
1941-
score = 0;
1942-
level = 1;
1943-
gameActive = false;
1944-
isPlayingSequence = false;
1945-
1946-
scoreDisplay.textContent = '0';
1947-
levelDisplay.textContent = '1';
1948-
sequenceLengthDisplay.textContent = '0';
1949-
instructionsDiv.textContent = "👇 Click START to begin the game!";
1950-
displayContent.textContent = "Ready to test your memory?";
1951-
startBtn.textContent = "▶️ START";
1952-
1953-
disableButtons(true);
1954-
}
1955-
1956-
startBtn.addEventListener('click', () => {
1957-
resetGame();
1958-
gameActive = true;
1959-
instructionsDiv.textContent = "Watch the sequence...";
1960-
startNewRound();
1961-
});
1962-
19631820
calculateBtn.addEventListener('click', calculateFlames);
19641821
name1Input.addEventListener('keypress', (e) => {
19651822
if (e.key === 'Enter') calculateFlames();
@@ -3871,45 +3728,50 @@ function getProductivePetHTML() {
38713728

38723729

38733730
function initializeProject(projectName) {
3731+
if (activeProject === projectName) return;
3732+
activeProject = projectName;
3733+
38743734
const initializers = {
3875-
'tic-tac-toe': initTicTacToe,
3876-
'rock-paper-scissor': initRockPaperScissor,
3877-
'dice-rolling': initDiceRolling,
3878-
'coin-flip': initCoinFlip,
3879-
'number-guessing': initNumberGuessing,
3880-
'hangman': initHangman,
3881-
'word-scramble': initWordScramble,
3882-
'flames': initFlames,
3883-
'dots-boxes': initDotsBoxes,
3884-
'emoji-memory': initEmojiMemoryGame,
3885-
'fibonacci': initFibonacci,
3886-
'progression-recognizer': initProgressionRecognizer,
3887-
'pascal-triangle': initPascalTriangle,
3888-
'armstrong': initArmstrong,
3889-
'calculator': initCalculator,
3890-
'collatz': initCollatz,
3891-
'prime-analyzer': initPrimeAnalyzer,
3892-
'projectile-motion': initProjectileMotion,
3893-
'coordinate-polar-transform': initCoordinatePolarTransform,
3894-
'derivative-calculator': initDerivativeCalculator,
3895-
'morse-code': initMorseCode,
3896-
'tower-of-hanoi': initTowerOfHanoi,
3897-
'number-converter': initNumberConverter,
3898-
'typing-speed-tester': initTypingSpeedTester,
3899-
'snake-game': initSnakeGame,
3900-
'password-forge': initPasswordForge, // Register Password Forge initializer
3901-
'spot-the-difference': initSpotTheDifference,
3902-
'whack-a-mole': initWhackaMole,
3903-
'flappy-game': initFlappyGame,
3904-
'productive-pet': initProductivePet,
3905-
'simon-says': initSimonSays,
3906-
'2048-game': init2048Game,
3907-
'color-palette': initColorPalette,
3908-
'math-quiz': initMathQuiz,
3735+
'tic-tac-toe': 'initTicTacToe',
3736+
'rock-paper-scissor': 'initRockPaperScissor',
3737+
'dice-rolling': 'initDiceRolling',
3738+
'coin-flip': 'initCoinFlip',
3739+
'blackjack-21': 'initBlackjack',
3740+
'number-guessing': 'initNumberGuessing',
3741+
'hangman': 'initHangman',
3742+
'word-scramble': 'initWordScramble',
3743+
'flames': 'initFlames',
3744+
'dots-boxes': 'initDotsBoxes',
3745+
'emoji-memory': 'initEmojiMemoryGame',
3746+
'fibonacci': 'initFibonacci',
3747+
'progression-recognizer': 'initProgressionRecognizer',
3748+
'pascal-triangle': 'initPascalTriangle',
3749+
'armstrong': 'initArmstrong',
3750+
'calculator': 'initCalculator',
3751+
'collatz': 'initCollatz',
3752+
'prime-analyzer': 'initPrimeAnalyzer',
3753+
'projectile-motion': 'initProjectileMotion',
3754+
'coordinate-polar-transform': 'initCoordinatePolarTransform',
3755+
'derivative-calculator': 'initDerivativeCalculator',
3756+
'morse-code': 'initMorseCode',
3757+
'tower-of-hanoi': 'initTowerOfHanoi',
3758+
'number-converter': 'initNumberConverter',
3759+
'typing-speed-tester': 'initTypingSpeedTester',
3760+
'snake-game': 'initSnakeGame',
3761+
'password-forge': 'initPasswordForge',
3762+
'spot-the-difference': 'initSpotTheDifference',
3763+
'whack-a-mole': 'initWhackaMole',
3764+
'flappy-game': 'initFlappyGame',
3765+
'productive-pet': 'initProductivePet',
3766+
'simon-says': 'initSimonSays',
3767+
'2048-game': 'init2048Game',
3768+
'color-palette': 'initColorPalette',
3769+
'math-quiz': 'initMathQuiz'
39093770
};
39103771

3911-
if (initializers[projectName]) {
3912-
initializers[projectName]();
3772+
const initializerName = initializers[projectName];
3773+
if (initializerName && typeof window[initializerName] === 'function') {
3774+
window[initializerName]();
39133775
}
39143776
}
39153777

web-app/js/projects/typing-speed-tester.js

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -7,98 +7,6 @@ function getTypingSpeedTesterHTML() {
77
min-height: auto;
88
padding: 1rem;
99
}
10-
<div class="project-content">
11-
12-
<h2>⌨️ Typing Speed Tester</h2>
13-
14-
<p style="margin-bottom: 10px;">
15-
Type the exact sentence shown below 👇
16-
</p>
17-
18-
19-
<div
20-
id="typingSentence"
21-
style="
22-
background: var(--surface-color);
23-
color: var(--text-color);
24-
padding: 15px;
25-
border-radius: 10px;
26-
margin-bottom: 20px;
27-
font-size: 18px;
28-
line-height: 1.8;
29-
min-height: 80px;
30-
"
31-
>
32-
Click Start Test 🚀
33-
</div>
34-
35-
<button
36-
id="startTypingBtn"
37-
type="button"
38-
class="btn-generate"
39-
style="
40-
margin-bottom: 20px;
41-
font-weight: 700;
42-
font-size: 16px;
43-
width:auto;
44-
min-height: 44px;
45-
padding: 12px 24px;
46-
border-radius: 30px;
47-
background-color:var(--accent-color);
48-
color:white;
49-
"
50-
>
51-
Start Test 🚀
52-
</button>
53-
54-
<button
55-
id="newSentenceBtn"
56-
type="button"
57-
class="btn-generate"
58-
style="
59-
margin-bottom: 20px;
60-
margin-left: 10px;
61-
font-weight: 700;
62-
font-size: 16px;
63-
width:auto;
64-
min-height: 44px;
65-
padding: 12px 24px;
66-
border-radius: 30px;
67-
background-color:#9333ea;
68-
color:white;
69-
"
70-
>
71-
🔄 New Sentence
72-
</button>
73-
74-
<div>
75-
<textarea
76-
id="typingInput"
77-
placeholder="Start typing here..."
78-
rows="5"
79-
disabled
80-
style="
81-
width: 100%;
82-
padding: 15px;
83-
border-radius: 10px;
84-
font-size: 16px;
85-
margin-bottom: 20px;
86-
background: var(--surface-color);
87-
color: var(--text-color);
88-
border: 1px solid var(--border-color);
89-
"
90-
></textarea>
91-
</div>
92-
93-
94-
<div
95-
id="typingResult"
96-
style="
97-
margin-top: 25px;
98-
font-size: 18px;
99-
line-height: 1.8;
100-
"
101-
></div>
10210
10311
.typing-tester .stage {
10412
background: linear-gradient(180deg, rgba(34, 197, 94, 0.06), rgba(15, 23, 42, 0.04));

0 commit comments

Comments
 (0)