-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
107 lines (90 loc) · 2.73 KB
/
index.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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>COOL-CLOCK</title>
<style>
html,
body {
height: 100%;
}
body {
background: #333;
background-size: 100%;
overflow: hidden;
}
p {
margin: 0;
padding: 0;
}
#clock {
font-family: 'Share Tech Mono', monospace;
text-align: center;
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
color: #fff;
text-shadow: 0 0 30px #90aeff;
}
#clock .time {
letter-spacing: 0.05em;
font-size: 8em;
padding: .1em 0;
}
#clock .date {
letter-spacing: 0.1em;
font-size: 1.5em;
}
#clock .text {
letter-spacing: 0.1em;
font-size: 1.5em;
padding-top: .3em;
}
</style>
</head>
<body>
<script type="text/javascript" src="vue.min.js"></script>
<div id="clock">
<p class="date">{{ date }}</p>
<p class="time">{{ time }}</p>
<p class="text">本月剩余{{ residue }}天</p>
</div>
<script>
var clock = new Vue({
el: '#clock',
data: {
time: '',
date: '',
residue: ''
}
});
var week = ['天', '一', '二', '三', '四', '五', '六'];
var timerID = setInterval(updateTime, 1000);
updateTime();
function updateTime() {
var cd = new Date();
clock.residue = getMonthResidue(cd);
clock.time = zeroPadding(cd.getHours(), 2) + ':' + zeroPadding(cd.getMinutes(), 2) + ':' + zeroPadding(cd.getSeconds(), 2);
clock.date = zeroPadding(cd.getFullYear(), 4) + '-' + zeroPadding(cd.getMonth() + 1, 2) + '-' + zeroPadding(cd.getDate(), 2) + ' ' + week[cd.getDay()];
};
function getMonthResidue(today) {
var now = today.getDate();
var year = today.getYear();
if (year < 2000) year += 1900;
var month = today.getMonth();
var monarr = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) monarr[1] = "29";
return (monarr[month] - now)
}
function zeroPadding(num, digit) {
var zero = '';
for (var i = 0; i < digit; i++) {
zero += '0';
}
return (zero + num).slice(-digit);
}
</script>
</body>
</html>