/
Julia-Cut.html
executable file
·80 lines (74 loc) · 3.35 KB
/
Julia-Cut.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
77
78
79
80
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>單音節辨音</title>
<style type="text/css">
<!--
body {
margin-top: 0px;
}-->
</style>
<link rel="stylesheet" type="text/css" href="https://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>
<script type="text/javascript" charset="utf8" src="https://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
//在page load的時候執行
$(document).ready(function () {
//Getdata();
});
function Getdata(input) {
//jQuery裡面的方法 --$.getJSON ===>jQuery.getJSON( url, [data], [callback] )
$.getJSON("cut_2_Data.html",
function (data) {
$.each(data.item, function (i, item) {
//$("#test").append(item.id + '<br />');
input.push(item.vocabulary);
});
});
}
var input_str_arr = new Array();
Getdata(input_str_arr);
$.unique(input_str_arr);
var remember_arr = [];
function randomit() {
if ($("#once").attr('checked')) {
var ttl = input_str_arr.length; // 資料總數
if (remember_arr.length < ttl) {
var ran = Math.floor((Math.random() * ttl) + 1);
while ($.inArray(ran, remember_arr) > -1) {
//alert(ran);
ran = Math.floor((Math.random() * ttl) + 1);
}
remember_arr.push(ran);
$("#display").html(input_str_arr[ran - 1]);
$("#record").html(remember_arr.length + "題");
} else {
alert("全部完成了!");
}
} else {
$("#display").html(Math.floor((Math.random() * $("#max").val()) + 1));
}
}
function clear_arr() {
remember_arr = [];
$("#record").html(remember_arr.length + "題");
}
$(document).ready(function () {
$("#record").html(remember_arr.length + "題");
$("#display").click(function () {
randomit();
});
});
</script>
</head>
<body>
<input type="checkbox" name="once" id="once" value="1" CHECKED /><span>切音單字不重複<span>
<input type="submit" onclick="javascript: randomit();" value="隨機產生單字" /> <span>(也可以直接在任意位置上點擊)</span>
<br />
<span>第</span><span id="record"></span><input type="submit" onclick="javascript: clear_arr();" value="清空記錄" />
<center><h1 id="display" style="font-size:200px;font-family:Calibri;cursor: pointer;width:auto;height:auto;border-style:solid">start</h1></center>
</body>
</html>