-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolor.html
More file actions
179 lines (163 loc) · 5.8 KB
/
color.html
File metadata and controls
179 lines (163 loc) · 5.8 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!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" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="materialize/css/materialize.min.css" />
<link rel="stylesheet" href="style.css" />
<title>壓力測驗 - 顏色</title>
</head>
<body>
<!-- navbar -->
<nav class="nav-extended teal">
<div class="nav-wrapper">
<ul class="left" style="width: 100%;">
<li class="active"><a href="./index-stress.html">壓力測驗</a></li>
<li><a href="./index-stroop.html">Stroop</a></li>
<li class="right"><a onclick="resetLocalStorage()">reset</a></li>
</ul>
</div>
<div class="nav-content">
<ul class="tabs tabs-transparent">
<li class="tab"><a href="./index-stress.html">計分板</a></li>
<li class="tab"><a href="./color.html">顏色</a></li>
<li class="tab"><a href="./calc.html">心算</a></li>
<li class="tab right"><a id="btn-download">下載</a></li>
<li class="tab right"><a href="./setting-stress.html">設定</a></li>
<li class="tab right"><a href="#modal-register" class="modal-trigger">註冊</a></li>
</ul>
</div>
</nav>
<!-- content -->
<div class="container">
<!-- startBlock -->
<div id="startBlock" style="display: block;">
<div class="row">
<div class="col" style="width: 100%;">
<div class="card">
<div class="card-content center-align">
<h3 id="h3-show"></h3>
<button id="btn-start" class="waves-effect waves-light btn-large">開始</button>
</div>
</div>
</div>
</div>
</div>
<!-- questionBlock -->
<div id="questionBlock" style="display: none;">
<div class="row">
<div class="col center-align" style="width: 100%">
<div class="progress">
<div id="div-countdown" class="determinate" style="width: 100%"></div>
</div>
<h3 id="qTime"></h3>
</div>
<div class="col" style="width: 100%;">
<div id="div-question" class="card-panel grey lighten-3 center-align"></div>
</div>
<div class="col s3 center-align">
<button class="btn waves-effect waves-light btn-large" type="button" name="action" onclick="submitAns('red')">
紅
</button>
</div>
<div class="col s3 center-align">
<button class="btn waves-effect waves-light btn-large" type="button" name="action"
onclick="submitAns('blue')">
藍
</button>
</div>
<div class="col s3 center-align">
<button class="btn waves-effect waves-light btn-large" type="button" name="action"
onclick="submitAns('green')">
綠
</button>
</div>
<div class="col s3 center-align">
<button class="btn waves-effect waves-light btn-large" type="button" name="action"
onclick="submitAns('amber')">
黃
</button>
</div>
</div>
</div>
<!-- resultBlock -->
<div id="resultBlock" style="display: none;">
<div class="row">
<div class="col" style="width: 100%;">
<div class="card">
<div class="card-content">
<h1 class="card-title">成績</h1>
<h2 class="center-align" id="result"></h2>
</div>
<div class="card-action">
<a href="./index-stress.html">首頁</a>
<a href="./calc.html">心算</a>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Black Modal Structure -->
<div id="modal-black" class="modal black">
<div class="modal-content"></div>
</div>
<!-- Register Modal Structure -->
<div id="modal-register" class="modal">
<div class="modal-content">
<h4>註冊</h4>
<div class="row">
<div class="input-field col s12">
<input id="input-name" type="text" class="validate" required />
<label for="input-name">姓名</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="waves-effect waves-green btn btn-flat" onclick="register()">
送出
</button>
</div>
</div>
</div>
<script src="materialize/js/materialize.min.js"></script>
<script src="main.js"></script>
<script src="stress.js"></script>
<script>
const TOTAL_TIME = localStorage.getItem("STRESS_COLOR_TOTAL_TIME"); // 總時間(s)
const QUESTION_TIME = localStorage.getItem("STRESS_COLOR_QUESTION_TIME"); // 每題時間(s)
var WORD = ["紅", "藍", "綠", "黃"];
var COLOR = ["red", "blue", "green", "amber"];
var CURRENT_QUESTION_NUM = 0;
init("color");
//------------------------顯示題目------------------------
var COLOR_PREV = "";
var WORD_PREV = "";
function show() {
while (true) {
[color_num, word_num] = getRandomNumbers([0, 1, 2, 3], 2);
if (COLOR_PREV != COLOR[color_num] && WORD_PREV != WORD[word_num]) {
break;
}
}
COLOR_PREV = COLOR[color_num];
WORD_PREV = WORD[word_num];
CURRENT_QUESTION_NUM = color_num;
color = COLOR[color_num];
word = WORD[word_num];
document.getElementById("div-question").innerHTML = `
<span id="color-question" class="${color}-text">
${word}
</span>
`;
}
//------------------------點擊答案,計算分數並顯示新題目------------------------
function submitAns(x) {
score(x, COLOR[CURRENT_QUESTION_NUM]);
document.getElementById("qTime").innerHTML = QUESTION_TIME;
show();
}
</script>
</body>
</html>