Skip to content

Commit

Permalink
Merge pull request #729 from saketh-05/fixes2
Browse files Browse the repository at this point in the history
Added TypingTest project
  • Loading branch information
SUGAM-ARORA authored Aug 10, 2024
2 parents 0935d8f + feb955d commit 803a143
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Components/CardMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ const features = [
pro: icon,
hearts: 90,
title: "TypingTest",
dev: "SophiaWilson",
dev: "Saketh D.Surya",
type: "Education",
github: "https://github.com/saketh-05/TypingTest",
role: "Web Developer, SEO Specialist",
about:
"I'm a proficient web developer and SEO specialist, dedicated to creating optimized, high-performance websites. I focus on both the technical and strategic aspects of web development to enhance visibility and user engagement.",
Expand Down
Binary file modified src/Components/projects/card7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/Components/projects/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ export const features = [
pro: icon,
hearts: 90,
title: "TypingTest",
dev: "SophiaWilson",
dev: "Saketh D.Surya",
type: "Education",
github: "https://github.com/saketh-05/TypingTest",
role: "Web Developer, SEO Specialist",
about: "I'm a proficient web developer and SEO specialist, dedicated to creating optimized, high-performance websites. I focus on both the technical and strategic aspects of web development to enhance visibility and user engagement.",
text: "TypingTest is a comprehensive platform designed to help users improve their typing speed and accuracy. This intuitive and user-friendly application offers a range of typing tests and practice exercises to suit different skill levels. With TypingTest, users can track their progress over time, identify areas for improvement, and achieve their typing goals. The platform features real-time feedback, detailed performance analytics, and personalized training plans to enhance the learning experience. TypingTest supports multiple languages and keyboard layouts, making it accessible to a global audience. Whether you're a beginner looking to learn touch typing or an experienced typist aiming to increase your speed, TypingTest provides the tools and resources to help you succeed."
Expand Down
25 changes: 25 additions & 0 deletions src/Projects/TypingTest/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Typing Test</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Typing Speed Test</h1>
<div id="test-area">
<p id="text-to-type"></p>
<textarea id="input-area" placeholder="Start typing..."></textarea>
</div>
<div id="result">
<p>Time: <span id="time">0</span> seconds</p>
<p>Errors: <span id="errors">0</span></p>
<p>WPM: <span id="wpm">0</span></p>
<button id="reset">Restart</button>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
96 changes: 96 additions & 0 deletions src/Projects/TypingTest/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Elements
const textToType = document.getElementById('text-to-type');
const inputArea = document.getElementById('input-area');
const timeDisplay = document.getElementById('time');
const errorsDisplay = document.getElementById('errors');
const wpmDisplay = document.getElementById('wpm');
const resetButton = document.getElementById('reset');

// Variables
let timer;
let time = 0;
let errors = 0;
let isTyping = false;
let offsetCheck = "";

const textTyping = ["The quick brown fox jumps over the lazy dog.",
"A journey of a thousand miles begins with a single step.",
"She sells seashells by the seashore, where the sand is soft and warm.",
"The rain in Spain stays mainly in the plain, causing the fields to remain green",
"To be or not to be, that is the question, pondered the thoughtful philosopher.",
"In the middle of difficulty lies opportunity, waiting for those who seek it.",
"The early bird catches the worm, but the second mouse gets the cheese.",
"Beneath the stars, the vast ocean whispered secrets to the moonlit sky.",
"Innovation distinguishes between a leader and a follower in every industry.",
"The beauty of the world lies in the diversity of its people and cultures."
];

const randomIndexText = () => {
const rIndex = Math.floor(Math.random() * (10));
textToType.innerText = offsetCheck = textTyping[rIndex];
};

document.addEventListener("DOMContentLoaded",() => {
randomIndexText();
});

// Functions
function startTimer() {
timer = setInterval(() => {
time++;
timeDisplay.innerText = time;
}, 1000);
}

function stopTimer() {
clearInterval(timer);
}

function calculateWPM() {
const wordsTyped = inputArea.value.trim().split(' ').length;
const wpm = Math.round((wordsTyped / time) * 60);
return wpm;
}

function resetTest() {
stopTimer();
time = 0;
errors = 0;
isTyping = false;
inputArea.value = '';
timeDisplay.innerText = time;
errorsDisplay.innerText = errors;
wpmDisplay.innerText = 0;
inputArea.disabled = false;
randomIndexText();
inputArea.focus();
}

// Event Listeners
inputArea.addEventListener('input', () => {
if (!isTyping) {
isTyping = true;
startTimer();
}

const typedText = inputArea.value;
const typedTextLength = typedText.length;

if (typedText === offsetCheck) {
stopTimer();
inputArea.disabled = true;
wpmDisplay.innerText = calculateWPM();
}

if (typedTextLength > 0) {
if (typedText[typedTextLength - 1] !== offsetCheck[typedTextLength - 1]) {
errors++;
errorsDisplay.innerText = errors;
}
}
});

resetButton.addEventListener('click', resetTest);

// Initialize
resetTest();
62 changes: 62 additions & 0 deletions src/Projects/TypingTest/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
body {
font-family: Arial, sans-serif;
background-color: #f8b7b7;
color: #333;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

.container {
text-align: center;
background-color: white;
padding: 30px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 600px;
height: auto;
}

h1 {
margin-bottom: 20px;
}

#test-area {
margin-bottom: 20px;
}

#text-to-type {
font-size: 18px;
margin-bottom: 10px;
}

#input-area {
width: 100%;
height: 100px;
padding: 10px;
font-size: 16px;
border: 1px solid #ddd;
border-radius: 4px;
}

#result {
font-size: 16px;
}

#result p {
margin: 5px 0;
}

#reset {
padding: 10px 20px;
font-size: 16px;
margin-top: 10px;
cursor: pointer;
border: none;
background-color: #007bff;
color: white;
border-radius: 4px;
}
Binary file added src/img/card7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 803a143

Please sign in to comment.