Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing Master #3014

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions Games/Typing master/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
@import url('https://fonts.googleapis.com/css2?family=Josefin+Sans:wght@400;600;700&family=Lexend+Deca:wght@100;200;300;400;500;600;700&family=Poppins:wght@300;400;600&display=swap');

*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}

html{
font-size: 62.5%;
}

body{
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: rgba(191, 172, 226, 0.35);
}

.typing-section{
text-align: center;
}

#textarea{
border: .1rem solid #A084DC;
border-radius: 1rem;
max-width: 50rem;
width: 50rem;
height: 20rem;
padding: 1rem 2rem;
font-size: 1.6rem;
}

#btn{
display: inline-block;
padding: 1rem 2.4rem;
border: none;
border-radius: 1rem;
background-color: #645CBB;
color: #fff;
font-size: 1.8rem;
margin-top: 1.6rem;
}

h2{
font-size: 2.4rem;
text-transform: capitalize;
color: #645CBB;
text-align: center;
}

#showSentence, #score{
font-size: 1.6rem;
margin: 2rem 0;
letter-spacing: .02rem;
text-align: center;
}
26 changes: 26 additions & 0 deletions Games/Typing master/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>typing test</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>

<section class="main-body">
<h2>typing Speed test</h2>
<p id="showSentence"></p>

<div class="typing_section">
<label for="textarea"></label>
<textarea name="textarea" id="textarea" cols="30" rows="10" disabled></textarea>
<br>
<button id="btn">Start</button>
</div>

<p id="score"></p>
</section>

<script src="js/index.js"></script>
</body>
</html>
76 changes: 76 additions & 0 deletions Games/Typing master/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// (actualWords / totalTimeTaken) * 60;

const typing_ground = document.querySelector('#textarea');
const btn = document.querySelector('#btn');
const score = document.querySelector('#score');
const show_sentence = document.querySelector('#showSentence');

let startTime, endTime, totalTimeTaken;


const sentences = ['The quick brown fox jumps over the lazy dog 1',
'The quick brown fox jumps over the lazy dog 2',
'The quick brown fox jumps over the lazy dog 3 ']

// step 5

const calculateTypingSpeed = (time_taken) => {
let totalWords = typing_ground.value.trim();
let actualWords = totalWords === '' ? 0 : totalWords.split(" ").length;

if(actualWords !== 0) {
let typing_speed = (actualWords / time_taken) * 60;
typing_speed = Math.round(typing_speed);
score.innerHTML = `Your typing speed is ${typing_speed} words per minutes & you wrote ${actualWords} words & time taken ${time_taken} sec`;
}else{
score.innerHTML = `Your typing speed is 0 words per minutes & time taken ${time_taken} sec`;
}
}

// step 4
const endTypingTest = () => {
btn.innerText = "Start";

let date = new Date();
endTime = date.getTime();

totalTimeTaken = (endTime -startTime) / 1000;

// console.log(totalTimeTaken);

calculateTypingSpeed(totalTimeTaken);

show_sentence.innerHTML = "";
typing_ground.value = "";
}


// step 3
const startTyping = () => {
let randomNumber = Math.floor(Math.random() * sentences.length);
// console.log(randomNumber);
show_sentence.innerHTML = sentences[randomNumber];

let date = new Date();
startTime = date.getTime();

btn.innerText = "Done";
}




// step 2
btn.addEventListener('click', () => {
switch (btn.innerText.toLowerCase()) {
case "start":
typing_ground.removeAttribute('disabled');
startTyping();
break;

case "done":
typing_ground.setAttribute('disabled' , 'true');
endTypingTest();
break;
}
})
28 changes: 28 additions & 0 deletions Games/Typing master/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# **Game_Name**
Typing Master
---

<br>

## **Description πŸ“ƒ**
<!-- add your game description here -->
In this gane you get the time how much time taken to write words


-


## **Screenshots πŸ“Έ**
![image](https://github.com/kunjgit/GameZone/assets/98798977/0d9776f6-ef7f-4ee9-bf99-80e97c092dea)

<br>
<!-- add your screenshots like this -->
<!-- ![image](url) -->

<br>

## **Working video πŸ“Ή**
<!-- add your working video over here -->

https://github.com/kunjgit/GameZone/assets/98798977/df633994-5af1-465e-854d-cd4a8ff65ef3

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ This repository also provides one such platforms where contributers come over an
| 383 | [Puzzel_Winner](https://github.com/kunjgit/GameZone/tree/main/Games/Puzzel_Winner)|
| 384 | [Emoji_Intruder](https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_Intruder)|
| 385 | [Guess The Weapon](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Weapon)|
| 386 | [Typing Master](https://github.com/kunjgit/GameZone/tree/main/Games/Typing Master)|
</center>

<br>
Expand Down
Binary file added assets/images/Typing Master.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading