-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththeclock.html
More file actions
65 lines (60 loc) · 1.97 KB
/
Copy paththeclock.html
File metadata and controls
65 lines (60 loc) · 1.97 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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
现在是北京时间:<span id='yanshi_time'></span><br/>
<audio src='http://cctv3.qiniudn.com/tbhdqx.mp3' preload='none' id='music'>
</audio>
请设定你的闹铃时间:
<input type='number' value='00' id='qiuye_shiz' size='1' min='0' max="23">
<input type='number' value='00' id='qiuye_fenz' size='1' min='0' max="59">
<input type='number' value='00' id='qiuye_miaoz' size='1' min='0' max="59">
<input type='button' value='关闭闹钟' id='qiuye_gb' size=2>
<script>
qiuye_shiz=document.getElementById('qiuye_shiz').value,
qiuye_fenz=document.getElementById('qiuye_fenz').value,
qiuye_miaoz=document.getElementById('qiuye_miaoz').value;
window.onload=function(){
var input=document.getElementsByTagName('input');
var gb=document.getElementById('qiuye_gb');
for(i=0;i<input.length;i++){
input[i].oninput=function(){
qiuye_shiz=document.getElementById('qiuye_shiz').value,
qiuye_fenz=document.getElementById('qiuye_fenz').value,
qiuye_miaoz=document.getElementById('qiuye_miaoz').value;
}
}
function showtime(){
var time=new Date();
var minute=time.getMinutes();
var hou=time.getHours();
var sec=time.getSeconds();
var content=document.getElementById('yanshi_time');
content.innerHTML=''+add_o(hou)+' : '+add_o(minute)+' : '+add_o(sec);
var d1=hou>=qiuye_shiz&&minute>=qiuye_fenz&&sec>=qiuye_miaoz;
var d2=hou>=qiuye_shiz&&minute>qiuye_fenz;
var d3=hou>qiuye_shiz;
if(d1||d2||d3){
if(!music.play()){music.play();}//响铃
content.style.color='red';//改变字体颜色为红色
}
else{music.pause();content.style.color='black';}//同理
}
showtime();
function add_o(m){
if(m<10){return '0'+m;}
else{return m;}
}
var timer=setInterval(showtime,1000);
gb.onclick=function(){
qiuye_shiz=24;
}}
</script>
</body>
</html>