Proszę o ocenę mojego zegarka binarnego:
<!doctype html>
<html lang="pl">
<head>
<meta charset="utf-8">
<title>Zegar binarny</title>
<meta name="description" content="">
<meta name="author" content="">
<link rel="stylesheet" href="css/styles.css?v=1.0">
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
<![endif]-->
<style>
body {
margin: 0px;
padding: 0px;
}
.container {
background-image: url('https://static.pexels.com/photos/99577/barn-lightning-bolt-storm-99577.jpeg');
background-size: cover;
background-position: center;
display: flex;
justify-content: center;
align-items: center;
position: fixed;
height: 100%;
width: 100%
}
.clock {
display: flex;
}
.clock > .digit {
display: flex;
flex-direction: column-reverse;
}
.clock > .digit > div {
width: 3vw;
height: 3vw;
margin: 5px;
border: 1px solid white;
transition: all 0.5s;
box-shadow: 0px 0px 5px lightgrey, 0px 0px 15px grey;
}
.active {
background-color: rgba(255, 255, 255, 0.9);
border-radius: 50px;
transform: rotate(180deg);
}
</style>
</head>
<body>
<div class="container">
<div class="clock">
</div>
</div>
<script>
function Clock(node) {
this.node = node,
this.colNumber;
this.init = function() {
var numberBitsInCols = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
numberBitsInCol,
clockDigit,
clockDigitBit,
i,
j;
this.colNumber = numberBitsInCols.length;
for(numberBitsInCol of numberBitsInCols) {
clockDigit = document.createElement('div');
clockDigit.classList.add('digit');
for(j = 0; j < numberBitsInCol; j++) {
clockDigitBit = document.createElement('div');
clockDigit.appendChild(clockDigitBit);
}
this.node.appendChild(clockDigit);
}
}
this.update = function() {
var curDate = new Date(),
y = curDate.getFullYear(),
mo = curDate.getMonth() + 1,
d = curDate.getDate(),
h = curDate.getHours(),
m = curDate.getMinutes(),
s = curDate.getSeconds(),
i,
j;
if(mo < 10) mo = '0' + mo;
if(d < 10) d = '0' + d;
if(h < 10) h = '0' + h;
if(m < 10) m = '0' + m;
if(s < 10) s = '0' + s;
var time = '' + y + mo + d + h + m + s;
for(i = 0; i < this.colNumber; i++) {
var bit = 1,
nodeLength = this.node.children[i].children.length;
for(j = 0; j < nodeLength; j++) {
if(time[i] & bit) {
this.node.children[i].children[j].classList.add('active');
} else {
this.node.children[i].children[j].classList.remove('active');
}
bit *= 2;
}
}
}
}
var clock1 = new Clock(document.querySelector('.clock'));
clock1.init();
setInterval(function() { clock1.update() }, 1000);
</script>
</body>
</html>
P.S. Wiem że to jest w jednym kodzie pomieszane z HTML i CSS ale tak to chciałem zamieścić...