diff --git a/src/index.html b/src/index.html index b6fb6f0..4e18d69 100644 --- a/src/index.html +++ b/src/index.html @@ -1,88 +1,133 @@ - - - - Thala For A Reason - - - - - - - - -
-
- -
-

Check If you are a Thala ? + + + + Thala For A Reason + + + + +
+
+
+

+ Check If you are a Thala ?
+

+
+ + + +
+
-

-
- - -
-
- -
-

-
-
-

#ThalaForReason

-
-
- -
- +
+

+
+
+

#ThalaForReason

+
+
+ +
+ +
+
+
-
- -
- - -
-
-

- Link Copied To Clipboard -

-
-
- - - - - - - + + + + + diff --git a/src/index.js b/src/index.js index 391fd42..79f43bb 100644 --- a/src/index.js +++ b/src/index.js @@ -17,17 +17,39 @@ document.addEventListener("DOMContentLoaded", function () { } }); // index.js -const button = document.getElementsByClassName("checkButton"); +const checkButton = document.getElementById("checkButton"); +const resetButton = document.getElementById("resetButton"); +const queryInput = document.getElementById("query"); +const responseContainer = document.getElementById("resultText"); +const loadingAnimationContainer = document.getElementById("loadingAnimation"); + +function enableCheck() { + checkButton.disabled = false; + checkButton.classList.remove("hidden"); + resetButton.classList.add("hidden"); +} + +function enableReset() { + queryInput.disabled = true; + checkButton.classList.add("hidden"); + resetButton.classList.remove("hidden"); +} + +function resetContent() { + queryInput.value = ""; + queryInput.disabled = false; + responseContainer.textContent = ""; + audio.stop(); + queryInput.focus(); + enableCheck(); +} async function generateContent() { - if (button.disabled === true) { + if (checkButton.disabled === true) { return; } - - button.disabled = true; - const query = document.getElementById("query").value; - const responseContainer = document.getElementById("resultText"); - const loadingAnimationContainer = document.getElementById("loadingAnimation"); + const query = queryInput.value; + checkButton.disabled = true; //If NO input Provoided if (query.length === 0) { @@ -50,8 +72,7 @@ async function generateContent() { } audio.play(); - button.disabled = false; - + enableReset(); return; } @@ -74,8 +95,7 @@ async function generateContent() { } audio.play(); - button.disabled = false; - + enableReset(); return; } @@ -90,7 +110,7 @@ async function generateContent() { } audio.play(); - button.disabled = false; + enableReset(); return; } @@ -104,7 +124,7 @@ async function generateContent() { var sum = digits.reduce((a, b) => a + b, 0); steps.push(digits.join(" + ") + " = " + sum); temp1 = sum; - // at any moment of sum is multiple of 7 , then it stop + // at any moment of sum is multiple of 7 , then it stop if (sum % 7 == 0) { break; } @@ -116,31 +136,30 @@ async function generateContent() { if (sum % 7 == 0) { let tempv = "

Steps:

\n"; - // here we create new element so that in this element we can store the html and later on we can retreive the text from it + // here we create new element so that in this element we can store the html and later on we can retreive the text from it var tempElement = document.createElement("div"); tempElement.innerHTML = tempv; let result_preset = tempElement.innerText; // we use array bcz , the text giving output in one line. Now it will give proper output - let lines = result_preset.split('\n'); // Split the text into an array of lines + let lines = result_preset.split("\n"); // Split the text into an array of lines responseContainer.innerHTML = lines[0]; - + for (let i = 1; i < lines.length; i++) { - responseContainer.innerHTML += '
'; // Add a line break for each new line - let line = lines[i]; - - for (let j = 0; j < line.length; j++) { - // button.disabled = true; - await sleep(30); // Adjust the typing speed (milliseconds) - responseContainer.innerHTML += line[j]; - } + responseContainer.innerHTML += "
"; // Add a line break for each new line + let line = lines[i]; + + for (let j = 0; j < line.length; j++) { + // button.disabled = true; + await sleep(30); // Adjust the typing speed (milliseconds) + responseContainer.innerHTML += line[j]; + } } audio.play(); - button.disabled = false; + enableReset(); return; } - } - + } // if input is text and its sum is multiple of 7 if (query.length >= 10 && temp === "letters") { @@ -155,7 +174,7 @@ async function generateContent() { var sum = digits.reduce((a, b) => a + b, 0); steps.push(digits.join(" + ") + " = " + sum); temp1 = sum; - // at any moment of sum is multiple of 7 , then it stop + // at any moment of sum is multiple of 7 , then it stop if (sum % 7 == 0) { break; } @@ -167,32 +186,38 @@ async function generateContent() { // if sum is multiple of 7 if (sum % 7 == 0) { let tempv = - "

Steps:

\n"+"Lettercount = "+letterCount+"\n"+""; - // here we create new element so that in this element we can store the html and later on we can retreive the text from it - console.log(tempv) + "

Steps:

\n" + + "Lettercount = " + + letterCount + + "\n" + + ""; + // here we create new element so that in this element we can store the html and later on we can retreive the text from it + console.log(tempv); var tempElement = document.createElement("div"); tempElement.innerHTML = tempv; let result_preset = tempElement.innerText; // we use array bcz , the text giving output in one line. Now it will give proper output - let lines = result_preset.split('\n'); // Split the text into an array of lines + let lines = result_preset.split("\n"); // Split the text into an array of lines responseContainer.innerHTML = lines[0]; - + for (let i = 1; i < lines.length; i++) { - responseContainer.innerHTML += '
'; // Add a line break for each new line - let line = lines[i]; - - for (let j = 0; j < line.length; j++) { - // button.disabled = true; - await sleep(30); // Adjust the typing speed (milliseconds) - responseContainer.innerHTML += line[j]; - } + responseContainer.innerHTML += "
"; // Add a line break for each new line + let line = lines[i]; + + for (let j = 0; j < line.length; j++) { + // button.disabled = true; + await sleep(30); // Adjust the typing speed (milliseconds) + responseContainer.innerHTML += line[j]; + } } audio.play(); - button.disabled = false; + enableReset(); return; } - } + } loadingAnimationContainer.style.height = "100px"; // Display loading animation @@ -227,7 +252,7 @@ async function generateContent() { } audio.play(); - button.disabled = false; + enableReset(); } catch (error) { console.error("Error:", error); responseContainer.textContent = "Developer is Too Lazy to resolve bugs"; diff --git a/src/styles.css b/src/styles.css index 22062cd..48a565e 100644 --- a/src/styles.css +++ b/src/styles.css @@ -178,7 +178,9 @@ button:hover { position: absolute; bottom: 60px; } - +.hidden { + display: none; +} .eyes { top: -40px; display: flex;