server / youyou /zh.html
silencewing's picture
Upload 93 files
50408e8
raw
history blame
7.29 kB
<!-- /*
* @Author: Chauncey Yuan
* @Date: 2019-08-01 18:25:30
* @Last Modified by: Chauncey Yuan
* @Last Modified time: 2019-08-03 08:24:27
*/ -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="js/axios.min.js"></script>
<script src="js/main.js"></script>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="cal_game">
<table>
<tr>
<td id="output" colspan="3"></td>
</tr>
<tr>
<th>题目</th>
<td id="eq" colspan="2"></td>
</tr>
<tr>
<th>答案</th>
<td colspan="2"><input type="text" name="" id="input" placeholder="请输入结果:"></td>
</tr>
<tr>
<th>正误</th>
<td id="result" colspan="2"></td>
</tr>
<tr>
<th>得分</th>
<td id="score" colspan="2"></td>
</tr>
<tr>
<td id="accuracy" colspan="3"></td>
</tr>
</table>
</div>
<script>
// 定义题号,使用时+1
var i = 0;
// 定义计算正确的次数
var right_times = 0;
// 定义分数
var score = 0;
// 定义正确率
var accuracy = 0;
// 定义加减法符号数组,用于后边产生0或1的随机数,来确定加减法
var sign_operation_list = ["+", "-"];
// 生成0或者1的随机数,确定加减法
var sign_operation = Math.floor((Math.random() * (1 - 0 + 1)) + 0);
// 显示题号
document.getElementById("output").innerHTML = "第 " + (i + 1) + " 题";
document.onkeydown = function (e) {
if(e.which == "13" && document.getElementById("input").value){
xun()
}
else{
document.getElementById("input").focus()
// ttsPlay(eq)
}
}
var sourceList = ['一','二','三','四','五','六','七','八','九','十','上','下','左','右','大','小','多','少','土','个','入','人','儿','火','文','木','禾','无','口','日','月','天','中','了','子','门','不','开','目','耳','头','米','见','白','田','电','也','长','山','出','飞','马','鸟','云','公','车','牛','羊','巾','牙','尺','毛','卜','又','心','风','力','手','水','广','升','足','走','方','半','巴','业','本','平','书','自','已','东','西','回','片','皮','生','里','果','几','用','鱼','今','正','雨','两','瓜','衣','来','年','万','百','丁','齐','冬','说','友','话','春','朋','高','你','绿','们','花','红','草','爷','亲','节','的','岁','行','古','处','声','知','忙','洗','真','认','父','扫','母','爸','写','全','完','关','家','看','笑','着','兴','画','会','妈','合','奶','放','午','收','女','气','太','早','去','亮','和','李','语','秀','千','香','听','远','唱','定','连','向','以','更','后','意','主','总','先','起','干','明','赶','净','同','专','工','才','级','队','蚂','蚁','前','房','空','网','诗','黄','林','闭','童','立','是','我','朵','叶','美','机','她','过','他','时','送','让','吗','往','吧','得','虫','很','河','借','姐','呢','呀','哪','谁','凉','怕','量','跟','最','园','脸','因','阳','为','光','可','法','石','找','办','许','别','那','到','都','吓','叫','再','做','象','点','像','照','沙','海','桥','军','竹','苗','井','面','乡','忘','想','念','王','这','从','进','边','道','贝','男','原','爱','虾','跑','吹','乐','地','老','快','师','短','淡','对','热','冷','情','拉','活','把','种','给','吃','练','学','习','非','苦','常','问','伴','间','共','伙','汽','分','要','没','孩','位','选','北','湖','南','秋','江','只','帮','星','请','雪','就','球','跳','玩','桃','树','刚','兰','座','各','带','坐','急','名','发','成','动','晚','新','有','么','在','变','什','条']
var max_num = sourceList.length - 1;
var num1 = Math.floor(Math.random() * (max_num - 0 + 1) + 0);
// 抽取汉字,显示给用户看
var eq = sourceList[num1];
// 页面中显示题目
document.getElementById("eq").innerHTML = eq;
ttsPlay(eq)
// console.log(eq);
downInit();
// 定义函数,当按钮按下是执行一次
function xun() {
// console.log(num1, num2);
// 题号加1
i++;
// 获取用户输入的结果
var input = document.getElementById("input").value;
// console.log(input, num1, num2);
// 如果是加法
if (1===1) {
// 定义真实结果
var calResult = sourceList[num1];
// 如果用户输入的结果和真实结果相同
if (input == calResult) {
// 分数加10分
score += 10;
// console.log("正确!");
// 显示正确信息
document.getElementById("result").innerHTML = resultImg("正确");
// 正确的次数加1
right_times++;
}
// 如果用户输入的结果和真实结果不同
if (input != calResult) {
// 分数减10分
score -= 10;
// console.log("错误!");
// 显示错误信息
document.getElementById("result").innerHTML = resultImg("错误");
}
}
// 判断结果后,用户输入框清空
document.getElementById("input").value = "";
// 显示分数
document.getElementById("score").innerHTML = score;
// 显示正确率
document.getElementById("accuracy").innerHTML = (((right_times / i) * 100).toFixed(2)) + "%";
if (score >= max_score) {
window.location.href = "game.html";
}
// 显示题号
document.getElementById("output").innerHTML = "第 " + (i + 1) + " 题";
// 如果是减法
if (1 == 1) {
// 范围为0-max_num
num1 = Math.floor(Math.random() * (max_num - 0 + 1) + 0);
}
// 组成算式,显示给用户看
eq = sourceList[num1];
// 页面中显示算式
document.getElementById("eq").innerHTML = eq;
ttsPlay(eq)
// console.log(eq);
}
// function read(txt){
// url = "https://tsn.baidu.com/text2audio?lan=zh&per=4121&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=220&aue=3&pit=5&ie=UTF-8&spd=4&tex="+txt;
// }
</script>
</body>
</html>