📄 typingtest.htm
字号:
checkStatusInt=setTimeout('calcStat();',250);
//Declare reference variables to the statistical information labels
var tStat = document.getElementById("stat_wpm");
var tTT = document.getElementById("stat_timeleft");
var tProg = document.getElementById("stProg");
var tProgt = document.getElementById("thisProg");
var tArea = document.getElementById("TypeArea");
var aArea = document.getElementById("AfterAction");
var eArea = document.getElementById("expectedArea");
//Refer to 1A (above) for details on why we are removing the double space
var thisTyped = document.JobOp.typed.value.replace(/ /g, " ");
//Create a temp variable with the current time of day to calculate the WPM
eDay = new Date();
endType = eDay.getTime();
totalTime = ((endType - startType) / 1000)
//Calculate the typing speed by taking the number of valid words typed by the total time taken and multiplying it by one minute in seconds (60)
wpmType = Math.round(((thisTyped.split(" ").length)/totalTime) * 60)
//Set the words per minute variable on the statistical information block
tStat.innerText=wpmType + " WPM";
//The test has started apparantly, so disable the stop button
document.JobOp.stop.disabled = false;
//Flip the stop and start button display status
document.JobOp.stop.style.display="block";
document.JobOp.start.style.display="none";
//Calculate and show the time taken to reach this point of the test and also the remaining time left in the test
//Colorize it based on the time left (red if less than 5 seconds, orange if less than 15)
if (Number(60-totalTime) < 5)
{
tTT.innerHTML="<font color=\"Red\">" + String(totalTime.toFixed(2)) + " sec. / " + String(Number(60-totalTime).toFixed(2)) + " sec.</font>";
}
else
{
if (Number(60-totalTime) < 15)
{
tTT.innerHTML="<font color=\"Orange\">" + String(totalTime.toFixed(2)) + " sec. / " + String(Number(60-totalTime).toFixed(2)) + " sec.</font>";
}
else
{
tTT.innerHTML=String(totalTime.toFixed(2)) + " sec. / " + String(Number(60-totalTime).toFixed(2)) + " sec.";
}
}
//Determine if the user has typed all of the words expected
if ((((thisTyped.split(" ").length)/word)*100).toFixed(2) >= 100)
{
tProg.width="100%";
tProgt.innerText = "100%";
}
else
{
//Set the progress bar with the exact percentage of the test completed
tProg.width=String((((thisTyped.split(" ").length)/word)*100).toFixed(2))+"%";
tProgt.innerText = tProg.width;
}
//Determine if the test is complete based on them having typed everything exactly as expected
if (thisTyped.value == document.JobOp.given.value)
{
endTest();
}
//Determine if the test is complete based on whether or not they have typed exactly or exceeded the number of valid words (determined by a space)
if (word <= (thisTyped.split(" ").length))
{
endTest();
}
//Check the timer; stop the test if we are at or exceeded 60 seconds
if (totalTime >= 60)
{
endTest();
}
//Our handy error handling
} catch(e){};
}
//Simply does a check on focus to determine if the test has started
function doCheck()
{
if (hasStarted == false)
{
//The test has not started, but the user is typing already -- maybe we should start?
beginTest(); //Yes, we should -- consider it done!
}
}
</SCRIPT>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="border-bottom: 2px solid #354562; padding: 4px" class="titlec">
<input disabled id="printB" onclick="window.print();" type="button" value="Print Results" name="printB" style="float: right; font-size: 8pt; font-family: Arial"><input onclick="document.getElementById('AfterAction').style.display='none';document.getElementById('expectedArea').style.display='block';document.getElementById('typeArea').style.display='block';document.JobOp.typed.value='';document.JobOp.typed.disabled=false;randNum = Math.floor((Math.random() * 10)) % intToTestCnt;strToTestType = strToTest[randNum];document.JobOp.given.value = strToTestType;" type="button" value="New Test" name="newtest" style="float: right; font-size: 8pt; font-family: Arial">ITS Typing Test System</td>
</tr>
</table>
</div>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="border-bottom: 1px dotted #860E36; padding: 4px" class="titlea" background="Images/Lt_Red_Back.gif" width="460">
Accurately and precisely
evaluate your typing speed
and accuracy.</td>
<td style="border-bottom: 1px dotted #860E36; padding: 4px" class="titlea" background="Images/Lt_Red_Back.gif" width="190">
<p align="right">v1.0</td>
</tr>
<tr>
<td style="padding: 4px" class="bodya" colspan="2">
<FORM name="JobOp">
<table border="0" cellpadding="5" width="100%">
<tr>
<td>
<table border="0" cellpadding="5" width="100%">
<tr>
<td align="center" style="border-left: 1px solid #344270; border-right: 2px solid #344270; border-top: 1px solid #344270; border-bottom: 2px solid #344270; padding: 5px; background-color: #CED3E8" background="Images/Blue_Back.gif">
<b><font face="Arial" size="2" color="#FFFFFF">Net / Gross WPM</font></b></td>
<td align="center" style="border-left: 1px solid #344270; border-right: 2px solid #344270; border-top: 1px solid #344270; border-bottom: 2px solid #344270; padding: 5px; background-color: #CED3E8" background="Images/Blue_Back.gif">
<b><font face="Arial" size="2" color="#FFFFFF">Entry Errors</font></b></td>
<td align="center" style="border-left: 1px solid #344270; border-right: 2px solid #344270; border-top: 1px solid #344270; border-bottom: 2px solid #344270; padding: 5px; background-color: #CED3E8" background="Images/Blue_Back.gif">
<b><font face="Arial" size="2" color="#FFFFFF">Accuracy</font></b></td>
<td align="center" style="border-left: 1px solid #344270; border-right: 2px solid #344270; border-top: 1px solid #344270; border-bottom: 2px solid #344270; padding: 5px; background-color: #CED3E8" background="Images/Blue_Back.gif">
<b><font face="Arial" size="2" color="#FFFFFF">Elapsed /
Remaining</font></b></td>
</tr>
<tr>
<td align="center"><font size="2" face="Arial">
<div id="stat_wpm">Not Started</div></font></td>
<td style="border-left: 1px dotted #8794C7; border-right: 1px dotted #8794C7; border-top-width: 1px; border-bottom-width: 1px" align="center">
<font size="2" face="Arial"><div id="stat_errors">Waiting...</div></font></td>
<td style="border-left-width: 1px; border-right: 1px dotted #8794C7; border-top-width: 1px; border-bottom-width: 1px" align="center">
<font size="2" face="Arial"><div id="stat_score">Waiting...</div></font></td>
<td align="center"><font size="2" face="Arial">
<div id="stat_timeleft">0:00</div></font></td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="border-left-width: 1px; border-right-width: 1px; border-top: 1px solid #344270; border-bottom-width: 1px">
<div id="expectedArea" style="display:block">
<p style="margin-top: 0; margin-bottom: 0">
<font color="#7A88C0" face="Arial" size="1">
<textarea name="given" cols=53 rows=10 wrap=on onFocus="deterCPProtect();" style="width: 100%; border: 1px solid #344270; padding: 2px; font-family:Arial; font-size:9pt">Click on the button below to start the typing test. What you will be expected to type will appear here.</textarea></font>
</div>
</td>
</tr>
<tr>
<td>
<p align="center" style="margin-top: 0; margin-bottom: 2px">
<input type=button value=">> Start Typing Test <<" name="start" onClick="beginTest()" style="display:block; border-left:1px solid #293358; border-right:2px solid #293358; border-top:1px solid #293358; border-bottom:2px solid #293358; width: 100%; background-color: #9BB892; color:#FFFFFF; background-image:url('Images/Green_Back.gif')"><p align="center" style="margin-top: 0; margin-bottom: 0">
<input disabled type=button value=">> End Typing Test <<" name="stop" onClick="endTest()" style="display:none; border-left:1px solid #293358; border-right:2px solid #293358; border-top:1px solid #293358; border-bottom:2px solid #293358; width: 100%; background-color: #F05959; color:#FFFFFF; background-image:url('Images/Red_Back.gif')"></td>
</tr>
<tr>
<td style="font-family: Arial; font-size: 9pt">
<div id="typeArea" style="display:block">
<table border="0" width="100%" cellspacing="1">
<tr>
<td style="border: 1px solid #9CA8D1; background-color: #EAECF4">
<div align="left">
<table id="stProg" border="0" width="0%" cellspacing="1">
<tr>
<td style="border: 1px solid #344270; background-color: #8F9BCB; font-family:Arial; font-size:8pt; color:#FFFFFF" align="right" background="Images/Blue_Back.gif">
<div id="thisProg">0%</div></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<p style="margin-top: 0; margin-bottom: 0">
<font color="#7A88C0" face="Arial" size="1">
<textarea onkeypress="doCheck();" onkeydown="//calcStat()" name="typed" cols=53 rows=10 wrap=on style="width: 100%; border: 1px solid #344270; padding: 2px; font-family:Arial; font-size:9pt"></textarea></font>
</div>
<div id="afterAction" style="display:none">
</div>
</td>
</tr>
<script>
randNum = Math.floor((Math.random() * 10)) % intToTestCnt;
strToTestType = strToTest[randNum];
document.JobOp.given.value = strToTestType;
document.JobOp.typed.focus();
</script>
</table>
</FORM>
</td>
</tr>
</table>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -