-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock.html
181 lines (164 loc) · 6.73 KB
/
clock.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
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
<!DOCTYPE html>
<html>
<head>
<title>Blatant html5 copy of thecolourclock</title>
<link href='http://fonts.googleapis.com/css?family=Anton' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Raleway:100' rel='stylesheet' type='text/css'>
<style>
html, body {
height: 100%; margin: 0; padding: 0;
-moz-transition: background-color 950ms cubic-bezier(0.2, 0.4, 0.7, 0.8);
-webkit-transition: background-color 950ms cubic-bezier(0.2, 0.4, 0.7, 0.8);
overflow: hidden;
pointer-events: none;
}
#gradient, #texts, #border {
position: absolute;
width: 100%; height: 100%;
font-family: 'Anton', arial, serif;
}
#border {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
padding: 20px;
}
#border > div {
width: 100%; height: 100%;
border: 1px solid #efefef;
color: #efefef;
padding: 5px;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
font-family: 'Raleway', arial, serif;
}
a, a:hover, a:active {
color: #efefef;
pointer-events: auto;
font-family: 'Raleway', arial, serif;
}
#texts > div {
width: 100%; height: 100%;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-box-align: center;
-webkit-box-pack: center;
display: -moz-box;
-moz-box-orient: vertical;
-moz-box-align: center;
-moz-box-pack: center;
-moz-user-select: none;
-webkit-user-select: none;
}
#hex, #time {
color: #efefef;
font-size: 200px;
text-transform: uppercase;
text-shadow: rgba(0,0,0,0.4) -1px -1px 2px;
line-height: 200px;
cursor: auto;
display: -webkit-box;
display: -moz-box;
-moz-transition: opacity 200ms cubic-bezier(0.2, 0.4, 0.7, 0.8);
-webkit-transition: opacity 200ms cubic-bezier(0.2, 0.4, 0.7, 0.8);
}
#hex {
-webkit-box-ordinal-group: 3;
-moz-box-ordinal-group: 3;
}
#hex span, #time span {
width: 100px;
display: block;
text-align: center;
}
#keys {
height: 30px;
width: 100%;
display: -webkit-box;
-webkit-box-orient: horizontal;
-webkit-box-pack: center;
-webkit-box-ordinal-group: 2;
display: -moz-box;
-moz-box-orient: horizontal;
-moz-box-pack: center;
-moz-box-ordinal-group: 2;
}
#keys a {
display: block;
width: 280px;
height: 15px;
margin: 10px;
background-color: #efefef;
-webkit-box-shadow: -1px -1px 2px rgba(0,0,0,0.4);
-moz-box-shadow: -1px -1px 2px rgba(0,0,0,0.4);
pointer-events: auto;
opacity: 0.5;
}
#left:target, #middle:target, #right:target {
opacity: 1.0;
}
#gradient {
height: 100%;
background: -moz-radial-gradient(50% 50% 0deg, ellipse cover, rgba(0,0,0,0.0), rgba(0,0,0,0.3));
background: -webkit-gradient(radial, center center, 0, center center, 600, from(rgba(0,0,0,0.0)), to(rgba(0,0,0,0.3)));
}
</style>
</head>
<body onLoad="updateHash(window.location.hash);updateColor();">
<div id="gradient"></div>
<div id="texts">
<div>
<div id="time"><span>-</span><span>-</span><span style="width: 80px;">:</span><span>-</span><span>-</span><span style="width: 80px;">:</span><span>-</span><span>-</span></div>
<div id="hex"><span style="margin-right: 10px;">#</span><span>f</span><span>f</span><span>f</span><span>f</span><span>f</span><span>f</span></div>
<div id="keys"><a id="left" onClick="updateHash('#left');" href="#left"></a><a id="middle" onClick="updateHash('#middle');" href="#middle"></a><a id="right" onClick="updateHash('#right');" href="#right"></a></div>
</div>
</div>
<div id="border"><div>Blatant html5 copy of <a href="http://thecolourclock.co.uk/">thecolourclock</a></div></div>
<script>
var maxHex = 0xFF;
var fill = function(x) { return ((""+x).length == 2) ? x : ("0"+x); };
var hexify = function(x) { return fill(parseInt((x*maxHex).toFixed(0)).toString(16)); };
var htmlHex = document.getElementById("hex");
var timeHex = document.getElementById("time");
var updateHash = function(hash) {
switch (hash) {
case "#left":
htmlHex.style.opacity = 0.0;
timeHex.style.opacity = 1.0;
break;
case "#right":
htmlHex.style.opacity = 1.0;
timeHex.style.opacity = 0.0;
break;
case "#middle":
default:
htmlHex.style.opacity = 1.0;
timeHex.style.opacity = 1.0;
break;
}
}
var updateColor = function () {
var date = new Date();
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var hex = "#" + hexify(hours/23) + hexify(minutes/59) + hexify((seconds)/59);
var time = fill(hours) + ":" + fill(minutes) + ":" + fill(seconds);
for (var c in hex) {
htmlHex.children[c].textContent = hex[c];
}
for (var c in time) {
timeHex.children[c].textContent = time[c];
}
document.body.style.backgroundColor = hex;
};
if (window.location.hash.length == 0) {
window.location = window.location + "#middle";
}
setInterval(function() {
updateColor();
}, 1000);
</script>
</body>
</html>