From f6aff3a0bb39fd9bea3cd9117b06540c533a8443 Mon Sep 17 00:00:00 2001 From: Kevin Geejo <74069952+KevinGeejo@users.noreply.github.com> Date: Tue, 19 Dec 2023 17:27:40 +0530 Subject: [PATCH 1/4] lol --- script.js | 23 ++++++++++++++++++----- styles.css | 12 ++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/script.js b/script.js index 62f8b69..7625dc4 100644 --- a/script.js +++ b/script.js @@ -25,7 +25,11 @@ function checkDigits(digits, tabName) { showCongratulations(tabName); } else { showAlert('Try again!', tabName); - showAlert('hint: addition of numbers', tabName); + if (digits.length > 1) { + + showAlert('hint: addition of numbers', tabName); + } + // showAlert('hint: addition of numbers', tabName); } } @@ -49,17 +53,26 @@ function showCongratulations(tabName) { } // Function to show alert message -function showAlert(message, tabName) { +function showAlert(messages, tabName) { var tab = document.getElementById(tabName); - tab.innerHTML = '
' + - message + - '
'; + var content = '
'; + + // Create content for each message + for (var i = 0; i < messages.length; i++) { + content += '' + messages[i] ; + } + + content += '
'; + + tab.innerHTML = content; + setTimeout(function() { tab.innerHTML = ''; setupTabContent(tabName); }, 2000); // Display the alert for 2 seconds } + // Setup tab content after the congratulations or alert message function setupTabContent(tabName) { if (tabName === 'oneDigit') { diff --git a/styles.css b/styles.css index 0f9f1c3..283ced4 100644 --- a/styles.css +++ b/styles.css @@ -46,6 +46,18 @@ h1 { background-color: #007bff; color: white; } +.alert-messages { + display: flex; + justify-content: center; + /* Centers the messages horizontally */ + align-items: center; + /* Centers the messages vertically */ +} + +.alert-messages span { + margin: 1 5px; + /* Adds a small gap between messages */ +} .tabContent { display: flex; From 6a749e84cc941f6c7b7faa876ce867f2b0de06c4 Mon Sep 17 00:00:00 2001 From: Kevin Geejo <74069952+KevinGeejo@users.noreply.github.com> Date: Tue, 19 Dec 2023 17:29:54 +0530 Subject: [PATCH 2/4] Update script.js --- script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.js b/script.js index 7625dc4..25c0305 100644 --- a/script.js +++ b/script.js @@ -26,7 +26,7 @@ function checkDigits(digits, tabName) { } else { showAlert('Try again!', tabName); if (digits.length > 1) { - + showAlert('Try again!', tabName); showAlert('hint: addition of numbers', tabName); } // showAlert('hint: addition of numbers', tabName); From 0a17e9961f1b6962a24a663ab3d6ca14fcff1a1a Mon Sep 17 00:00:00 2001 From: Kevin Geejo <74069952+KevinGeejo@users.noreply.github.com> Date: Tue, 19 Dec 2023 17:32:27 +0530 Subject: [PATCH 3/4] Update script.js --- script.js | 1 + 1 file changed, 1 insertion(+) diff --git a/script.js b/script.js index 25c0305..e471908 100644 --- a/script.js +++ b/script.js @@ -25,6 +25,7 @@ function checkDigits(digits, tabName) { showCongratulations(tabName); } else { showAlert('Try again!', tabName); + // Only show hint if the number of inputs taken is more than 1 if (digits.length > 1) { showAlert('Try again!', tabName); showAlert('hint: addition of numbers', tabName); From d69a4a7e86ecccb3ff4e9cfafe7c107c78de0b80 Mon Sep 17 00:00:00 2001 From: Kevin Geejo <74069952+KevinGeejo@users.noreply.github.com> Date: Tue, 19 Dec 2023 17:42:01 +0530 Subject: [PATCH 4/4] Fixed minor bug --- script.js | 10 +++++++--- styles.css | 6 ++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/script.js b/script.js index e471908..0d4056e 100644 --- a/script.js +++ b/script.js @@ -24,11 +24,11 @@ function checkDigits(digits, tabName) { if (sum === 7) { showCongratulations(tabName); } else { - showAlert('Try again!', tabName); + showAlert(['Try again!'], tabName); // Only show hint if the number of inputs taken is more than 1 if (digits.length > 1) { - showAlert('Try again!', tabName); - showAlert('hint: addition of numbers', tabName); + + showAlert(['Try again!', 'hint: addition of numbers'], tabName); } // showAlert('hint: addition of numbers', tabName); } @@ -61,6 +61,10 @@ function showAlert(messages, tabName) { // Create content for each message for (var i = 0; i < messages.length; i++) { content += '' + messages[i] ; + + if (i < messages.length - 1) { + content += '
'; + } } content += ''; diff --git a/styles.css b/styles.css index 78be94b..d9f993c 100644 --- a/styles.css +++ b/styles.css @@ -48,10 +48,8 @@ h1 { } .alert-messages { display: flex; - justify-content: center; - /* Centers the messages horizontally */ - align-items: center; - /* Centers the messages vertically */ + flex-direction: column; /* Stack messages vertically */ + align-items: center; /* Center messages horizontally */ } .alert-messages span {