varcurrentIndex= 0;vartotalCount= 0;varrightCount= 0;varnumAStart= 0;varnumAEnd= 10;varnumBStart= 0;varnumBEnd= 10;varopType= "+";varusedSeconds= 0;varstartTime= 0;vartempNumA= 0;vartempNumB= 0;vartempAnswer= 0;varisRTL= false;functionfnStart(){
document.getElementById("divSetting").style.display= "none";
document.getElementById("divQuestionAnswer").style.display= "block";
usedSeconds= 0;
currentIndex= 0;
numAStart=document.getElementById('txtNumAStart').value;
numAEnd=document.getElementById("txtNumAEnd").value;
numBStart=document.getElementById("txtNumBStart").value;
numBEnd=document.getElementById("txtNumBEnd").value;
totalCount=document.getElementById("txtQuestionsCount").value;
rightCount= 0;varradios=document.getElementsByName("radOperationType");for(vari=0;i
opType=radios[i].value;break;
}
}
startTime= newDate().getTime() ;if( document.getElementById("chkIsRTL").checked ){
isRTL= true;
document.getElementById("txtNumAnswer").style.display="none";
document.getElementById("txtNumAnswerRTL").style.display="block";
}else{
isRTL= false;
document.getElementById("txtNumAnswer").style.display="block";
document.getElementById("txtNumAnswerRTL").style.display="none";
}
fnCreateQuestion();
}functiongetRndInteger(min, max) {returnMath.floor(Math.random()*(max-min+ 1) )+Math.floor(min);
}functionfnCreateQuestion(){if(currentIndex
currentIndex=currentIndex+ 1;
tempNumA=getRndInteger(numAStart,numAEnd);
tempNumB=getRndInteger(numBStart,numBEnd);if(opType== "+"){
tempAnswer=tempNumA+tempNumB;
}else if(opType== "-"){if(tempNumA
tempNumA=tempNumB;
tempNumB=tempN;
}
tempAnswer=tempNumA-tempNumB;
}else if(opType== "x"){
tempAnswer=tempNumA*tempNumB;
}if(opType== "÷"){
tempAnswer=tempNumA/tempNumB;
}
document.getElementById("divQuestionIndex").innerText=currentIndex+ ".";
document.getElementById("divNumA").innerText=tempNumA;
document.getElementById("divNumB").innerText=tempNumB;
document.getElementById("divOp").innerText=opType;if(isRTL){
document.getElementById("txtNumAnswerRTL").value= "";
document.getElementById("txtNumAnswerRTL").focus();
}else{
document.getElementById("txtNumAnswer").value= "";
document.getElementById("txtNumAnswer").focus();
}
}else{//all finish
fnEnd();
}
}functionfnNext() {vartempInputAnswer=document.getElementById("txtNumAnswer").value;if(isRTL){
tempInputAnswer=document.getElementById("txtNumAnswerRTL").value;vararr=tempInputAnswer.split("");varrever=arr.reverse();
tempInputAnswer=rever.join("");
}if(tempInputAnswer==tempAnswer){
rightCount=rightCount+ 1;
}else{
}
fnCreateQuestion();
}functionfnAfterInputAnswer(event){if(event.keyCode==13) {
fnNext();
}
}functionfnEnd(){varendTime= newDate().getTime() ;vartempSeconds=Math.floor( (endTime-startTime)/1000 ) ;
varreportInfo= "题目数量:" +totalCount;
reportInfo+= "
正确数量:" +rightCount;
reportInfo+= "
用时秒数:" +tempSeconds;
reportInfo+= "
";
reportInfo+= "
分数: " +Math.floor(( rightCount* 100 /totalCount))+ "%";
document.getElementById("divResult").innerHTML=reportInfo;
document.getElementById("divSetting").style.display= "none";
document.getElementById("divQuestionAnswer").style.display= "none";
document.getElementById("divResultReport").style.display= "block";
}functionfnReStart(){
document.getElementById("divSetting").style.display= "block";
document.getElementById("divQuestionAnswer").style.display= "none";
document.getElementById("divResultReport").style.display= "none";
}
数字A 范围:
-
数字B 范围:
-
运算符:
加法+
减法-
乘法x
除法÷
题目数量:
单题限时:
(秒)
大数倒序输入