-
Notifications
You must be signed in to change notification settings - Fork 1
/
timer_common.bak
245 lines (237 loc) · 9.26 KB
/
timer_common.bak
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="./source/bootstrap.min.css">
<script src="./source/jquery-3.3.1.slim.min.js"></script>
<script src="./source/popper.min.js"></script>
<script src="./source/bootstrap.min.js"></script>
<script src="./config.js"></script>
<script type="text/javascript">
var min,sec,timer;
var origin_sec;
function bing(){
var audio = document.getElementById('sound');
audio.play();
}
function bing3(){
var audio = document.getElementById('sound3');
audio.play();
}
function get_text(t)
{
if(t==0)
return "00";
res=String(t);
if(t<=9)
return "0"+res;
return res;
}
function time_updata(){
if(min==0&&sec==0){
bing3();
return;
}
if(min==0&&sec==30){
bing();
}
sec-=1;
if(sec==-1){
min-=1;
sec=59;
}
var cur = $('#min-item-1');
cur.text(get_text(min));
cur = $('#s-item-1');
cur.text(get_text(sec));
timer=setTimeout("time_updata()", 1000);
$("#bar-1").attr('style', "width: "+String((origin_sec-(min*60+sec))*100/origin_sec)+"%");
}
function stop_timer(){
$("#btn-start").show();
$("#btn-stop").hide();
clearTimeout(timer);
}
function start_timer(){
$("#btn-start").hide();
$("#btn-stop").show();
timer = setTimeout("time_updata()", 1000);
}
function restart(){
stop_timer();
$("#btn-start").hide();
$("#btn-stop").show();
min = Number($("#input-min").val());
sec = Number($("#input-s").val());
$('#min-item-1').text(get_text(min));
$('#s-item-1').text(get_text(sec));
origin_sec = min*60+sec;
$('#reset').modal('hide');
$("#btn-2").show();
$("#btn-1").show();
$("#bar-1").attr('style', "width: 0%");
timer = setTimeout("time_updata()", 1000);
}
function clear_text(){
$('#min-item-1').text('00');
$('#min-item-2').text('00');
}
function restart_with_time(m, ss){
bing();
clear_text();
stop_timer();
$("#btn-start").hide();
$("#btn-stop").show();
min = Number(m);
sec = Number(ss);
$('#min-item-1').text(get_text(min));
$('#s-item-1').text(get_text(sec));
origin_sec = min*60+sec;
$('#reset').modal('hide');
$("#btn-2").show();
$("#btn-1").show();
$("#bar-1").attr('style', "width: 0%");
timer = setTimeout("time_updata()", 1000);
}
function load_name(){
$('#topic').val(name_topic);
$('#cur-name-aff').text(name_aff);
$('#cur-name-neg').text(name_neg);
}
function load(){
load_name();
$('#cur-aff').hide();
$('#cur-neg').hide();
}
function change_cur(is_aff){
if(is_aff){
$('#cur-aff').show();
$('#cur-neg').hide();
}else{
$('#cur-aff').hide();
$('#cur-neg').show();
}
}
</script>
</head>
<style>
.pull-right{
float: right;
}
.my-middle{
vertical-align: middle;
}
.timer-block{
font-size: 4rem;
text-align:center;
}
.mid{
text-align:center;
}
.hid{
display: none;
}
.in-line{
display: inline-block;
}
</style>
<body onload="load()" style="text-align: center">
<nav class="navbar navbar-dark bg-primary">
<span class="navbar-brand">计时器<i></i></span>
<a class="nav-item nav-link text-white" href="./timer.html" target="_self">普通模式[切换]</a>
<div class="navbar-nav">
</div>
</nav>
<div class="container mt-3">
<div style="text-align: center;">
<span style="display: inline-block;margin-left: 0rem;vertical-align: middle;">
<h5 style="display: block;"></h5>
<h3 style="font-weight: bold;">动物科学学院队内赛</h3>
</span>
<div>
<input id="topic" type="text" name="firstname" value="辩题" style="border: none;color: gray;text-align: center;width: 100%;font-size: 1.5em;">
</div>
<div class="alert alert-success mt-1" role="alert" id="cur-aff">
<b>正方 </b><span id="cur-name-aff"></span>
</div>
<div class="alert alert-warning mt-1" role="alert" id="cur-neg">
<b>反方 </b><span id="cur-name-neg"></span>
</div>
</div>
<div class="m-3">
<div class="timer-block">
<span><span class="badge badge-primary" id="min-item-1">00</span> <small>min</small></span>
<span><span class="badge badge-primary" id="s-item-1">00</span> <small>s</small></span>
<div class="progress">
<div id="bar-1" class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 0%"></div>
</div>
</div>
</div>
<div class="m-3 mid">
<button type="button" class="btn btn-sm btn-success" id="btn-stop" onclick="stop_timer()">暂停</button>
<button type="button" class="btn btn-sm btn-success" id="btn-start" onclick="start_timer()" style="display: none;">开始</button>
<button type="button" class="btn btn-sm btn-danger" id="btn-restart" data-toggle="modal" data-target="#reset">自定义</button>
</div>
</div>
<!--赛制-->
<div class="btn-group1 ml-3 mt-3" role="group">
<button type="button" class="btn btn-success" onclick="restart_with_time(5,0);change_cur(1);">自我介绍<br><small>正方</small></button>
<button type="button" class="btn btn-warning" onclick="restart_with_time(5,0);change_cur(0);">自我介绍<br><small>反方</small></button>
<button type="button" class="btn btn-success" onclick="restart_with_time(3,30);change_cur(1);">正方立论<br><small>正一 3min 30s</small></button>
<button type="button" class="btn btn-warning" onclick="restart_with_time(2,0);change_cur(0);">反方质询<br><small>反二 2min</small></button>
<button type="button" class="btn btn-warning" onclick="restart_with_time(3,30);change_cur(0);">反方立论<br><small>反一 3min 30s</small></button>
<button type="button" class="btn btn-success" onclick="restart_with_time(2,00);change_cur(1);">正方质询<br><small>正二 2min</small></button>
</div><!--结尾-->
<div class="btn-group1 ml-3 mt-3" role="group">
<button type="button" class="btn btn-warning" onclick="restart_with_time(1,30);change_cur(0);">反方小节<br><small>反二 1min 30s</small></button>
<button type="button" class="btn btn-success" onclick="restart_with_time(1,30);change_cur(1);">正方小节<br><small>正二 1min 30s</small></button>
<a class="btn btn-primary" href="./timer.html" target="_self">双方对辩<br><small>四辩</small></a>
<button type="button" class="btn btn-success" onclick="restart_with_time(1,30);change_cur(1);">正方盘问<br><small>正三 1min 30s</small></button>
<button type="button" class="btn btn-warning" onclick="restart_with_time(1,30);change_cur(0);">反方盘问<br><small>反三 1min 30s</small></button>
<button type="button" class="btn btn-success" onclick="restart_with_time(1,30);change_cur(1);">正方小节<br><small>正三 1min 30s</small></button>
<button type="button" class="btn btn-warning" onclick="restart_with_time(1,30);change_cur(0);">反方小节<br><small>反三 1min 30s</small></button>
<a class="btn btn-primary" href="./timer.html" target="_self">自由辩论<br><small>切换</small></a>
<button type="button" class="btn btn-warning" onclick="restart_with_time(3,30);change_cur(0);">反方结辩<br><small>反四 3min</small></button>
<button type="button" class="btn btn-success" onclick="restart_with_time(3,30);change_cur(1);">正方结辩<br><small>正四 3min</small></button>
</div><!--结尾-->
<audio src="./source/ding.wav" controls="controls" style="display: none;" id="sound">
您的浏览器不支持播放声音,请更新您的浏览器
</audio>
<audio src="./source/ding3.mp3" controls="controls" style="display: none;" id="sound3">
</audio>
<!-- Modal -->
<div class="modal fade" id="reset" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalCenterTitle">重设Timer</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="in-line">
<div class="input-group mb-3">
<input type="number" class="form-control" id="input-min" placeholder="分钟" aria-label="Recipient's username" aria-describedby="basic-addon2" value="5">
<div class="input-group-append">
<span class="input-group-text" id="basic-addon2">min</span>
</div>
</div>
<div class="input-group mb-3">
<input type="number" class="form-control" id="input-s" placeholder="秒" aria-label="Recipient's username" aria-describedby="basic-addon2" value="0">
<div class="input-group-append">
<span class="input-group-text" id="basic-addon2">s</span>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" onclick="restart()">重设</button>
</div>
</div>
</div>
</div>
</body>
</html>