Skip to content

Commit ad5e86c

Browse files
committed
Fix indentation and Flames function scope issue
1 parent b7f8af8 commit ad5e86c

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

web-app/js/projects.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// Project Registry
22
// Each project's HTML and logic lives in its own file under js/projects/
33

4+
//To Prevent duplicate intialisation
5+
let activeProject=null;
6+
47
function getProjectHTML(projectName) {
58
const projects = {
69
'rock-paper-scissor': getRockPaperScissorHTML(),
@@ -23,7 +26,7 @@ function getProjectHTML(projectName) {
2326
'morse-code': getMorseCodeHTML(),
2427
'tower-of-hanoi': getTowerOfHanoiHTML(),
2528
'number-converter': getNumberConverterHTML(),
26-
'typing-speed-tester': getTypingSpeedTesterHTML()
29+
'typing-speed-tester': getTypingSpeedTesterHTML(),
2730
'snake-game': getsnakeGameHTML(),
2831
'password-forge': getPasswordForgeHTML(),
2932
'whack-a-mole': getWhackaMoleHTML(),
@@ -33,6 +36,12 @@ function getProjectHTML(projectName) {
3336
}
3437

3538
function initializeProject(projectName) {
39+
//Prevent duplicate listeners+duplicate ui execution
40+
//if same project is already active it will not re run init
41+
if(activeProject ===projectName ) return;
42+
43+
activeProject=projectName;
44+
3645
const initializers = {
3746
'rock-paper-scissor': initRockPaperScissor,
3847
'dice-rolling': initDiceRolling,
@@ -57,6 +66,7 @@ function initializeProject(projectName) {
5766
'typing-speed-tester': initTypingSpeedTester,
5867
'snake-game': initSnakeGame,
5968
'whack-a-mole': initWhackaMole,
69+
'password-forge': initPasswordForge,
6070
};
6171

6272
if (initializers[projectName]) {
@@ -1981,9 +1991,6 @@ function initEmojiMemoryGame() {
19811991
});
19821992
}
19831993

1984-
calculateBtn.addEventListener('click', calculateFlames);
1985-
name1Input.addEventListener('keypress', (e) => {
1986-
if (e.key === 'Enter') calculateFlames();
19871994

19881995
function showSequence() {
19891996
isPlayingSequence = true;
@@ -2103,7 +2110,7 @@ function initEmojiMemoryGame() {
21032110

21042111
// ============================================
21052112
// COLLATZ CONJECTURE
2106-
// ============================================
2113+
// ===========================================
21072114
function getCollatzHTML() {
21082115
return `
21092116
<div class="project-content">

0 commit comments

Comments
 (0)