-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmode.html
117 lines (106 loc) · 3.4 KB
/
mode.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,minimal-ui">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="no">
<link rel="shortcut icon" href="./favicon.png">
<title>调式练习</title>
<script src="js/jquery-3.3.1.js"></script>
<script src="js/bootstrap.js"></script>
<script src="js/bootstrap.bundle.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-grid.min.css">
<link rel="stylesheet" href="css/bootstrap-reboot.min.css">
</head>
<body>
<div class="jumbotron text-center">
<h1 class="display-3">调式练习</h1>
</div>
<div class="card m-3">
<div class="card-header">
<h4 class="card-title">配置</h4>
</div>
<div id="conf_div" class="card-body">
<div class="row">
<div class="col-lg-2 m-auto">
<select name="difficulty" id="difficulty" class="form-control d-inline">
<option value="1">简单</option>
<option value="2">普通</option>
<option value="3">困难</option>
</select>
</div>
<div class="col-lg-2 m-auto">
<input id="always_show_answer" type="checkbox" checked onchange="onShowAnswerToggleChange()">
<label for="always_show_answer">总是显示唱名</label>
</div>
</div>
<a href="index.html"
class="btn btn-lg btn-block mt-1 btn-secondary">切换到和弦练习
</a>
<div class="row">
<div class="col-lg-4 m-auto">
<button id="draw_button" onclick="draw()"
class="btn btn-lg btn-block btn-primary mt-1">抽选
</button>
</div>
<div class="col-lg-4 m-auto">
<button id="show_ans_button" onclick="showAnswer()"
class="btn btn-lg btn-block btn-primary mt-1">显示唱名
</button>
</div>
</div>
</div>
</div>
<div class="card bg-dark text-white m-3" id="result_div">
<div class="card-header">
<h4 class="card-title">抽选</h4>
</div>
<div id="draw_result" class="card-body" style="text-align: center">
<h2 id="pitch_h2" class="display-3"></h2>
<h2 id="result_h2" class="display-3">结果在此处</h2>
<h2 id="answer_h2" class="display-3"></h2>
</div>
</div>
<script src="modes.js"></script>
<script src="chords.js"></script>
<script>
String.prototype.replaceAll = function (s1, s2) {
return this.replace(new RegExp(s1, "gm"), s2);
};
function draw() {
let difficulty = $("#difficulty").val();
let result_f = $("#result_h2");
let answer_f = $("#answer_h2");
let question;
if(!showAnswerSettingOn()){
answer_f.attr("hidden","");
}
console.log(difficulty);
switch(difficulty){
case "1":question = modes_easy[random(modes_easy.length)];break;
case "2":question = modes_normal[random(modes_normal.length)];break;
case "3":question = modes_hard[random(modes_hard.length)];break;
}
result_f.html(question[0]);
answer_f.html(question[1]);
$("#pitch_h2").html(pitches[random(pitches.length)]);
}
function showAnswer(){
$("#answer_h2").removeAttr("hidden");
}
function random(max) {
return parseInt(Math.random() * max);
}
function showAnswerSettingOn(){
return $("#always_show_answer").is(":checked");
}
function onShowAnswerToggleChange(){
if(showAnswerSettingOn()){
showAnswer();
}
}
</script>
</body>
</html>