-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
76 lines (66 loc) · 2.68 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>QUIZ</title>
</head>
<body>
<br />
<p style="text-align:center;font-size: 80px;" id="word"></p>
<!-- <center><button style="width: 300px;height: 100px;">显示答案</button></center> -->
<div id="define" style="border-style:solid;left:10%;right:10%;margin: auto;">
</div>
<div id="define" style="border-style:solid;left:10%;right:10%;margin: auto;" onclick="showans();">
<p id="ans" style="text-align:center;font-size: 50px;">Show Answer</p>
<!-- 中文符號 -->
</div>
<br>
<div> <button style="width: 347px;height: 150px;" onclick="next(0)">未掌握</button>
<!-- <button style="width: 347px;height: 150px;" onclick="next(1)">基本掌握</button> -->
<button style="width: 347px;height: 150px;" onclick="next(2)">已掌握</button>
</div>
<span id="ans" style="font-size: 25px;">Energy points gained: </span><span><b style="font-size: 25px;"
id="points"></b></span>
<script>
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
// Typical action to be performed when the document is ready:
t = xhttp.responseText.split("******");
document.getElementById("word").innerText = t[0];
answer = t[1];
}
};
var xhttp_getpoints = new XMLHttpRequest();
xhttp_getpoints.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("points").innerText = xhttp_getpoints.responseText;
}
};
var xhttp_normal = new XMLHttpRequest();
function getPoints() {
xhttp_getpoints.open("GET", "getpoints", true);
xhttp_getpoints.send();
}
function getword() {
xhttp.open("GET", "getword", true);
xhttp.send();
}
function showans() {
document.getElementById("ans").innerText = answer;
}
function next(level) {
// alert(level);
// xhttp_normal.open("GET", "feedback?points="+String(level)+"&word=", true); 404
xhttp_normal.open("GET", "feedback&"+String(level)+"&test", true); //404
xhttp_normal.send();
// xhttp_getpoints,xhttp_normal 太多了
getword();
document.getElementById("ans").innerText = "Show Answer";
getPoints();
}
getword();
getPoints();
</script>
</body>
</html>