Practice your typing skills with a quote from Sherlock Holmes. Click **start** to begin!
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/typing-game-solution/script.js b/typing-game-solution/script.js
new file mode 100644
index 0000000..6335f6f
--- /dev/null
+++ b/typing-game-solution/script.js
@@ -0,0 +1,86 @@
+// inside script.js
+// all of our quotes
+const quotes = [
+ 'When you have eliminated the impossible, whatever remains, however improbable, must be the truth.',
+ 'There is nothing more deceptive than an obvious fact.',
+ 'I ought to know by this time that when a fact appears to be opposed to a long train of deductions it invariably proves to be capable of bearing some other interpretation.',
+ 'I never make exceptions. An exception disproves the rule.',
+ 'What one man can invent another can discover.',
+ 'Nothing clears up a case so much as stating it to another person.',
+ 'Education never ends, Watson. It is a series of lessons, with the greatest for the last.',
+];
+// store the list of words and the index of the word the player is currently typing
+let words = [];
+let wordIndex = 0;
+// the starting time
+let startTime = Date.now();
+// page elements
+const quoteElement = document.getElementById('quote');
+const messageElement = document.getElementById('message');
+const typedValueElement = document.getElementById('typed-value');
+
+// at the end of script.js
+document.getElementById('start').addEventListener('click', () => {
+ // get a quote
+ const quoteIndex = Math.floor(Math.random() * quotes.length);
+ const quote = quotes[quoteIndex];
+ // Put the quote into an array of words
+ words = quote.split(' ');
+ // reset the word index for tracking
+ wordIndex = 0;
+
+ // UI updates
+ // Create an array of span elements so we can set a class
+ const spanWords = words.map(function(word) { return `${word} `});
+ // Convert into string and set as innerHTML on quote display
+ quoteElement.innerHTML = spanWords.join('');
+ // Highlight the first word
+ quoteElement.childNodes[0].className = 'highlight';
+ // Clear any prior messages
+ messageElement.innerText = '';
+
+ // Setup the textbox
+ // Clear the textbox
+ typedValueElement.value = '';
+ // set focus
+ typedValueElement.focus();
+ // set the event handler
+
+ // Start the timer
+ startTime = new Date().getTime();
+ });
+
+ // at the end of script.js
+typedValueElement.addEventListener('input', () => {
+ // Get the current word
+ const currentWord = words[wordIndex];
+ // get the current value
+ const typedValue = typedValueElement.value;
+
+ if (typedValue === currentWord && wordIndex === words.length - 1) {
+ // end of sentence
+ // Display success
+ const elapsedTime = new Date().getTime() - startTime;
+ const message = `CONGRATULATIONS! You finished in ${elapsedTime / 1000} seconds.`;
+ messageElement.innerText = message;
+ } else if (typedValue.endsWith(' ') && typedValue.trim() === currentWord) {
+ // end of word
+ // clear the typedValueElement for the new word
+ typedValueElement.value = '';
+ // move to the next word
+ wordIndex++;
+ // reset the class name for all elements in quote
+ for (const wordElement of quoteElement.childNodes) {
+ wordElement.className = '';
+ }
+ // highlight the new word
+ quoteElement.childNodes[wordIndex].className = 'highlight';
+ } else if (currentWord.startsWith(typedValue)) {
+ // currently correct
+ // highlight the next word
+ typedValueElement.className = '';
+ } else {
+ // error state
+ typedValueElement.className = 'error';
+ }
+ });
\ No newline at end of file
diff --git a/typing-game-solution/style.css b/typing-game-solution/style.css
new file mode 100644
index 0000000..ed4d988
--- /dev/null
+++ b/typing-game-solution/style.css
@@ -0,0 +1,8 @@
+.highlight {
+ background-color: yellow;
+ }
+
+ .error {
+ background-color: lightcoral;
+ border: red;
+ }
\ No newline at end of file
From 8ebb3b35db69c2f4e0339afaa514f5464646f966 Mon Sep 17 00:00:00 2001
From: Rohit Reddy <5668.rohit@gmail.com>
Date: Thu, 27 Feb 2025 01:55:35 +0530
Subject: [PATCH 3/7] Added code
---
typing-game-solution/index.html | 15 ++++---
typing-game-solution/script.js | 74 +++++++++++++++++++--------------
typing-game-solution/style.css | 54 ++++++++++++++++++++++--
3 files changed, 103 insertions(+), 40 deletions(-)
diff --git a/typing-game-solution/index.html b/typing-game-solution/index.html
index 04ec901..dfb0d31 100644
--- a/typing-game-solution/index.html
+++ b/typing-game-solution/index.html
@@ -2,14 +2,19 @@
Typing game
+
+
+
-
Typing game!
-
Practice your typing skills with a quote from Sherlock Holmes. Click **start** to begin!
-
-
-
+
Typing game !
+
Practice your typing skills with a quote from Sherlock Holmes. Click **start** to begin!
+
+
+
+
+
diff --git a/typing-game-solution/script.js b/typing-game-solution/script.js
index 6335f6f..e730b1b 100644
--- a/typing-game-solution/script.js
+++ b/typing-game-solution/script.js
@@ -8,6 +8,9 @@ const quotes = [
'What one man can invent another can discover.',
'Nothing clears up a case so much as stating it to another person.',
'Education never ends, Watson. It is a series of lessons, with the greatest for the last.',
+ 'Mediocrity knows nothing higher than itself; but talent instantly recognizes genius.',
+ 'What you do in this world is a matter of no consequence. The question is what can you make people believe you have done.',
+ 'Crime is common. Logic is rare. Therefore it is upon the logic rather than upon the crime that you should dwell.',
];
// store the list of words and the index of the word the player is currently typing
let words = [];
@@ -22,6 +25,7 @@ const typedValueElement = document.getElementById('typed-value');
// at the end of script.js
document.getElementById('start').addEventListener('click', () => {
// get a quote
+ typedValueElement.className = 'typing-start';
const quoteIndex = Math.floor(Math.random() * quotes.length);
const quote = quotes[quoteIndex];
// Put the quote into an array of words
@@ -51,36 +55,42 @@ document.getElementById('start').addEventListener('click', () => {
});
// at the end of script.js
-typedValueElement.addEventListener('input', () => {
- // Get the current word
- const currentWord = words[wordIndex];
- // get the current value
- const typedValue = typedValueElement.value;
-
- if (typedValue === currentWord && wordIndex === words.length - 1) {
- // end of sentence
- // Display success
- const elapsedTime = new Date().getTime() - startTime;
- const message = `CONGRATULATIONS! You finished in ${elapsedTime / 1000} seconds.`;
- messageElement.innerText = message;
- } else if (typedValue.endsWith(' ') && typedValue.trim() === currentWord) {
- // end of word
- // clear the typedValueElement for the new word
- typedValueElement.value = '';
- // move to the next word
- wordIndex++;
- // reset the class name for all elements in quote
- for (const wordElement of quoteElement.childNodes) {
- wordElement.className = '';
- }
- // highlight the new word
- quoteElement.childNodes[wordIndex].className = 'highlight';
- } else if (currentWord.startsWith(typedValue)) {
- // currently correct
- // highlight the next word
- typedValueElement.className = '';
- } else {
- // error state
- typedValueElement.className = 'error';
+typedValueElement.addEventListener('input', getInput);
+
+
+
+function getInput(){
+ // Get the current word
+ const currentWord = words[wordIndex];
+ // get the current value
+ const typedValue = typedValueElement.value;
+
+ if (typedValue === currentWord && wordIndex === words.length - 1) {
+ // end of sentence
+ // Display success
+ const elapsedTime = new Date().getTime() - startTime;
+ const message = `CONGRATULATIONS! You finished in ${elapsedTime / 1000} seconds.`;
+ messageElement.innerText = message;
+ typedValueElement.removeEventListener('input',getInput);
+ typedValueElement.className = 'typing-end';
+ } else if (typedValue.endsWith(' ') && typedValue.trim() === currentWord) {
+ // end of word
+ // clear the typedValueElement for the new word
+ typedValueElement.value = '';
+ // move to the next word
+ wordIndex++;
+ // reset the class name for all elements in quote
+ for (const wordElement of quoteElement.childNodes) {
+ wordElement.className = '';
}
- });
\ No newline at end of file
+ // highlight the new word
+ quoteElement.childNodes[wordIndex].className = 'highlight';
+ } else if (currentWord.startsWith(typedValue)) {
+ // currently correct
+ // highlight the next word
+ typedValueElement.className = 'typing-start';
+ } else {
+ // error state
+ typedValueElement.className = 'error';
+ }
+}
\ No newline at end of file
diff --git a/typing-game-solution/style.css b/typing-game-solution/style.css
index ed4d988..26c2c92 100644
--- a/typing-game-solution/style.css
+++ b/typing-game-solution/style.css
@@ -1,8 +1,56 @@
.highlight {
- background-color: yellow;
+ background-color: rgb(102, 255, 0);
}
- .error {
+.error {
background-color: lightcoral;
border: red;
- }
\ No newline at end of file
+ width: 220px;
+ height: 45px;
+ font-size: 25px;
+ font-weight: bolder;
+ }
+
+body{
+ background-color: rgb(12, 2, 2);
+}
+
+h1{
+ font-family: 'Fondamento',serif;
+ font-size: 80px;
+ color: blueviolet;
+ text-align: center;
+ }
+
+p{
+ font-family: 'Fondamento',serif;
+ font-size: 40px;
+ color: yellow;
+ text-align: center;
+}
+
+.typing-start {
+ width: 220px;
+ height: 45px;
+ font-size: 25px;
+ font-weight: bolder;
+}
+
+.typing-end {
+ width: 0px;
+ height: 0px;
+}
+
+button{
+ height: 45px;
+ margin-left: 30px;
+ border-color: white;
+ width: 70px;
+ font-size: 20px;
+ font-weight: bolder;
+}
+
+.typing{
+ margin-top: 90px;
+ margin-left: 40%;
+}
\ No newline at end of file
From e359c9b66d58d7f2c6d37e0a1c6542e68956ef20 Mon Sep 17 00:00:00 2001
From: Rohit Reddy <5668.rohit@gmail.com>
Date: Fri, 28 Feb 2025 17:30:34 +0530
Subject: [PATCH 4/7] Added code
---
typing-game-solution/index.html | 2 +-
typing-game-solution/script.js | 7 ++++---
typing-game-solution/style.css | 12 +++++++++---
3 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/typing-game-solution/index.html b/typing-game-solution/index.html
index dfb0d31..0e388e3 100644
--- a/typing-game-solution/index.html
+++ b/typing-game-solution/index.html
@@ -14,7 +14,7 @@
Typing game !
-
+
diff --git a/typing-game-solution/script.js b/typing-game-solution/script.js
index e730b1b..fd55fa7 100644
--- a/typing-game-solution/script.js
+++ b/typing-game-solution/script.js
@@ -25,7 +25,7 @@ const typedValueElement = document.getElementById('typed-value');
// at the end of script.js
document.getElementById('start').addEventListener('click', () => {
// get a quote
- typedValueElement.className = 'typing-start';
+ typedValueElement.disabled=false;
const quoteIndex = Math.floor(Math.random() * quotes.length);
const quote = quotes[quoteIndex];
// Put the quote into an array of words
@@ -72,7 +72,7 @@ function getInput(){
const message = `CONGRATULATIONS! You finished in ${elapsedTime / 1000} seconds.`;
messageElement.innerText = message;
typedValueElement.removeEventListener('input',getInput);
- typedValueElement.className = 'typing-end';
+ typedValueElement.disabled=true;
} else if (typedValue.endsWith(' ') && typedValue.trim() === currentWord) {
// end of word
// clear the typedValueElement for the new word
@@ -88,7 +88,8 @@ function getInput(){
} else if (currentWord.startsWith(typedValue)) {
// currently correct
// highlight the next word
- typedValueElement.className = 'typing-start';
+ typedValueElement.className='';
+ typedValueElement.disabled=false;
} else {
// error state
typedValueElement.className = 'error';
diff --git a/typing-game-solution/style.css b/typing-game-solution/style.css
index 26c2c92..a366906 100644
--- a/typing-game-solution/style.css
+++ b/typing-game-solution/style.css
@@ -1,5 +1,5 @@
.highlight {
- background-color: rgb(102, 255, 0);
+ background-color: rgb(7, 182, 235);
}
.error {
@@ -29,16 +29,22 @@ p{
text-align: center;
}
-.typing-start {
+input {
width: 220px;
height: 45px;
font-size: 25px;
font-weight: bolder;
}
-.typing-end {
+input:disabled {
width: 0px;
height: 0px;
+ background-color: rgb(12, 2, 2);
+}
+
+input:focus{
+ outline: none;
+ border: none;
}
button{
From f014bebac43e6b4112a66064ea6af7492ef7ba37 Mon Sep 17 00:00:00 2001
From: Rohit Reddy <5668.rohit@gmail.com>
Date: Mon, 3 Mar 2025 23:53:29 +0530
Subject: [PATCH 5/7] Added the assignment folder
---
tic-tac-toe/index.html | 33 +++++++++++++++
tic-tac-toe/script.js | 94 ++++++++++++++++++++++++++++++++++++++++++
tic-tac-toe/styles.css | 42 +++++++++++++++++++
3 files changed, 169 insertions(+)
create mode 100644 tic-tac-toe/index.html
create mode 100644 tic-tac-toe/script.js
create mode 100644 tic-tac-toe/styles.css
diff --git a/tic-tac-toe/index.html b/tic-tac-toe/index.html
new file mode 100644
index 0000000..2434b61
--- /dev/null
+++ b/tic-tac-toe/index.html
@@ -0,0 +1,33 @@
+
+
+
+
+
+ Tic-Tac-Toe
+
+
+
+