-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
34 lines (34 loc) · 1.02 KB
/
script.js
File metadata and controls
34 lines (34 loc) · 1.02 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
var clock = document.getElementById('clock');
var body = document.getElementById('body');
var colorArray = ['#4FC3F7', '#29B6F6', '#03A9F4', '#039BE5', '#0288D1', '#0277BD', '#01579B', '#9575CD', '#7E57C2', '#673AB7', '#5E35B1', '#512DA8', '#4527A0', '#311B92', '#7986CB', '#5C6BC0', '#3F51B5', '#3949AB', '#303F9F', '#283593', '#1A237E', '#64B5F6', '#42A5F5', '#2196F3', '#1E88E5', '#1976D2', '#1565C0', '#0D47A1'];
function time() {
var d = new Date();
var s = d.getSeconds();
var m = d.getMinutes();
var h = d.getHours();
if(h >= 12) {
h = h - 12;
}
if(h == 0) {
h = 12;
}
if(m < 10){
m = ("0" + m);
}
if(s < 10){
s = ("0" + s);
}
clock.innerHTML = h + "<span class='colon'>:</span>" + m + "<span class='colon'>:</span>"+ s;
}
var i = 0;
function bgChange(){
body.style.backgroundColor = colorArray[i];
i++;
if(i == colorArray.length -1){
i = 0;
}
}
setInterval(function(){
time();
bgChange();
}, 1000);