-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
75 lines (61 loc) · 1.53 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
<!DOCTYPE html>
<!--
Created using JS Bin
http://jsbin.com
Copyright (c) 2016 by anonymous (http://jsbin.com/biqawameka/1/edit)
Released under the MIT license: http://jsbin.mit-license.org
-->
<meta name="robots" content="noindex">
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link href='https://fonts.googleapis.com/css?family=Amatic+SC' rel='stylesheet' type='text/css'>
<title>My Little Clock</title>
<style id="jsbin-css">
#container{
position:absolute;
top:0; bottom:0;
left:0; right:0;
}
#clock{
/*text-align: center;*/
margin:auto auto;
display: table;
position: absolute;
top: 0; bottom: 0;
left: 0; right: 0;
width: 100%;
color: white;
font-family: 'Amatic SC', cursive;
font-size: 18vh;
}
</style>
</head>
<body>
<div id="container">
<div id="clock"></div>
</div>
<script id="jsbin-javascript">
clock();
function clock(){
var date = new Date();
var hours= date.getHours();
var mins = date.getMinutes();
var secs = date.getSeconds();
var thours;
if (hours <= 9) thours = '0' + hours;
if (mins <= 9) mins = '0' + mins;
if (secs <= 9) secs = '0' + secs;
var time = thours + ":" + mins + ":" + secs;
document.getElementById('clock').innerHTML = time;
var hexColor = "#" + (60 + hours) + Math.ceil(60 + 255/60 * mins).toString(16) + Math.ceil(60 + 255/60 * secs).toString(16);
console.log(hexColor);
document.body.style.background = hexColor;
setTimeout(function() {
clock();
}, 1000);
}
</script>
</body>
</html>