<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>打字测试</title>
<style type="text/css">
body
{
font-family: 宋体;
font-size: 14px;
line-height: 120%;
}
.source
{
width: 99%;
height: 380px;
border: 1px solid #999999;
background-color: #efefef;
padding: 2px;
}
.textarea
{
width: 99%;
height: 100px;
}
</style>
</head>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>打字测试</title>
<style type="text/css">
body
{
font-family: 宋体;
font-size: 14px;
line-height: 120%;
}
.source
{
width: 99%;
height: 380px;
border: 1px solid #999999;
background-color: #efefef;
padding: 2px;
}
.textarea
{
width: 99%;
height: 100px;
}
</style>
</head>
<body>
<form name="form1">
<input type="button" name="optn" value="开始" οnclick="startit()" />
<input type="button" name="optn" value="开始" οnclick="startit()" />
<input type="radio" name="language" value="zh" checked="checked" />中文
<input type="radio" name="language" value="en" />英语
<input type="radio" name="language" value="en" />英语
<span id="prompt">限定时间(分钟)</span> <input type="text" name="timer" value="10" size="6" />
<br />
<br />
<b>原文</b><br />
<textarea name="source" class="source"></textarea><br />
<b>测试区</b><br />
<textarea name="score" class="textarea"></textarea>
</form>
<textarea name="source" class="source"></textarea><br />
<b>测试区</b><br />
<textarea name="score" class="textarea"></textarea>
</form>
<script language="javascript" type="text/javascript">
var started = 0;
var remain = 0;
var elaps = 0;
var scored = 0;
var remain = 0;
var elaps = 0;
var scored = 0;
function startit()
{
if(started)
{
if(remain)
{
if(confirm('您真的要停止吗?')) stat();
else return false;
{
if(started)
{
if(remain)
{
if(confirm('您真的要停止吗?')) stat();
else return false;
}
started = 0;
form1.timer.disabled = false;
form1.optn.value = '开始';
document.getElementById('prompt').innerText = '限定时间(分钟)';
clearInterval(timer);
}
else
{
started = 1;
form1.timer.disabled = true;
form1.optn.value = '停止';
document.getElementById('prompt').innerText = '剩余时间';
remain = parseInt(form1.timer.value)*60;
timer = setInterval('counter()',1000);
started = 0;
form1.timer.disabled = false;
form1.optn.value = '开始';
document.getElementById('prompt').innerText = '限定时间(分钟)';
clearInterval(timer);
}
else
{
started = 1;
form1.timer.disabled = true;
form1.optn.value = '停止';
document.getElementById('prompt').innerText = '剩余时间';
remain = parseInt(form1.timer.value)*60;
timer = setInterval('counter()',1000);
}
}
}
function counter()
{
remain --;
elaps ++;
if(remain==0)
{
clearInterval(timer);
startit();
stat();
return false;
}
minute = parseInt(remain / 60);
second = remain % 60;
form1.timer.value = minute + ':' + second;
}
{
remain --;
elaps ++;
if(remain==0)
{
clearInterval(timer);
startit();
stat();
return false;
}
minute = parseInt(remain / 60);
second = remain % 60;
form1.timer.value = minute + ':' + second;
}
function stat()
{
minute = parseInt(elaps / 60);
second = elaps % 60;
scored = String(form1.score.value);
if(form1.language[0].checked)
{
scored = scored.replace(/[a-zA-Z0-9]+/g,'大');
scored = scored.replace(//s/g,'');
word = scored.length;
speed = parseInt(word / elaps * 60);
str = '您在' + minute + '分' + second + '秒内共输入' + word + '个字'+"/n";
str += '您的平均打字速度为每分钟' + speed + '个。';
}
else
{
letter = scored.length;
word = scored.replace(/[^/s]+/g,'').length;
speed = parseInt(word / elaps * 60);
speed_letter = parseInt(scored.length / elaps * 60);
str = '您在 ' + minute + '分' + second + '秒 内共输入 ' + word + ' 个单词,';
str += '共 ' + letter + ' 个字母' + "/n";
str += '您的平均打字速度为每分钟 '+speed+' 个单词,'+ speed_letter +' 个字母。';
}
alert(str);
//document.location.reload();
}
</script>
</body>
</html>
{
minute = parseInt(elaps / 60);
second = elaps % 60;
scored = String(form1.score.value);
if(form1.language[0].checked)
{
scored = scored.replace(/[a-zA-Z0-9]+/g,'大');
scored = scored.replace(//s/g,'');
word = scored.length;
speed = parseInt(word / elaps * 60);
str = '您在' + minute + '分' + second + '秒内共输入' + word + '个字'+"/n";
str += '您的平均打字速度为每分钟' + speed + '个。';
}
else
{
letter = scored.length;
word = scored.replace(/[^/s]+/g,'').length;
speed = parseInt(word / elaps * 60);
speed_letter = parseInt(scored.length / elaps * 60);
str = '您在 ' + minute + '分' + second + '秒 内共输入 ' + word + ' 个单词,';
str += '共 ' + letter + ' 个字母' + "/n";
str += '您的平均打字速度为每分钟 '+speed+' 个单词,'+ speed_letter +' 个字母。';
}
alert(str);
//document.location.reload();
}
</script>
</body>
</html>