Typing test Application/game by Sanket Sinha | JavaScriptSource

Typing test Application/game by Sanket Sinha

Sanket Sinha Jan 29, 2015

Abstract

Typing test game comes with some awesome interface and will provide you a new experience. This typing application will generate random set of words and you have to type them as fast as you can but at same time be careful of what you type.

Description

Typing test game is an optimization of the earlier version with better interface and new algorithm for text generation.

Code Snippet

<!DOCTYPE html>
<html>
<head>
<style>

table{align:center;
    border:2px solid DarkRed; background-color:#CCCC99;
}
textarea{
        box-shadow: 1px 1px 0 ;
		background-color:#CCFF99;
        display: block;
        font-family: 'Marck Script',cursive;
        font-size: 22px;
        }
#text{
	background-color:#CCFF99;
	display: block;
	text-area:20;
	font-family:'Lucida Console',cursive;
	font-size: 20px;
	}		
#button{
	display: fade;
    font-weight: bold;
    color:#FF3366;
	}
	
</style>

<script>
var count=0;
var msgType="welcome,";
var msgType1="";
function r(){
	var msg=['Rat','ball','cow','dog','sat','.','kite','fan','hut','ink','junk','man','kilo','lung','monday','soon','.','sunday','poet','raw','sat','temple','user','van','xmas','now','owl','.','fun','now'];
	for(i=0;i<10;i++){
		var randNum=Math.floor((Math.random()*29)+1);
		
		if(msg[randNum]!=".")
		msgType = msgType +" "+ msg[randNum];
		else
		msgType = msgType + msg[randNum];
		count++;
	}
}	

function s(){
	var msg=['apple','because','jute','candy','dusty','enough','.','fell-off','ground','happen','India','judicial','system','know','love','eating','really','.','went','play','rotten','surely','title','under','various','expanded','data','object','.'];
	for(i=0;i<15;i++)
	{
		var randNum=Math.floor((Math.random()*28)+1);
		
		if(msg[randNum]!=".")
		msgType = msgType +" "+ msg[randNum];
		else
		msgType = msgType + msg[randNum];
		count++;
	}
}
function t(){
	
var msg =['aahing','aaliis','aarrgh','abacas',' abacus','abamps','abased','abaser','abases','forget','cofee','during','last-minute','gateways','boring','brew','amazing','conversation','over','relaxing','under','conversation','chewing','peeling','produces','starfish','breathing','ovaries','stomach','testicles','intestine']
for(i=0;i<20;i++)
	{
		var randNum=Math.floor((Math.random()*31)+1);
		
		if(msg[randNum]!=".")
		msgType = msgType +" "+ msg[randNum];
		else
		msgType = msgType + msg[randNum];
		count++;
	}

}		
function beginit(){
day = new Date();
startType = day.getTime();
document.theForm.given.value =msgType;
document.theForm.typed.focus();
document.theForm.typed.select();
}
function cheat(){
alert("You can not change that!");
document.theForm.typed.focus();
}
function stopIt() {
dayTwo = new Date();
endType = dayTwo.getTime();
totalTime = ((endType - startType) / 1000)
spd = Math.round((count/totalTime) * 60)
if(document.theForm.typed.value.length==document.theForm.given.value.length)
{
	if (document.theForm.typed.value === document.theForm.given.value)
	{
		alert("\nYou typed  " + count + " word sentence in "
		+ totalTime + " seconds, a speed of about " + spd + " words per minute!")
		window.location.reload();
	}
	else 
	{
		alert("You made some error, ")
		window.location.reload();
	}
}
else
{
	alert("You didn't typed the whole Sentence or You might have left something. "+ " " + " "+ "Next Time Type Carefully...!!");
	window.location.reload();
}
}
</script>
</head>
<body>

<form name = "theForm">

<table align=center border=5 width=59 cellpadding=1 cellspacing=1>

<tr colspan=1>
<td aign=cenetr>Are you a..</td></tr>
<tr colspan=1>
<td align=center >
<input type ="radio" name="sme" value="Beginner" onClick="r()">Beginner
<input type="radio" name="sme" value="Novice" onClick="s()">Novice
<input type="radio" name="sme" value="Expert" onClick="t()">Expert
</td>
</tr>

<tr><td colspan=1 align=center>
<input type="button" id="button" value="Start Typing Test" name="start" onClick="beginit()">
</td></tr>

<tr><td><textarea name="given" cols=53 rows=3 onFocus="cheat()"></textarea>
</td></tr>

<tr><td colspan=1><input type="text" id="text" name="typed" size=59><input type="button" id="button" value=DONE  name="stop"  onClick="stopIt()"></td>
</tr>

</table></form>
</body>
</html>

Download

Download

Leave a Response

(2 comments)

this code is not accurate i tried it and their were near 20 sintax errors and after fixing them all the code didnt work right

kenneth Mar 4, 2016

tell me java code of above code plzzzzz..... i will be very thankful to u sir,,, its my project plz....

shams May 19, 2015