");
// 文章檔案格式
// 檔名規定 -- pXX.js (XX 是數字,個位數不用補0)
// 文章標題 -- p[p.length][0] = "....";
// 內容格式 -- p[p.length][1] = "...."; (.... 是文字內容,且必須全部是全形字)
// 檔案位置 -- 請和本主程式檔案(chKeyinTest.htm)存放在一起
}
function showWelcome() {
if (tz != null) {
with(tz.document) {
write('
');
write('
尋找中文打字高手
');
write('
歡迎各路英雄(雌),前來挑戰
');
write('

');
close();
}
}
}
function UpdateDate(para) {
var ud = new Date(document.lastModified);
var udDate = ud.getFullYear()+"-"+(ud.getMonth()+1)+"-"+ud.getDate();
var udTime = ud.getHours()+":"+ud.getMinutes()+":"+ud.getSeconds();
switch(para) {
case "Date" : return(udDate);
break;
case "Time" : return(udTime);
break;
default : return(udDate+" "+udTime);
break;
}
}
var btm,bts;
function blinkObj(obj) {
if (obj.style.visibility == "visible") {
obj.style.visibility = "hidden";
} else {
obj.style.visibility = "visible";
}
}
function AddZero(numbers,dn) {
var ts = "";
var ns = numbers + "";
if (dn <= ns.length) return(numbers);
for(var i=0;i
每分鐘 " + kitestWord[i] + " 字(" + kitestTime[i] + "秒)";
msg += kitestDateTime[i] + " -----> 每分鐘 " + kitestWord[i] + " 字";
if (i == (kitestTimes-1) % 10)
msg += " (最近一次成績)\n";
else
msg += "\n";
}
alert(msg);
}
function recordScore() {
var Min=document.all("tmin").innerText*1;
var Sec=document.all("tsec").innerText*1;
// var useTime = (testMin*60+testSec*1) - (Min*60+Sec);
// kitestTime[kitestTimes % 10] = useTime;
// var cookieStr = kitestTime.join(",");
// setCookie("kitestTime",cookieStr);
var Today=new Date();
var nowTime = Today.getFullYear() + "-" +
AddZero(Today.getMonth()+1,2) + "-" +
AddZero(Today.getDate(),2) + " " +
AddZero(Today.getHours(),2) + ":" +
AddZero(Today.getMinutes(),2) + ":" +
AddZero(Today.getSeconds(),2);
kitestDateTime[kitestTimes % 10] = nowTime;
cookieStr = kitestDateTime.join(",");
setCookie("kitestDateTime",cookieStr);
kitestWord[kitestTimes % 10] = document.all("avgSpeed").innerText;
cookieStr = kitestWord.join(",");
setCookie("kitestWord",cookieStr);
kitestTimes++;
setCookie("kitestTimes",kitestTimes);
}
function lockInput(stat) {
stat = (stat=="true") ? "true" : "false";
for(var lnum=0;lnum') ch = ">";
if (ch == '&') ch = "&";
return(ch);
}
//函數checkKeyin(),偵測打字狀況
function checkKeyin() {
if (tz.document == null) return;
var tm = document.all("tmin").innerText; // 檢測剩下tm分ts秒
var ts = document.all("tsec").innerText;
var useMin = (60-ts > 0) ? (9-tm)+(60-ts)/60 : 10-tm; // 檢測已過分鐘數
var tqo = tz.document.all("span2"+nowInputLine); // 取得正在輸入之題目物件
var ttq = ttq1 = ""; // 題目顯示暫存變數
var tq = tqo.innerText; // 取得題目字串
var tb = tz.document.all("Text"+nowInputLine).value; // 取得答案字串
var tbl = tb.length; // 已鍵入之答案字元字數
var tqc,tbc; // 取出欲比對之題目(tqc)與答案(tbc)之字元
var tmpWord = ""; // 暫存用
var kw=bw=0; // 該行已打字字數(kw)及錯誤(bw)字數
if (nowInputLine>3)
tz.scroll(0,(nowInputLine-3)*24*2);
else
tz.scroll(0,0);
if (tbl > wln) {
// 去除中文輸入法第一個字根勿判為已輸入的文字
if (escape(tb.substr(tbl-1,1)) == "%u3000" && tbl==wln+1) return;
tz.document.all("Text"+nowInputLine).value = tb.substr(0,wln);
tmpWord = tb.substr(wln);
tb = tz.document.all("Text"+nowInputLine).value; // 取得答案字串
tz.document.all("Text"+nowInputLine).onblur = "";
tz.document.all("Text"+nowInputLine).blur();
tz.document.all("Text"+nowInputLine).value = tb;
tbl = tb.length; // 已鍵入之答案字元字數
nextLine = true;
}
if (nowInputLine > 0 && tbl == 0) {
tz.document.all("Text"+nowInputLine).onblur = "";
tz.document.all("Text"+nowInputLine).blur();
nowInputLine--;
tz.document.all("Text"+nowInputLine).focus();
tz.document.all("Text"+nowInputLine).value = tz.document.all("Text"+nowInputLine).value;
tz.document.all("Text"+nowInputLine).onblur = focusText;
}
badWordArr[nowInputLine] = 0;
for(var i=0;i" + tqc + "";
badWordArr[nowInputLine]++;
} else {
tqc = conv2HTML(tqc);
ttq += tqc;
}
}
for(;i 0) document.all("rightPercent").innerText = Math.round(((kw - bw) / kw) * 10000) / 100;
if (useMin > 0) document.all("avgSpeed").innerText = Math.round(((kw - bw) / useMin)*100) / 100;
if (nextLine) {
nowInputLine++;
tz.document.all("Text"+nowInputLine).focus();
tz.document.all("Text"+nowInputLine).value = tmpWord.substr(0,tz.document.all("Text"+nowInputLine).maxLength);
tz.document.all("Text"+nowInputLine).onblur = focusText;
nextLine = false;
}
if (Testing) {
if (kw == nowtwn) {
if (escape(tb.substr(tbl-1,1)) == "%u3000") return;
stopGame('文章打完嘍!');
// document.all("msgBox").innerHTML = "文章打完嘍!
";
// showInfoDialog(document.all("msgBox"));
// tz.document.all("Text"+nowInputLine).onblur = "";
// document.all("stopBtn").focus();
KeyinOver = true;
} else {
document.all("msgBox").style.display = "none";
tz.document.all("Text"+nowInputLine).onblur = focusText;
KeyinOver = false;
}
}
}
function focusText() {
this.focus();
this.value=this.value;
}
function keyinBox() {
// tz=window.open("","typeWin");
with(tz.document) {
clear();
writeln("");
writeln("");
writeln("");
// writeln("| ※ 打 字 檢 測 區 ※ |
");
writeln(" |
");
writeln("
");
close();
}
}
//---動態刪除輸入元件
function delInput() {
var NodeToAddChild = tz.document.getElementById('typeZone');
for(var lnum=nowtln-1;lnum>=0;lnum--) {
NodeToAddChild.removeChild(tz.document.all("br2"+lnum));
NodeToAddChild.removeChild(tz.document.all("Text"+lnum));
NodeToAddChild.removeChild(tz.document.all("br1"+lnum));
NodeToAddChild.removeChild(tz.document.all("span2"+lnum));
NodeToAddChild.removeChild(tz.document.all("span1"+lnum));
}
}
function randomStr(str) {
var sl = str.length;
var s1=s2=tstr = "";
var rnd=0;
while(str.length>0) {
rnd = Math.floor(Math.random()*str.length);
tstr += str.substr(rnd,1);
s1 = str.substr(0,rnd);
str = s1+str.substr(rnd+1);
}
return(tstr);
}
//---動態新增輸入元件(pid=文章篇號)
function addInput(pid) {
var NodeToAddChild = tz.document.getElementById('typeZone');
var NewSPAN1,NewSPAN2,NewBR1,NewText,NewBR2;
// tln 文章總行數
var tln = (p[pid][1].length%wln > 0) ? parseInt(p[pid][1].length/wln) + 1 : parseInt(p[pid][1].length/wln);
if (p[pid][0].indexOf("基礎測驗")!=-1) {
p[pid][1] = randomStr(p[pid][1]);
}
// if (nowtln > 0) delInput(); //先刪除先前產生的輸入元件
nowtln = tln;
for(var lnum=0;lnum objS.zindex)
objS.zindex= (alldivs(i).style.zIndex + 1);
}
}
function startCounter() {
var key =window.event.keyCode;
if ((key==32) || (key==13) || (key>=48 && key<=57) || (key>=97 && key<=122) || (key>=65 && key<=90)) {
lockInput("false");
Testing = true;
tz.document.all("Text0").onblur = focusText;
tz.document.all("Text0").focus();
clockTimer = setInterval("showClock()",1000);
document.onblur = "";
document.onkeypress="";
}
return(false);
}
function startGame(pid) {
npn = pid;
keyinBox();
addInput(pid);
// 初始化資料
rightWord=badWord=0;
nowInputLine = 0;
document.all("keyinWordNum").innerText = 0;
document.all("textWordNum").innerText = nowtwn = p[pid][1].length;
document.all("tmin").innerText = testMin;
document.all("tsec").innerText = testSec;
document.all("badWordNum").innerText = 0;
document.all("rightPercent").innerText = 0;
document.all("avgSpeed").innerText = 0;
var fm = document.sfm;
var mmsg="";
mmsg += "檢測文章:" + document.all("article1").innerText + "\n\n";
mmsg += "正確請按〔確定〕,要修改請按〔取消〕";
lockInput("true");
document.all.startBtnText.style.visibility = "visible";
if (!confirm(mmsg)) {
showInfoDialog(document.all("stInfo"));
return(false);
}
document.all.startBtnText.style.visibility = "visible";
document.all("msgBox").innerHTML = "1.先調整好輸入法種類,2.任意按一鍵即開始!
";
showInfoDialog(document.all("msgBox"));
// if (!confirm("準備好了嗎?\n\n按<確定>,就不能停了哦!")) return(false);
document.all.seeScore.disabled = true;
document.all.startBtn.disabled = true;
clearInterval(sbt);
document.all.startBtnText.style.visibility = "visible";
document.focus();
document.onblur = document.focus();
document.onkeypress = startCounter;
checkTimer = setInterval("checkKeyin()",50);
}
function checkInfo(fm) {
var allsym = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz∼‵!@#$%︿&*()_-+={〔}〕|\:;”’<,>•。?/※◎§";
var digit = "0123456789";
var pt = fm.article.options.selectedIndex;
if (pt == 0) {
alert("請選擇文章!");
fm.article.focus();
return(false);
}
document.all("article1").innerText = p[pt][0];
document.all("stInfo").style.display = "none";
startGame(pt);
}
//-->