Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modifying script for typing game

Status
Not open for further replies.

simonWMC

Programmer
Dec 2, 2002
180
GB
Hello

I downloaded the free script :

Code:
<HEAD>


<title>Free Typing Test Online</title>

<META NAME=&quot;keywords&quot;
CONTENT=&quot; Typing Test, online typing tests,World's Smallest Political Quiz,iq  ,universityoflife.com,online iq test,typing test, typing,typing tutor, typing tutorial,typing program, typing game,typing software, mavis beacon typing tutorial, Mavis Beacon, navis beecon, navis beacom,  Jumpstart Typing,  Learn Typing Quick & Easy 9.0, Typing Instructor Deluxe Edition 9.0,
,typing lesson, free typing tutor,free typing test,typing services  The Keirsey Temperament Sorter,free iq test, iq testing,  2ofakind.com,  iq and test, iq test online, iq score,iq quiz,Alien abduction,oline teat,fun questionaires,tieping, tiping,magazine, quizzes test tests examinations exam, New Age,Netiquette, University OF Life school of hard knocks
School Of Hard Knocks present great gift idea, Psych Web
college of experience,
Psychological tests,  Mavis Beacon Teaches Typing, All Star Typing&quot;>

<META

<META NAME=&quot;revisit-after&quot; CONTENT=&quot;30 days&quot;>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>


<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! [URL unfurl="true"]http://javascript.internet.com[/URL] -->

<!-- Begin
msg = new Array(&quot;Practicing with your typing can greatly help your overall computer skills.&quot;,
&quot;A new computer is sold in the US every hour!&quot;,
&quot;When do birds migrate from North to South?&quot;,
&quot;Perplexing phrases, like this one, are tougher to type.&quot;)
word = 10
function m() {
msg = new Array(&quot;Practicing with your typing can greatly help your overall computer skills.&quot;,
&quot;A new computer is sold in the US every hour!&quot;,
&quot;When do birds migrate from North to South?&quot;,
&quot;Perplexing phrases, like this one, are tough to type.&quot;)
word = 10
}
function e() {
msg = new Array(&quot;If you can correctly, and quickly, type this perplexing sentence, you are one superb typist!&quot;,
&quot;You are one superb typist if you can correctly, and quickly, type this long phrase.&quot;,
&quot;I believe you're a good typist, so I believe you will correctly copy this statement!&quot;,
&quot;Because this is not a fairly simple phrase, could you swiftly, and precisely, copy it?&quot;)
word = 15
}
function s() {
msg = new Array(&quot;Computers are the medium of the future.&quot;,
&quot;Can you type this phrase rather quickly?&quot;,
&quot;Who is the President of the US?&quot;,
&quot;I believe that you can type well!&quot;)
word = 7
}
function beginIt() {
randNum = Math.floor((Math.random() * 10)) % 4
msgType = msg[randNum]
day = new Date();
startType = day.getTime();
document.theForm.given.value = msgType
document.theForm.typed.focus();
document.theForm.typed.select();
}
function cheat() {
alert(&quot;You can not change that!&quot;);
document.theForm.typed.focus();
}
function stopIt() {
dayTwo = new Date();
endType = dayTwo.getTime();
totalTime = ((endType - startType) / 1000)
spd = Math.round((word/totalTime) * 60)
if (document.theForm.typed.value == document.theForm.given.value) {
alert(&quot;\nYou typed a &quot; + word + &quot; word sentence in &quot; 
+ totalTime + &quot; seconds, a speed of about &quot; + spd + &quot; words per minute!&quot;)
}
else {
alert(&quot;You made an error, but typed at a speed of &quot; + spd + &quot; words per minute.&quot;)
   }
}
// End -->
</SCRIPT>
</HEAD>
<body bgcolor=&quot;white&quot; text=&quot;TEAL&quot; link=#0000FF alink=#0000FF vlink=#FF0000>

<!-- STEP ONE: Put this code into the BODY of your HTML document  -->

<BODY>
<CENTER>



<FONT COLOR=&quot;DARKGREEN&quot;>
<h2>&nbsp; </h2>
</FONT> <B> <BR>
</B>
<FORM name=&quot;theForm&quot;>
  <div align=&quot;center&quot;></div>
  <TABLE BORDER=3 align=&quot;center&quot; CELLPADDING=0 CELLSPACING=0>
    <TR>
      <TD>Select Level.</TD>
<TD align=center><input type=radio name=&quot;sme&quot; value=&quot;Beginner&quot; onClick=&quot;s()&quot; checked>
        Practice 
        <input type=radio name=&quot;sme&quot; value=&quot;Novice&quot; onClick=&quot;m()&quot;>
        Main </TD>
</TR>
<TR><TD colspan=2><BR>
<center><input type=button value=&quot;Start Typing Test&quot; name=&quot;start&quot; onClick=&quot;beginIt()&quot;></center><P>
<textarea name=&quot;given&quot; cols=53 rows=3 wrap=on onFocus=&quot;cheat()&quot;></textarea></TD>
</TR>
<TR><TD colspan=2><center><input type=text name=&quot;typed&quot; size=45>
<input type=button value=&quot;DONE&quot;  name=&quot;stop&quot;  onClick=&quot;stopIt()&quot;></center></TD>
</TR>
</TABLE>
  <div align=&quot;center&quot;></div>
</FORM>
<BLOCKQUOTE>
<H3>
<BR><BR>


<BR><BR>


<BR><BR><BR><BR><BR><BR><BR><BR><BR>
<BR>
<BR><BR><BR><BR><BR><BR><BR><BR>
<BR><BR><BR><BR><BR><BR><BR>
<FONT COLOR=&quot;#FFFFaa&quot;><BR>

<BR>
</FONT> </HTML>

I removed the first array and the 'e' function and replaced functions m & s with custom text - however this stops the whole thing working. Does anybody one know why ?

thanks
 
i see

can you tell me what this function does ?

Code:
function beginIt() {
randNum = Math.floor((Math.random() * 10)) % 4
msgType = msg[randNum]
day = new Date();
startType = day.getTime();
document.theForm.given.value = msgType
document.theForm.typed.focus();
document.theForm.typed.select();
}
 

It generates a random number from 0 to 3, picks a message from the 'msg' array, gets the current date and time, sets the value of the form element 'given' to the selected message, and then selects the text.

Dan
 
right i think this may be sinking in - but what are the other funtions for ???
 
going back to my original post.

is it possible for me to change it to two differnant tests ? and then put a timer on each one ?

thankyou for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top